Skip to content

Commit 8c4d42f

Browse files
committed
Revert "[fix] Resource upload in dev branch (#35)"
This reverts commit 85a1dfa.
1 parent 229aa8b commit 8c4d42f

8 files changed

Lines changed: 23 additions & 28 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
integrate-test:
152152
needs: license
153153
runs-on: ubuntu-latest
154-
if: ${{ github.event_name == 'schedule' }} || contains(github.event.head_commit.message, '[run-it]')
154+
if: ${{ github.event_name == 'schedule' || contains(github.event.head_commit.message, '[run-it]') }}
155155
timeout-minutes: 30
156156
steps:
157157
- name: Checkout Dolphinscheduler SDK Python

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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,19 @@ 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.content,
72+
self.description,
7273
)

src/pydolphinscheduler/core/task.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,18 @@ def resource_list(self) -> List[Dict[str, Resource]]:
221221
for res in self._resource_list:
222222
if type(res) == str:
223223
resources.add(
224-
Resource(
225-
name=res, user_name=self.user_name
226-
).get_fullname_from_database()
224+
Resource(name=res, user_name=self.user_name).get_id_from_database()
227225
)
228-
elif type(res) == dict and ResourceKey.NAME in res:
226+
elif type(res) == dict and res.get(ResourceKey.ID) is not None:
229227
warnings.warn(
230228
"""`resource_list` should be defined using List[str] with resource paths,
231229
the use of ids to define resources will be remove in version 3.2.0.
232230
""",
233231
DeprecationWarning,
234232
stacklevel=2,
235233
)
236-
resources.add(res.get(ResourceKey.NAME))
237-
return [{ResourceKey.NAME: r} for r in resources]
234+
resources.add(res.get(ResourceKey.ID))
235+
return [{ResourceKey.ID: r} for r in resources]
238236

239237
@property
240238
def user_name(self) -> Optional[str]:

src/pydolphinscheduler/java_gateway.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ def get_resources_file_info(self, program_type: str, main_package: str):
116116
"""Get resources file info through java gateway."""
117117
return self.gateway.entry_point.getResourcesFileInfo(program_type, main_package)
118118

119-
def create_or_update_resource(self, user_name: str, name: str, content: str):
119+
def create_or_update_resource(
120+
self, user_name: str, name: str, content: str, description: Optional[str] = None
121+
):
120122
"""Create or update resource through java gateway."""
121-
return self.gateway.entry_point.createOrUpdateResource(user_name, name, content)
123+
return self.gateway.entry_point.createOrUpdateResource(
124+
user_name, name, description, content
125+
)
122126

123127
def query_resources_file_info(self, user_name: str, name: str):
124128
"""Get resources file info through java gateway."""

tests/core/test_task.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_task_timeout(value: timedelta, expect: Tuple[int, str]):
146146
},
147147
{
148148
"localParams": ["foo", "bar"],
149-
"resourceList": [{"resourceName": 1}],
149+
"resourceList": [{"id": 1}],
150150
"dependence": {"foo", "bar"},
151151
"waitStartTimeout": {"foo", "bar"},
152152
"conditionResult": {"foo": ["bar"]},
@@ -155,7 +155,7 @@ def test_task_timeout(value: timedelta, expect: Tuple[int, str]):
155155
],
156156
)
157157
@patch(
158-
"pydolphinscheduler.core.resource.Resource.get_fullname_from_database",
158+
"pydolphinscheduler.core.resource.Resource.get_id_from_database",
159159
return_value=1,
160160
)
161161
@patch(
@@ -478,11 +478,11 @@ def test_task_obtain_res_plugin_exception(m_get_content, m_code_version, attr):
478478
[
479479
(
480480
["/dev/test.py"],
481-
[{"resourceName": 1}],
481+
[{"id": 1}],
482482
),
483483
(
484-
["/dev/test.py", {"resourceName": 2}],
485-
[{"resourceName": 1}, {"resourceName": 2}],
484+
["/dev/test.py", {"id": 2}],
485+
[{"id": 1}, {"id": 2}],
486486
),
487487
],
488488
)
@@ -491,7 +491,7 @@ def test_task_obtain_res_plugin_exception(m_get_content, m_code_version, attr):
491491
return_value=(123, 1),
492492
)
493493
@patch(
494-
"pydolphinscheduler.core.resource.Resource.get_fullname_from_database",
494+
"pydolphinscheduler.core.resource.Resource.get_id_from_database",
495495
return_value=1,
496496
)
497497
@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)

tests/testing/constants.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
"task_flink_example",
3737
"task_map_reduce_example",
3838
"task_spark_example",
39-
# TODO activate it when dolphinscheduler default resource center is local file
40-
"multi_resources_example",
4139
}
4240

4341
# pydolphinscheduler environment home

0 commit comments

Comments
 (0)