Revert "[fix] Resource upload in dev branch (#35)" This reverts commit 85a1dfaa
diff --git a/RELEASE.md b/RELEASE.md index 62aad00..f8b8b52 100644 --- a/RELEASE.md +++ b/RELEASE.md
@@ -39,6 +39,10 @@ # Install or upgrade dependencies python3 -m pip install --upgrade pip build twine +# Configuration during the releasing +VERSION=<VERSION> # The version of the package you want to release, e.g. 1.2.3 +REMOTE=<REMOTE> # The git remote name, we usually use `origin` or `remote` + # Change version # For macOS sed -i '' "s/__version__ = \".*\"/__version__ = \"${VERSION}\"/" src/pydolphinscheduler/__init__.py @@ -47,8 +51,6 @@ git commit -am "Release v${VERSION}" # Add Tag -VERSION=<VERSION> # The version of the package you want to release, e.g. 1.2.3 -REMOTE=<REMOTE> # The git remote name, we usually use `origin` or `remote` git tag -a "${VERSION}" -m "Release v${VERSION}" git push "${REMOTE}" --tags @@ -68,9 +70,9 @@ ```shell svn co https://dist.apache.org/repos/dist/dev/dolphinscheduler/ release/dolphinscheduler mkdir -p release/dolphinscheduler/python/"${VERSION}" -cp dolphinscheduler-python-src-"${VERSION}"* release/dolphinscheduler/python/"${VERSION}" +cp dist/dolphinscheduler-python-src-"${VERSION}"* release/dolphinscheduler/python/"${VERSION}" -cd release/dolphinscheduler && svn add python && svn commit python -m "Release Apache DolphinScheduler-SDK-Python version ${VERSION}" +cd release/dolphinscheduler && svn add python/"${VERSION}" && svn commit python -m "Release Apache DolphinScheduler-SDK-Python version ${VERSION}" ``` ### Vote Mail
diff --git a/src/pydolphinscheduler/constants.py b/src/pydolphinscheduler/constants.py index e158892..b6067c8 100644 --- a/src/pydolphinscheduler/constants.py +++ b/src/pydolphinscheduler/constants.py
@@ -119,7 +119,7 @@ class ResourceKey(str): """Constants for key of resource.""" - NAME = "resourceName" + ID = "id" class Symbol(str):
diff --git a/src/pydolphinscheduler/core/resource.py b/src/pydolphinscheduler/core/resource.py index 907114f..6833efa 100644 --- a/src/pydolphinscheduler/core/resource.py +++ b/src/pydolphinscheduler/core/resource.py
@@ -55,9 +55,9 @@ ) return gateway.query_resources_file_info(self.user_name, self.name) - def get_fullname_from_database(self): - """Get resource fullname from java gateway.""" - return self.get_info_from_database().getFullName() + def get_id_from_database(self): + """Get resource id from java gateway.""" + return self.get_info_from_database().getId() def create_or_update_resource(self): """Create or update resource via java gateway.""" @@ -65,8 +65,9 @@ raise PyDSParamException( "`user_name` and `content` are required when create or update resource from python gate." ) - return gateway.create_or_update_resource( + gateway.create_or_update_resource( self.user_name, self.name, self.content, + self.description, )
diff --git a/src/pydolphinscheduler/core/task.py b/src/pydolphinscheduler/core/task.py index f0d3e83..2fda2a1 100644 --- a/src/pydolphinscheduler/core/task.py +++ b/src/pydolphinscheduler/core/task.py
@@ -267,11 +267,9 @@ for res in self._resource_list: if type(res) == str: resources.add( - Resource( - name=res, user_name=self.user_name - ).get_fullname_from_database() + Resource(name=res, user_name=self.user_name).get_id_from_database() ) - elif type(res) == dict and ResourceKey.NAME in res: + elif type(res) == dict and res.get(ResourceKey.ID) is not None: warnings.warn( """`resource_list` should be defined using List[str] with resource paths, the use of ids to define resources will be remove in version 3.2.0. @@ -279,8 +277,8 @@ DeprecationWarning, stacklevel=2, ) - resources.add(res.get(ResourceKey.NAME)) - return [{ResourceKey.NAME: r} for r in resources] + resources.add(res.get(ResourceKey.ID)) + return [{ResourceKey.ID: r} for r in resources] @property def user_name(self) -> Optional[str]:
diff --git a/src/pydolphinscheduler/java_gateway.py b/src/pydolphinscheduler/java_gateway.py index dcf4fe8..e8ec2c1 100644 --- a/src/pydolphinscheduler/java_gateway.py +++ b/src/pydolphinscheduler/java_gateway.py
@@ -116,9 +116,13 @@ """Get resources file info through java gateway.""" return self.gateway.entry_point.getResourcesFileInfo(program_type, main_package) - def create_or_update_resource(self, user_name: str, name: str, content: str): + def create_or_update_resource( + self, user_name: str, name: str, content: str, description: Optional[str] = None + ): """Create or update resource through java gateway.""" - return self.gateway.entry_point.createOrUpdateResource(user_name, name, content) + return self.gateway.entry_point.createOrUpdateResource( + user_name, name, description, content + ) def query_resources_file_info(self, user_name: str, name: str): """Get resources file info through java gateway."""
diff --git a/tests/core/test_task.py b/tests/core/test_task.py index d34b6d2..014a906 100644 --- a/tests/core/test_task.py +++ b/tests/core/test_task.py
@@ -147,7 +147,7 @@ }, { "localParams": ["foo", "bar"], - "resourceList": [{"resourceName": 1}], + "resourceList": [{"id": 1}], "dependence": {"foo", "bar"}, "waitStartTimeout": {"foo", "bar"}, "conditionResult": {"foo": ["bar"]}, @@ -156,7 +156,7 @@ ], ) @patch( - "pydolphinscheduler.core.resource.Resource.get_fullname_from_database", + "pydolphinscheduler.core.resource.Resource.get_id_from_database", return_value=1, ) @patch( @@ -480,11 +480,11 @@ [ ( ["/dev/test.py"], - [{"resourceName": 1}], + [{"id": 1}], ), ( - ["/dev/test.py", {"resourceName": 2}], - [{"resourceName": 1}, {"resourceName": 2}], + ["/dev/test.py", {"id": 2}], + [{"id": 1}, {"id": 2}], ), ], ) @@ -493,7 +493,7 @@ return_value=(123, 1), ) @patch( - "pydolphinscheduler.core.resource.Resource.get_fullname_from_database", + "pydolphinscheduler.core.resource.Resource.get_id_from_database", return_value=1, ) @patch(
diff --git a/tests/integration/test_resources.py b/tests/integration/test_resources.py index a8fd8f7..ee1d99d 100644 --- a/tests/integration/test_resources.py +++ b/tests/integration/test_resources.py
@@ -45,9 +45,6 @@ user.delete() -@pytest.mark.skip( - "activate it when dolphinscheduler default resource center is local file" -) def test_create_or_update(tmp_user): """Test create or update resource to java gateway.""" resource = Resource(name=name, content=content, user_name=UNIT_TEST_USER_NAME) @@ -56,9 +53,6 @@ assert result.getAlias() == name -@pytest.mark.skip( - "activate it when dolphinscheduler default resource center is local file" -) def test_get_resource_info(tmp_user): """Test get resource info from java gateway.""" resource = Resource(name=name, user_name=UNIT_TEST_USER_NAME)