From 12a4b012683d3129b2d279aed005e290aa0c3003 Mon Sep 17 00:00:00 2001 From: QuakeWang <45645138+QuakeWang@users.noreply.github.com> Date: Wed, 11 May 2022 11:43:11 +0800 Subject: [PATCH] [Doc] Add example and notice about task type Conditions (#9945) --- docs/docs/en/guide/task/conditions.md | 44 +++++++++++++---- docs/docs/zh/guide/task/conditions.md | 60 ++++++++++++++++------- docs/img/condition_dag_en.png | Bin 32856 -> 0 bytes docs/img/condition_task_en.png | Bin 26380 -> 0 bytes docs/img/condition_task_zh.png | Bin 25721 -> 0 bytes docs/img/tasks/demo/condition_task01.png | Bin 0 -> 121536 bytes docs/img/tasks/demo/condition_task02.png | Bin 0 -> 130398 bytes docs/img/tasks/demo/condition_task03.png | Bin 0 -> 128023 bytes 8 files changed, 76 insertions(+), 28 deletions(-) delete mode 100644 docs/img/condition_dag_en.png delete mode 100644 docs/img/condition_task_en.png delete mode 100644 docs/img/condition_task_zh.png create mode 100644 docs/img/tasks/demo/condition_task01.png create mode 100644 docs/img/tasks/demo/condition_task02.png create mode 100644 docs/img/tasks/demo/condition_task03.png diff --git a/docs/docs/en/guide/task/conditions.md b/docs/docs/en/guide/task/conditions.md index 6e404a9687..4bd8094648 100644 --- a/docs/docs/en/guide/task/conditions.md +++ b/docs/docs/en/guide/task/conditions.md @@ -4,15 +4,8 @@ Condition is a conditional node, that determines which downstream task should ru ## Create Task -Drag from the toolbar task node to canvas to create a new Conditions task, as shown in the figure below: - -
- -
- -- -
+- Click `Project -> Management-Project -> Name-Workflow Definition`, and click the "Create Workflow" button to enter the DAG editing page. +- Drag from the toolbar task node to canvas. ## Parameter @@ -24,7 +17,7 @@ Drag from the toolbar task node to c - Times of failed retry attempts: The number of times the task failed to resubmit. You can select from drop-down or fill-in a number. - Failed retry interval: The time interval for resubmitting the task after a failed task. You can select from drop-down or fill-in a number. - Timeout alarm: Check the timeout alarm and timeout failure. When the task runs exceed the "timeout", an alarm email will send and the task execution will fail. -- Downstream tasks selection: supports two branches success and failure. +- Downstream tasks selection: Depending on the status of the predecessor task, you can jump to the corresponding branch, currently two branches are supported: success, failure - Success: When the upstream task runs successfully, run the success branch. - Failure: When the upstream task runs failed, run the failure branch. - Upstream condition selection: can select one or more upstream tasks for conditions. @@ -34,3 +27,34 @@ Drag from the toolbar task node to c ## Related Task [switch](switch.md): Conditions task mainly executes the corresponding branch based on the execution status (success, failure) of the upstream nodes. The [Switch](switch.md) task node mainly executes the corresponding branch based on the value of the [global parameter](../parameter/global.md) and the result of user written expression. + +## Example + +This sample demonstrates the operation of the Condition task by using the [Shell](shell.md) task. + +### 1. Create workflow + +Go to the workflow definition page, and then create the following task nodes: + +- Node_A: Shell task, prints out "hello world", its main function is the upstream branch of Condition, and triggers the corresponding branch node according to whether its execution is successful or not. +- Condition: The Conditions task executes the corresponding branch according to the execution status of the upstream task. +- Node_Success: Shell task, print out "success", Node_A executes the successful branch. +- Node_False: Shell task, print out "false", Node_A executes the failed branch. + +![condition_task01](/img/tasks/demo/condition_task01.png) + +### 2. View the execution result + +After you finish creating the workflow, you can run the workflow online. You can view the execution status of each task on the workflow instance page. As shown below: + +![condition_task01](/img/tasks/demo/condition_task02.png) + +In the above figure, the task status marked with a green check mark is the successfully executed task node. + +## Notice + +- The Conditions task supports multiple upstream tasks, but only two downstream tasks. +- The Conditions task and the workflow that contain it do not support copy operations. +- The predecessor task of Conditions cannot connect to its branch nodes, which will cause logical confusion and does not conform to DAG scheduling. The situation shown below is **wrong**. + +![condition_task03](/img/tasks/demo/condition_task03.png) diff --git a/docs/docs/zh/guide/task/conditions.md b/docs/docs/zh/guide/task/conditions.md index 4988939a87..66f11fa3ed 100644 --- a/docs/docs/zh/guide/task/conditions.md +++ b/docs/docs/zh/guide/task/conditions.md @@ -1,36 +1,60 @@ -# Conditions +# Conditions 节点 -Conditions是一个条件节点,根据上游任务运行状态,判断应该运行哪个下游任务。截止目前Conditions支持多个上游任务,但只支持两个下游任务。当上游任务数超过一个时,可以通过`且`以及`或`操作符实现复杂上游依赖 +Conditions 是一个条件节点,根据上游任务运行状态,判断应该运行哪个下游任务。截止目前 Conditions 支持多个上游任务,但只支持两个下游任务。当上游任务数超过一个时,可以通过`且`以及`或`操作符实现复杂上游依赖 ## 创建任务 -拖动工具栏中的任务节点到画板中即能完成任务创建,如下图所示: - -- -
- -- -
+- 点击项目管理-项目名称-工作流定义,点击“创建工作流”按钮,进入 DAG 编辑页面; +- 拖动工具栏中的任务节点到画板中。 ## 任务参数 -- 节点名称:一个工作流定义中的节点名称是唯一的。 +- 节点名称:设置任务的名称,一个工作流定义中的节点名称是唯一的。 - 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。 - 描述信息:描述该节点的功能。 -- 任务优先级:worker线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。 -- Worker分组:任务分配给worker组的机器机执行,选择Default,会随机选择一台worker机执行。 +- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。 +- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。 - 失败重试次数:任务失败重新提交的次数,支持下拉和手填。 - 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。 - 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败. -- 下游任务选择:目前支持两个分支,成功、失败 +- 下游任务选择:根据前置任务的状态来跳转到对应的分支,目前支持两个分支:成功、失败 - 成功:当上游运行成功时,运行成功选择的分支 - 失败:当上游运行失败时,运行失败选择的分支 -- 上游条件选择:可以为conditions选择一个或多个上游任务 - - 增加上游依赖:通过选择第一个参数选择对应的任务名称,通过第二个参数选择触发的conditions任务的状态 +- 上游条件选择:可以为 Conditions 任务选择一个或多个上游任务 + - 增加上游依赖:通过选择第一个参数选择对应的任务名称,通过第二个参数选择触发的 Conditions 任务的状态 - 上游任务关系选择:当有多个上游任务时,可以通过`且`以及`或`操作符实现任务的复杂关系。 ## 相关任务 -[switch](switch.md):Condition节点主要依据上游节点的执行状态(成功、失败)执行对应分支。[Switch](switch.md)节点主要依据全局变量的值和用户所编写的表达式判断结果执行对应分支 \ No newline at end of file +[switch](switch.md):Condition节点主要依据上游节点的执行状态(成功、失败)执行对应分支。[Switch](switch.md)节点主要依据全局变量的值和用户所编写的表达式判断结果执行对应分支 + +## 任务样例 + +该样例通过使用 [Shell](shell.md) 任务来演示 Condition 任务的操作流程。 + +### 1、创建工作流 + +进入工作流定义页面,然后分别创建如下任务节点: + +- Node_A:Shell 任务,打印输出 ”hello world“,其主要作用是 Condition 的上游分支,根据其执行是否成功来触发对应的分支节点。 +- Condition:Conditions 任务,根据上游任务的执行状态,来执行对应的分支。 +- Node_Success:Shell 任务,打印输出 “success”,Node_A 执行成功的分支。 +- Node_False:Shell 任务,打印输出 ”false“,Node_A 执行失败的分支。 + +![condition_task01](/img/tasks/demo/condition_task01.png) + +### 2、查看执行结果 + +当完成创建工作流之后,可以上线运行该工作流。在工作流实例页面可以查看到各个任务的执行状态。如下图所示: + +![condition_task01](/img/tasks/demo/condition_task02.png) + +上图中,任务状态标记为绿色对号的,即为成功执行的任务节点。 + +## 注意事项 + +- Conditions 任务支持多个上游任务,但只支持两个下游任务。 +- Conditions 任务以及包含该任务的工作流不支持复制操作。 +- Conditions 的前置任务不能连接其分支节点,会造成逻辑混乱,不符合 DAG 调度。如下图所示的情况是**错误**的。 + +![condition_task03](/img/tasks/demo/condition_task03.png) diff --git a/docs/img/condition_dag_en.png b/docs/img/condition_dag_en.png deleted file mode 100644 index 9e7c43be90bff3df884df919b6b2eb24ed52a9e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32856 zcmag_byOTr7r%=R8Ui7>y9C!@!7aEa1a}A!oZ!yju0eth?(R0Y26rDkxXYk($oD|noOXyNv*XL@*eks8JQPF5wcEYeuKaaz#
zb5eXGa;SA?T7LKKjL2n{DD&dv4_&)V-DX_yuVX*t#il>VuAQ(I$f+Rs8)pK;WiiqA
zH$TQ=VjiWQYLm}J6Sfr$Y#I8KdKH 3GM8TO4C~SGU9p7;0_#P6A_f@j#(o02yBf4;Z?`OAs
zpD%wyo+=f_(8n%}S#^E(yY^OCXC3@OvgyqKX_t8qQ#>fyzY{Ela%uC;dKyxG-Qu2^
zsub{q_z`|-P!3C$=E%c}Nn2iFu9%Q0;5czOF*Hdei7DQK|AQUkj$595iI2!