Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
三久
DolphinScheduler
提交
a2cd2a99
DolphinScheduler
项目概览
三久
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
a2cd2a99
编写于
5月 16, 2022
作者:
陈
陈家名
提交者:
GitHub
5月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[python] Fix pre_submit_check error when local params in tasks (#10032)
上级
b1885c7a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
4 deletion
+37
-4
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py
...heduler/src/pydolphinscheduler/core/process_definition.py
+4
-2
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/switch.py
...pydolphinscheduler/src/pydolphinscheduler/tasks/switch.py
+5
-1
dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py
.../pydolphinscheduler/tests/core/test_process_definition.py
+28
-1
未找到文件。
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/core/process_definition.py
浏览文件 @
a2cd2a99
...
...
@@ -350,14 +350,16 @@ class ProcessDefinition(Base):
This method should be called before process definition submit to java gateway
For now, we have below checker:
* `self.param` should be set if task `switch` in this workflow.
* `self.param`
or at least one local param of task
should be set if task `switch` in this workflow.
"""
if
(
any
([
task
.
task_type
==
TaskType
.
SWITCH
for
task
in
self
.
tasks
.
values
()])
and
self
.
param
is
None
and
all
([
len
(
task
.
local_params
)
==
0
for
task
in
self
.
tasks
.
values
()])
):
raise
PyDSParamException
(
"Parameter param must be provider if task Switch in process definition."
"Parameter param or at least one local_param of task must "
"be provider if task Switch in process definition."
)
def
submit
(
self
)
->
int
:
...
...
dolphinscheduler-python/pydolphinscheduler/src/pydolphinscheduler/tasks/switch.py
浏览文件 @
a2cd2a99
...
...
@@ -129,7 +129,11 @@ class SwitchCondition(Base):
class
Switch
(
Task
):
"""Task switch object, declare behavior for switch task to dolphinscheduler."""
"""Task switch object, declare behavior for switch task to dolphinscheduler.
Param of process definition or at least one local param of task must be set
if task `switch` in this workflow.
"""
def
__init__
(
self
,
name
:
str
,
condition
:
SwitchCondition
,
*
args
,
**
kwargs
):
super
().
__init__
(
name
,
TaskType
.
SWITCH
,
*
args
,
**
kwargs
)
...
...
dolphinscheduler-python/pydolphinscheduler/tests/core/test_process_definition.py
浏览文件 @
a2cd2a99
...
...
@@ -240,11 +240,38 @@ def test__pre_submit_check_switch_without_param(mock_code_version):
parent
>>
switch
with
pytest
.
raises
(
PyDSParamException
,
match
=
"Parameter param must be provider if task Switch in process definition."
,
match
=
"Parameter param or at least one local_param of task must "
"be provider if task Switch in process definition."
,
):
pd
.
_pre_submit_check
()
@
patch
(
"pydolphinscheduler.core.task.Task.gen_code_and_version"
,
return_value
=
(
123
,
1
),
)
def
test__pre_submit_check_switch_with_local_params
(
mock_code_version
):
"""Test :func:`_pre_submit_check` if process definition with switch with local params of task."""
with
ProcessDefinition
(
TEST_PROCESS_DEFINITION_NAME
)
as
pd
:
parent
=
Task
(
name
=
"parent"
,
task_type
=
TEST_TASK_TYPE
,
local_params
=
[
{
"prop"
:
"var"
,
"direct"
:
"OUT"
,
"type"
:
"VARCHAR"
,
"value"
:
""
}
],
)
switch_child_1
=
Task
(
name
=
"switch_child_1"
,
task_type
=
TEST_TASK_TYPE
)
switch_child_2
=
Task
(
name
=
"switch_child_2"
,
task_type
=
TEST_TASK_TYPE
)
switch_condition
=
SwitchCondition
(
Branch
(
condition
=
"${var} > 1"
,
task
=
switch_child_1
),
Default
(
task
=
switch_child_2
),
)
switch
=
Switch
(
name
=
"switch"
,
condition
=
switch_condition
)
parent
>>
switch
pd
.
_pre_submit_check
()
def
test_process_definition_get_define_without_task
():
"""Test process definition function get_define without task."""
expect
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录