|
|
@ -32,6 +32,8 @@ from pydolphinscheduler.core.process_definition import ( |
|
|
|
ProcessDefinition, |
|
|
|
ProcessDefinition, |
|
|
|
ProcessDefinitionContext, |
|
|
|
ProcessDefinitionContext, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
from pydolphinscheduler.core.resource import Resource |
|
|
|
|
|
|
|
from pydolphinscheduler.exceptions import PyDSParamException |
|
|
|
from pydolphinscheduler.java_gateway import launch_gateway |
|
|
|
from pydolphinscheduler.java_gateway import launch_gateway |
|
|
|
from pydolphinscheduler.models import Base |
|
|
|
from pydolphinscheduler.models import Base |
|
|
|
|
|
|
|
|
|
|
@ -175,18 +177,28 @@ class Task(Base): |
|
|
|
def resource_list(self) -> List: |
|
|
|
def resource_list(self) -> List: |
|
|
|
"""Get task define attribute `resource_list`.""" |
|
|
|
"""Get task define attribute `resource_list`.""" |
|
|
|
resources = set() |
|
|
|
resources = set() |
|
|
|
for resource in self._resource_list: |
|
|
|
for res in self._resource_list: |
|
|
|
if type(resource) == str: |
|
|
|
if type(res) == str: |
|
|
|
resources.add(self.query_resource(resource).get(ResourceKey.ID)) |
|
|
|
resources.add( |
|
|
|
elif type(resource) == dict and resource.get(ResourceKey.ID) is not None: |
|
|
|
Resource(name=res, user_name=self.user_name).get_id_from_database() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
elif type(res) == dict and res.get(ResourceKey.ID) is not None: |
|
|
|
logger.warning( |
|
|
|
logger.warning( |
|
|
|
"""`resource_list` should be defined using List[str] with resource paths, |
|
|
|
"""`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. |
|
|
|
the use of ids to define resources will be remove in version 3.2.0. |
|
|
|
""" |
|
|
|
""" |
|
|
|
) |
|
|
|
) |
|
|
|
resources.add(resource.get(ResourceKey.ID)) |
|
|
|
resources.add(res.get(ResourceKey.ID)) |
|
|
|
return [{ResourceKey.ID: r} for r in resources] |
|
|
|
return [{ResourceKey.ID: r} for r in resources] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
|
|
def user_name(self) -> Optional[str]: |
|
|
|
|
|
|
|
"""Return user name of process definition.""" |
|
|
|
|
|
|
|
if self.process_definition: |
|
|
|
|
|
|
|
return self.process_definition.user.name |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
raise PyDSParamException("`user_name` cannot be empty.") |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def condition_result(self) -> Dict: |
|
|
|
def condition_result(self) -> Dict: |
|
|
|
"""Get attribute condition_result.""" |
|
|
|
"""Get attribute condition_result.""" |
|
|
@ -295,10 +307,3 @@ class Task(Base): |
|
|
|
# result = gateway.entry_point.genTaskCodeList(DefaultTaskCodeNum.DEFAULT) |
|
|
|
# result = gateway.entry_point.genTaskCodeList(DefaultTaskCodeNum.DEFAULT) |
|
|
|
# gateway_result_checker(result) |
|
|
|
# gateway_result_checker(result) |
|
|
|
return result.get("code"), result.get("version") |
|
|
|
return result.get("code"), result.get("version") |
|
|
|
|
|
|
|
|
|
|
|
def query_resource(self, full_name): |
|
|
|
|
|
|
|
"""Get resource info from java gateway, contains resource id, name.""" |
|
|
|
|
|
|
|
gateway = launch_gateway() |
|
|
|
|
|
|
|
return gateway.entry_point.queryResourcesFileInfo( |
|
|
|
|
|
|
|
self.process_definition.user.name, full_name |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|