You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/11/27 04:24:56 UTC
[GitHub] [dolphinscheduler] devosend opened a new pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
devosend opened a new pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022
#6930
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] CalvinKirs merged pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
CalvinKirs merged pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760897936
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.process_definition import ProcessDefinitionContext
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(self, name: str, process_definition_name: str, *args, **kwargs):
+ self._process_definition_name = process_definition_name
+ self._process_definition = {}
+ task_params = SubProcessTaskParams(
+ process_definition_code=self.get_process_definition_code(),
+ )
+ super().__init__(name, TaskType.SUB_PROCESS, task_params, *args, **kwargs)
+
+ def get_process_definition_code(self) -> str:
+ """Get process definition code, a wrapper for :func:`get_process_definition_info`."""
+ return self.get_process_definition_info(self._process_definition_name).get(
+ "code"
+ )
+
+ def get_process_definition_info(self, process_definition_name: str) -> Dict:
+ """Get process definition info from java gateway, contains process definition id, name, code."""
+ if self._process_definition:
+ return self._process_definition
+ else:
+ gateway = launch_gateway()
+ process_definition = ProcessDefinitionContext.get()
Review comment:
Hi @devosend , I do no think it will, for now we have two way to use task in workflow-as-code, with context or direct assignment to task attribute.
```py
# Context mode
# In this case, sub_process would get `self.process_definiton`
# from parent `Task`, and `Task` `self.process_definiton`
# would get from `ProcessDefinitionContext`
with ProcessDefinition(...) as pd:
sub_process = SubProcess(name="test", process_name="sub-name")
# Seperate mode
# We would directly assign ProcessDefinition instance to
# `SubProcess` parameter `process_definiton` and we could use it directly.
pd = ProcessDefinition(...)
sub_process = SubProcess(name="test", process_name="sub-name", process_definiton=pd)
```
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983651962
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] removed a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984672903
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] devosend commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
devosend commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760887208
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.process_definition import ProcessDefinitionContext
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(self, name: str, process_definition_name: str, *args, **kwargs):
+ self._process_definition_name = process_definition_name
+ self._process_definition = {}
+ task_params = SubProcessTaskParams(
+ process_definition_code=self.get_process_definition_code(),
+ )
+ super().__init__(name, TaskType.SUB_PROCESS, task_params, *args, **kwargs)
+
+ def get_process_definition_code(self) -> str:
+ """Get process definition code, a wrapper for :func:`get_process_definition_info`."""
+ return self.get_process_definition_info(self._process_definition_name).get(
+ "code"
+ )
+
+ def get_process_definition_info(self, process_definition_name: str) -> Dict:
+ """Get process definition info from java gateway, contains process definition id, name, code."""
+ if self._process_definition:
+ return self._process_definition
+ else:
+ gateway = launch_gateway()
+ process_definition = ProcessDefinitionContext.get()
Review comment:
Hi @zhongjiajie , thank's for your advice.
Because `process_definition` needs parent class initialization, which will lead to parent-child class initialization depending on each other, I think `process_definition` needs to be acquired in subprocess and then passed to parent class initialization.
like this:
```
self.process_definition = ProcessDefinitionContext.get()
task_params = SubProcessTaskParams(
process_definition_code=self.get_process_definition_code(),
)
super().__init__(
name,
TaskType.SUB_PROCESS,
task_params,
process_definition=self.process_definition,
*args,
**kwargs
)
```
What do you think?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980500963
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7022](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (057f578) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a8aed0f5f7d0c8fd2d8acf04359c9cff8276df14?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a8aed0f) will **decrease** coverage by `0.06%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## dev #7022 +/- ##
============================================
- Coverage 32.67% 32.61% -0.07%
+ Complexity 1607 1605 -2
============================================
Files 431 431
Lines 14340 14340
Branches 1437 1437
============================================
- Hits 4686 4677 -9
- Misses 9203 9213 +10
+ Partials 451 450 -1
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...r/plugin/registry/zookeeper/ZookeeperRegistry.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS9kb2xwaGluc2NoZWR1bGVyLXJlZ2lzdHJ5LXBsdWdpbnMvZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS16b29rZWVwZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL3JlZ2lzdHJ5L3pvb2tlZXBlci9ab29rZWVwZXJSZWdpc3RyeS5qYXZh) | `47.27% <0.00%> (-7.28%)` | :arrow_down: |
| [...er/master/dispatch/host/assign/RandomSelector.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1zZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvc2VydmVyL21hc3Rlci9kaXNwYXRjaC9ob3N0L2Fzc2lnbi9SYW5kb21TZWxlY3Rvci5qYXZh) | `77.77% <0.00%> (-5.56%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a8aed0f...057f578](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984672903
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980502934
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] removed a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980502934
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r759893805
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,73 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict, Optional
+
+from pydolphinscheduler.constants import ProcessDefinitionDefault, TaskType
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(
+ self,
+ name: str,
+ process_definition_name: str,
+ user: Optional[str] = ProcessDefinitionDefault.USER,
+ project_name: Optional[str] = ProcessDefinitionDefault.PROJECT,
Review comment:
I check out DS web definition and found out task `sub process` could only use workflow process definition. As workflow-as-code we already declare `project` and `user`, so maybe we should found a way to get attribute `user` and `project` from `ProcessDefinition`
Maybe at the end it would look like
```py
with ProcessDefinition(
"test-pd-name",
user="specific-user",
project="specific-project",
) as pd:
sub_process = SubProcess(
name = "su-process-task-name",
process_definition_name = "sub-process-definition-name"
)
```
and task `sub_process` could get `user='specific-user'` and `project='specific-project'`. WDYT
##########
File path: dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
##########
@@ -391,6 +391,42 @@ public void createUser(String userName,
return result;
}
+ /**
+ * Get processDefinition by given processDefinitionName name. It return map contain processDefinition id, name, code.
+ * Useful in Python API create subProcess task which need processDefinition information.
+ *
+ * @param userName user who create or update schedule
+ * @param projectName project name which process definition belongs to
+ * @param processDefinitionName process definition name
+ */
+ public Map<String, Object> getProcessDefinitionInfo(String userName, String projectName, String processDefinitionName) {
Review comment:
I found this function is most likely to function `createOrUpdateProcessDefinition` in PythonGatewayServer. Could you add a private function combine your function and function `createOrUpdateProcessDefinition` define?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760902310
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.process_definition import ProcessDefinitionContext
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(self, name: str, process_definition_name: str, *args, **kwargs):
+ self._process_definition_name = process_definition_name
+ self._process_definition = {}
+ task_params = SubProcessTaskParams(
+ process_definition_code=self.get_process_definition_code(),
+ )
+ super().__init__(name, TaskType.SUB_PROCESS, task_params, *args, **kwargs)
+
+ def get_process_definition_code(self) -> str:
+ """Get process definition code, a wrapper for :func:`get_process_definition_info`."""
+ return self.get_process_definition_info(self._process_definition_name).get(
+ "code"
+ )
+
+ def get_process_definition_info(self, process_definition_name: str) -> Dict:
+ """Get process definition info from java gateway, contains process definition id, name, code."""
+ if self._process_definition:
+ return self._process_definition
+ else:
+ gateway = launch_gateway()
+ process_definition = ProcessDefinitionContext.get()
+ self._process_definition = gateway.entry_point.getProcessDefinitionInfo(
+ process_definition.user.name,
+ process_definition.project.name,
+ process_definition_name,
+ )
Review comment:
Here I would give a simple example
```suggestion
if self.process_definition is None:
raise PyDSProcessDefinitionNotAssignException("ProcessDefinition must be provider when SubProcess initialization.")
self._process_definition = gateway.entry_point.getProcessDefinitionInfo(
self.process_definition.user.name,
self.process_definition.project.name,
self.process_definition_name,
)
```
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter edited a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980500963
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7022](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7b259a0) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a8aed0f5f7d0c8fd2d8acf04359c9cff8276df14?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a8aed0f) will **increase** coverage by `7.70%`.
> The diff coverage is `25.14%`.
> :exclamation: Current head 7b259a0 differs from pull request most recent head 0eaaefa. Consider uploading reports for the commit 0eaaefa to get more accurate results
[](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## dev #7022 +/- ##
============================================
+ Coverage 32.67% 40.38% +7.70%
- Complexity 1607 3590 +1983
============================================
Files 431 647 +216
Lines 14340 26316 +11976
Branches 1437 2926 +1489
============================================
+ Hits 4686 10628 +5942
- Misses 9203 14712 +5509
- Partials 451 976 +525
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...org/apache/dolphinscheduler/alert/AlertServer.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hbGVydC9kb2xwaGluc2NoZWR1bGVyLWFsZXJ0LXNlcnZlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZG9scGhpbnNjaGVkdWxlci9hbGVydC9BbGVydFNlcnZlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...er/api/controller/ProcessDefinitionController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUHJvY2Vzc0RlZmluaXRpb25Db250cm9sbGVyLmphdmE=) | `48.75% <ø> (ø)` | |
| [.../api/controller/ProcessTaskRelationController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUHJvY2Vzc1Rhc2tSZWxhdGlvbkNvbnRyb2xsZXIuamF2YQ==) | `13.04% <0.00%> (ø)` | |
| [...api/service/impl/ProcessDefinitionServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9Qcm9jZXNzRGVmaW5pdGlvblNlcnZpY2VJbXBsLmphdmE=) | `26.44% <0.00%> (ø)` | |
| [.../org/apache/dolphinscheduler/common/Constants.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL0NvbnN0YW50cy5qYXZh) | `80.00% <ø> (ø)` | |
| [...pache/dolphinscheduler/common/enums/CacheType.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2VudW1zL0NhY2hlVHlwZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...dolphinscheduler/common/enums/ExecutionStatus.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2VudW1zL0V4ZWN1dGlvblN0YXR1cy5qYXZh) | `63.15% <ø> (ø)` | |
| [...heduler/common/task/switchtask/SwitchResultVo.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3Rhc2svc3dpdGNodGFzay9Td2l0Y2hSZXN1bHRWby5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...eduler/dao/datasource/SpringConnectionFactory.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL2RhdGFzb3VyY2UvU3ByaW5nQ29ubmVjdGlvbkZhY3RvcnkuamF2YQ==) | `100.00% <ø> (ø)` | |
| [...dolphinscheduler/dao/entity/ProcessDefinition.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL2VudGl0eS9Qcm9jZXNzRGVmaW5pdGlvbi5qYXZh) | `57.94% <ø> (ø)` | |
| ... and [249 more](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a8aed0f...0eaaefa](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] devosend commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
devosend commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984703858
@zhongjiajie I modified the code, re-review please.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984501122
@devosend Please mentioned me if you submit new commit to this PR
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter edited a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980500963
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7022](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (25d1ff3) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a8aed0f5f7d0c8fd2d8acf04359c9cff8276df14?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a8aed0f) will **increase** coverage by `7.82%`.
> The diff coverage is `26.74%`.
> :exclamation: Current head 25d1ff3 differs from pull request most recent head e54457f. Consider uploading reports for the commit e54457f to get more accurate results
[](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## dev #7022 +/- ##
============================================
+ Coverage 32.67% 40.50% +7.82%
- Complexity 1607 3585 +1978
============================================
Files 431 647 +216
Lines 14340 26375 +12035
Branches 1437 2936 +1499
============================================
+ Hits 4686 10682 +5996
- Misses 9203 14699 +5496
- Partials 451 994 +543
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...org/apache/dolphinscheduler/alert/AlertServer.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hbGVydC9kb2xwaGluc2NoZWR1bGVyLWFsZXJ0LXNlcnZlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZG9scGhpbnNjaGVkdWxlci9hbGVydC9BbGVydFNlcnZlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...er/api/controller/ProcessDefinitionController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUHJvY2Vzc0RlZmluaXRpb25Db250cm9sbGVyLmphdmE=) | `48.75% <ø> (ø)` | |
| [.../api/controller/ProcessTaskRelationController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUHJvY2Vzc1Rhc2tSZWxhdGlvbkNvbnRyb2xsZXIuamF2YQ==) | `13.04% <0.00%> (ø)` | |
| [.../org/apache/dolphinscheduler/common/Constants.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL0NvbnN0YW50cy5qYXZh) | `80.00% <ø> (ø)` | |
| [...pache/dolphinscheduler/common/enums/CacheType.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2VudW1zL0NhY2hlVHlwZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...dolphinscheduler/common/enums/ExecutionStatus.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL2VudW1zL0V4ZWN1dGlvblN0YXR1cy5qYXZh) | `63.15% <ø> (ø)` | |
| [...heduler/common/task/switchtask/SwitchResultVo.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1jb21tb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvY29tbW9uL3Rhc2svc3dpdGNodGFzay9Td2l0Y2hSZXN1bHRWby5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...eduler/dao/datasource/SpringConnectionFactory.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL2RhdGFzb3VyY2UvU3ByaW5nQ29ubmVjdGlvbkZhY3RvcnkuamF2YQ==) | `100.00% <ø> (ø)` | |
| [...dolphinscheduler/dao/entity/ProcessDefinition.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL2VudGl0eS9Qcm9jZXNzRGVmaW5pdGlvbi5qYXZh) | `57.94% <ø> (ø)` | |
| [...e/dolphinscheduler/dao/entity/ProcessInstance.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1kYW8vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvZGFvL2VudGl0eS9Qcm9jZXNzSW5zdGFuY2UuamF2YQ==) | `66.66% <ø> (ø)` | |
| ... and [257 more](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a8aed0f...e54457f](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter edited a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-980500963
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#7022](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f75e1f1) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a8aed0f5f7d0c8fd2d8acf04359c9cff8276df14?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a8aed0f) will **decrease** coverage by `0.05%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## dev #7022 +/- ##
============================================
- Coverage 32.67% 32.62% -0.06%
+ Complexity 1607 1606 -1
============================================
Files 431 431
Lines 14340 14340
Branches 1437 1437
============================================
- Hits 4686 4678 -8
- Misses 9203 9213 +10
+ Partials 451 449 -2
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...r/plugin/registry/zookeeper/ZookeeperRegistry.java](https://codecov.io/gh/apache/dolphinscheduler/pull/7022/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS9kb2xwaGluc2NoZWR1bGVyLXJlZ2lzdHJ5LXBsdWdpbnMvZG9scGhpbnNjaGVkdWxlci1yZWdpc3RyeS16b29rZWVwZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL3JlZ2lzdHJ5L3pvb2tlZXBlci9ab29rZWVwZXJSZWdpc3RyeS5qYXZh) | `47.27% <0.00%> (-7.28%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a8aed0f...f75e1f1](https://codecov.io/gh/apache/dolphinscheduler/pull/7022?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984274544
BTW, to target specific issue from PR, we recommend use keyword `fix: #issue_id` or `close: #issue_id` or `closes: #issue_id` in your PR describe(not title). I would not only connect issue to PR but also close issue automatically when PR is be closed.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984481800
Oh I got it and thanks @devosend to clarification 👍 , this because parent class init before `taskParam` class init, and we need attribute `process_definition` in `taskParam`, it would cause cycle dependence
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984578339
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760740529
##########
File path: dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
##########
@@ -243,6 +236,25 @@ public Long createOrUpdateProcessDefinition(String userName,
return processDefinitionCode;
}
+ private ProcessDefinition getProcessDefinition(User user, long projectCode, String processDefineName) {
Review comment:
Could you please add function comment on this?
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.process_definition import ProcessDefinitionContext
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(self, name: str, process_definition_name: str, *args, **kwargs):
+ self._process_definition_name = process_definition_name
+ self._process_definition = {}
+ task_params = SubProcessTaskParams(
+ process_definition_code=self.get_process_definition_code(),
+ )
+ super().__init__(name, TaskType.SUB_PROCESS, task_params, *args, **kwargs)
+
+ def get_process_definition_code(self) -> str:
+ """Get process definition code, a wrapper for :func:`get_process_definition_info`."""
+ return self.get_process_definition_info(self._process_definition_name).get(
+ "code"
+ )
+
+ def get_process_definition_info(self, process_definition_name: str) -> Dict:
+ """Get process definition info from java gateway, contains process definition id, name, code."""
+ if self._process_definition:
+ return self._process_definition
+ else:
+ gateway = launch_gateway()
+ process_definition = ProcessDefinitionContext.get()
Review comment:
Hi @devosend, we already have attribute `process_definition` in base `Task` class in
https://github.com/apache/dolphinscheduler/blob/d93248acbc3f7f1db299f7573b1403575f6da2a0/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/task.py#L152-L154
So maybe you could just use statement `self.process_definition` to call it.
But take of one edge case, when user assign outside the `ProcessDefinition` context and not assign `process_definiton` by them self, we would got null as return. So maybe we should check `self.process_definiton` value before we use it. if value is `None` we should raise error. I recommend you add new exception in https://github.com/apache/dolphinscheduler/blob/d93248acbc3f7f1db299f7573b1403575f6da2a0/dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/exceptions.py#L18 named `PyDSProcessDefinitionNotAssignException` or something like that.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984690514
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983342879
BTW, Do you mind to add me wechat @devosend ? my wechat id is `zhongjiajie955, maybe we could discuss our workflow-as-code‘s future
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] devosend commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
devosend commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760222070
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,73 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict, Optional
+
+from pydolphinscheduler.constants import ProcessDefinitionDefault, TaskType
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(
+ self,
+ name: str,
+ process_definition_name: str,
+ user: Optional[str] = ProcessDefinitionDefault.USER,
+ project_name: Optional[str] = ProcessDefinitionDefault.PROJECT,
Review comment:
thank's for your advice!
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] removed a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983651962
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie edited a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie edited a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984501122
@devosend Please mentioned me if you submit new commit to this PR, I would review ASAP.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] removed a comment on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-984578339
SonarCloud Quality Gate failed. 
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=7022&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=7022&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983314555
Good job! 👍 I would take a look right now!
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] devosend commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
devosend commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983252183
@zhongjiajie I had submit a PR,looking forward to your review and merge.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] devosend commented on pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
devosend commented on pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#issuecomment-983684617
I change code for your advice, re-review please! @zhongjiajie
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a change in pull request #7022: [Feature-6930] [Python]Add workflow as code task type sub_process
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on a change in pull request #7022:
URL: https://github.com/apache/dolphinscheduler/pull/7022#discussion_r760898353
##########
File path: dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/sub_process.py
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Task sub_process."""
+
+from typing import Dict
+
+from pydolphinscheduler.constants import TaskType
+from pydolphinscheduler.core.process_definition import ProcessDefinitionContext
+from pydolphinscheduler.core.task import Task, TaskParams
+from pydolphinscheduler.java_gateway import launch_gateway
+
+
+class SubProcessTaskParams(TaskParams):
+ """Parameter only for Sub Process task type."""
+
+ def __init__(self, process_definition_code, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.process_definition_code = process_definition_code
+
+
+class SubProcess(Task):
+ """Task SubProcess object, declare behavior for SubProcess task to dolphinscheduler."""
+
+ def __init__(self, name: str, process_definition_name: str, *args, **kwargs):
+ self._process_definition_name = process_definition_name
+ self._process_definition = {}
+ task_params = SubProcessTaskParams(
+ process_definition_code=self.get_process_definition_code(),
+ )
+ super().__init__(name, TaskType.SUB_PROCESS, task_params, *args, **kwargs)
+
+ def get_process_definition_code(self) -> str:
+ """Get process definition code, a wrapper for :func:`get_process_definition_info`."""
+ return self.get_process_definition_info(self._process_definition_name).get(
+ "code"
+ )
+
+ def get_process_definition_info(self, process_definition_name: str) -> Dict:
+ """Get process definition info from java gateway, contains process definition id, name, code."""
+ if self._process_definition:
+ return self._process_definition
+ else:
+ gateway = launch_gateway()
+ process_definition = ProcessDefinitionContext.get()
Review comment:
Did I miss something in this case?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org