Skip to content

Commit 8fb5d64

Browse files
authored
fix: Resource config error and failed workflow run (#116)
1 parent b56ba23 commit 8fb5d64

5 files changed

Lines changed: 15 additions & 23 deletions

File tree

src/pydolphinscheduler/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Time(str):
112112
class ResourceKey(str):
113113
"""Constants for key of resource."""
114114

115-
NAME = "resourceName"
115+
ID = "id"
116116

117117

118118
class Symbol(str):

src/pydolphinscheduler/core/resource.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ def get_info_from_database(self):
5555
)
5656
return gateway.query_resources_file_info(self.user_name, self.name)
5757

58-
def get_fullname_from_database(self):
59-
"""Get resource fullname from java gateway."""
60-
return self.get_info_from_database().getFullName()
58+
def get_id_from_database(self):
59+
"""Get resource id from java gateway."""
60+
return self.get_info_from_database().getId()
6161

6262
def create_or_update_resource(self):
6363
"""Create or update resource via java gateway."""
6464
if not self.content or not self.user_name:
6565
raise PyDSParamException(
6666
"`user_name` and `content` are required when create or update resource from python gate."
6767
)
68-
return gateway.create_or_update_resource(
68+
gateway.create_or_update_resource(
6969
self.user_name,
7070
self.name,
7171
self.description,

src/pydolphinscheduler/core/task.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,18 @@ def resource_list(self) -> List[Dict[str, Resource]]:
262262
for res in self._resource_list:
263263
if isinstance(res, str):
264264
resources.add(
265-
Resource(
266-
name=res, user_name=self.user_name
267-
).get_fullname_from_database()
265+
Resource(name=res, user_name=self.user_name).get_id_from_database()
268266
)
269-
elif isinstance(res, dict) and ResourceKey.NAME in res:
267+
elif isinstance(res, dict) and res.get(ResourceKey.ID) is not None:
270268
warnings.warn(
271269
"""`resource_list` should be defined using List[str] with resource paths,
272270
the use of ids to define resources will be remove in version 3.2.0.
273271
""",
274272
DeprecationWarning,
275273
stacklevel=2,
276274
)
277-
resources.add(res.get(ResourceKey.NAME))
278-
return [{ResourceKey.NAME: r} for r in resources]
275+
resources.add(res.get(ResourceKey.ID))
276+
return [{ResourceKey.ID: r} for r in resources]
279277

280278
@property
281279
def user_name(self) -> Optional[str]:

tests/core/test_task.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_task_timeout(value: timedelta, expect: Tuple[int, str]):
147147
},
148148
{
149149
"localParams": ["foo", "bar"],
150-
"resourceList": [{"resourceName": 1}],
150+
"resourceList": [{"id": 1}],
151151
"dependence": {"foo", "bar"},
152152
"waitStartTimeout": {"foo", "bar"},
153153
"conditionResult": {"foo": ["bar"]},
@@ -156,7 +156,7 @@ def test_task_timeout(value: timedelta, expect: Tuple[int, str]):
156156
],
157157
)
158158
@patch(
159-
"pydolphinscheduler.core.resource.Resource.get_fullname_from_database",
159+
"pydolphinscheduler.core.resource.Resource.get_id_from_database",
160160
return_value=1,
161161
)
162162
@patch(
@@ -481,11 +481,11 @@ def test_task_obtain_res_plugin_exception(m_get_content, m_code_version, attr):
481481
[
482482
(
483483
["/dev/test.py"],
484-
[{"resourceName": 1}],
484+
[{"id": 1}],
485485
),
486486
(
487-
["/dev/test.py", {"resourceName": 2}],
488-
[{"resourceName": 1}, {"resourceName": 2}],
487+
["/dev/test.py", {"id": 2}],
488+
[{"id": 1}, {"id": 2}],
489489
),
490490
],
491491
)
@@ -494,7 +494,7 @@ def test_task_obtain_res_plugin_exception(m_get_content, m_code_version, attr):
494494
return_value=(123, 1),
495495
)
496496
@patch(
497-
"pydolphinscheduler.core.resource.Resource.get_fullname_from_database",
497+
"pydolphinscheduler.core.resource.Resource.get_id_from_database",
498498
return_value=1,
499499
)
500500
@patch(

tests/integration/test_resources.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ def tmp_user():
4545
user.delete()
4646

4747

48-
@pytest.mark.skip(
49-
"activate it when dolphinscheduler default resource center is local file"
50-
)
5148
def test_create_or_update(tmp_user):
5249
"""Test create or update resource to java gateway."""
5350
resource = Resource(name=name, content=content, user_name=UNIT_TEST_USER_NAME)
@@ -56,9 +53,6 @@ def test_create_or_update(tmp_user):
5653
assert result.getAlias() == name
5754

5855

59-
@pytest.mark.skip(
60-
"activate it when dolphinscheduler default resource center is local file"
61-
)
6256
def test_get_resource_info(tmp_user):
6357
"""Test get resource info from java gateway."""
6458
resource = Resource(name=name, user_name=UNIT_TEST_USER_NAME)

0 commit comments

Comments
 (0)