zhongjiajie commented on code in PR #10515:
URL: https://github.com/apache/dolphinscheduler/pull/10515#discussion_r903492117
##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/python.py:
##########
@@ -100,3 +108,21 @@ def raw_script(self) -> str:
raise PyDSParamException(
"Parameter definition do not support % for now.",
type(self.definition)
)
+
+ @property
+ def resource_list(self) -> List:
+ """Get python task define attribute `resource_list`."""
+ if super().resource_list is not None and len(super().resource_list) >
0:
+ for resource in super().resource_list:
+ if (
+ resource.get("id") is None
+ and resource.get("resourceName") is not None
+ ):
+ if resource.get("resourceType") is not None:
+ resource_type = resource.get("resourceType")
+ else:
+ resource_type = "FILE"
+ resource["id"] = self.query_resource(
+ resource_type, resource.get("resourceName")
+ ).get("id")
+ return super().resource_list
Review Comment:
I think we should better put this to `pydolphinscheduler.core.task` instead
of python.py. because I know we also support it in shell task. and in the
`core.task` we can add some code like
```py
@property
def resource_list(self) -> List:
"""Get attribute resource_list."""
resources = set()
for resource in self._resource_list:
resources.add(query_resource(resource_type, resource))
return [{"id": r.get("id")} for r in resources]
@resource_list.setter
def resource_list(self, val) -> None:
"""Get attribute resource_list."""
return self._resource_list = val
```
##########
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/python.py:
##########
@@ -100,3 +108,21 @@ def raw_script(self) -> str:
raise PyDSParamException(
"Parameter definition do not support % for now.",
type(self.definition)
)
+
+ @property
+ def resource_list(self) -> List:
+ """Get python task define attribute `resource_list`."""
+ if super().resource_list is not None and len(super().resource_list) >
0:
+ for resource in super().resource_list:
+ if (
+ resource.get("id") is None
+ and resource.get("resourceName") is not None
+ ):
+ if resource.get("resourceType") is not None:
+ resource_type = resource.get("resourceType")
+ else:
+ resource_type = "FILE"
+ resource["id"] = self.query_resource(
+ resource_type, resource.get("resourceName")
+ ).get("id")
+ return super().resource_list
Review Comment:
BTW, why we need resource type to query the resources?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]