Revert "[fix] Resource upload in dev branch (#35)"
This reverts commit 85a1dfaaa72b41dc6e9376ba56c404f93140a18a.
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 35af018..7268186 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -151,7 +151,7 @@
integrate-test:
needs: license
runs-on: ubuntu-latest
- if: ${{ github.event_name == 'schedule' }} || contains(github.event.head_commit.message, '[run-it]')
+ if: ${{ github.event_name == 'schedule' || contains(github.event.head_commit.message, '[run-it]') }}
timeout-minutes: 30
steps:
- name: Checkout Dolphinscheduler SDK Python
diff --git a/src/pydolphinscheduler/constants.py b/src/pydolphinscheduler/constants.py
index 0519688..16494cf 100644
--- a/src/pydolphinscheduler/constants.py
+++ b/src/pydolphinscheduler/constants.py
@@ -112,7 +112,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 32d87bc..a6fbebd 100644
--- a/src/pydolphinscheduler/core/task.py
+++ b/src/pydolphinscheduler/core/task.py
@@ -221,11 +221,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.
@@ -233,8 +231,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 46a284e..6b28bde 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 40a3e9c..4b86af4 100644
--- a/tests/core/test_task.py
+++ b/tests/core/test_task.py
@@ -146,7 +146,7 @@
},
{
"localParams": ["foo", "bar"],
- "resourceList": [{"resourceName": 1}],
+ "resourceList": [{"id": 1}],
"dependence": {"foo", "bar"},
"waitStartTimeout": {"foo", "bar"},
"conditionResult": {"foo": ["bar"]},
@@ -155,7 +155,7 @@
],
)
@patch(
- "pydolphinscheduler.core.resource.Resource.get_fullname_from_database",
+ "pydolphinscheduler.core.resource.Resource.get_id_from_database",
return_value=1,
)
@patch(
@@ -478,11 +478,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}],
),
],
)
@@ -491,7 +491,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)
diff --git a/tests/testing/constants.py b/tests/testing/constants.py
index 4dfaa37..dbbf5e5 100644
--- a/tests/testing/constants.py
+++ b/tests/testing/constants.py
@@ -36,8 +36,6 @@
"task_flink_example",
"task_map_reduce_example",
"task_spark_example",
- # TODO activate it when dolphinscheduler default resource center is local file
- "multi_resources_example",
}
# pydolphinscheduler environment home