You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2022/05/25 13:53:47 UTC

[dolphinscheduler] branch dev updated: [doc] Add setValue syntax in local param (#10245)

This is an automated email from the ASF dual-hosted git repository.

zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 6d9bc0743b [doc] Add setValue syntax in local param (#10245)
6d9bc0743b is described below

commit 6d9bc0743b5839b5621dbf92b8ddccb900d4ed7f
Author: Jiajie Zhong <zh...@hotmail.com>
AuthorDate: Wed May 25 21:53:41 2022 +0800

    [doc] Add setValue syntax in local param (#10245)
    
    ref: #9576
    same as: #9671
---
 docs/docs/en/guide/parameter/local.md              |  49 +++++++++++++++++++++
 docs/docs/zh/guide/parameter/local.md              |  46 +++++++++++++++++++
 .../new_ui/dev/parameter/local_param_set_val.png   | Bin 0 -> 22422 bytes
 .../dev/parameter/local_param_set_val_bash.png     | Bin 0 -> 33232 bytes
 .../dev/parameter/local_param_set_val_custom.png   | Bin 0 -> 50476 bytes
 5 files changed, 95 insertions(+)

diff --git a/docs/docs/en/guide/parameter/local.md b/docs/docs/en/guide/parameter/local.md
index 3ba290bb36..cc2b7ff417 100644
--- a/docs/docs/en/guide/parameter/local.md
+++ b/docs/docs/en/guide/parameter/local.md
@@ -6,10 +6,18 @@ Parameters configured on the task definition page, the scope of this parameter i
 
 ## Usage
 
+* If you want to use parameter in single task, see [local parameter with custom parameter](#use-local-parameter-by-custom-parameter)
+* If you want to use set parameter in task and use them in downstream tasks:
+  * For simple use without using custom parameter, see [export parameter via `setValue`](#export-local-parameter-by-setvalue)
+  * Using custom parameter, see [export parameter via `setValue` and custom parameter](#export-local-parameter-by-setvalue-and-custom-parameter)
+  * Using bash variable, see [export parameter via `setValue` and bash variable](#export-local-parameter-by-setvalue-and-bash-variable)
+
 Usage of local parameters is: at the task define page, click the '+' beside the 'Custom Parameters' and fill in the key and value to save.
 
 ## Examples
 
+### Use Local Parameter by Custom Parameter
+
 This example shows how to use local parameters to print the current date. Create a Shell task and write a script with the content `echo ${dt}`. Click **custom parameter** in the configuration bar, and the configuration is as follows:
 
 ![local-parameter01](/img/new_ui/dev/parameter/local_parameter01.png)
@@ -26,3 +34,44 @@ Save the workflow and run it. View Shell task's log.
 ![local-parameter02](/img/new_ui/dev/parameter/local_parameter02.png)
 
 > Note: The local parameter can be used in the workflow of the current task node. If it is set to OUT, it can be passed to the downstream workflow. Please refer to: [Parameter Context](context.md)
+
+### Export Local Parameter by `setValue`
+
+If you want to simple export parameters and then use them in downstream tasks, you could use `setValue` in your task, which
+you can manage your parameters into one single task. You can use syntax `echo '${setValue(set_val=123)}'`(**do not forget the
+single quote**) in Shell task and add new `OUT` custom parameter to export it.
+
+![local-parameter-set-val](/img/new_ui/dev/parameter/local_param_set_val.png)
+
+You could get this value in downstream task using syntax `echo '${set_val}'`.
+
+### Export Local Parameter by `setValue` and Custom Parameter
+
+If you want to export parameters with custom parameter instead of constants value, and then use them in downstream tasks,
+you could use `setValue` in your task, which easier to maintain by change "custom parameter" block when you want to
+change its value. You can use syntax `echo "#{setValue(set_val_param=${val})}"`(**do not forget the double quote, if you are
+using any variable with `setValue`**) in Shell task and add new `IN` custom parameter for input variable `val` and `OUT` custom
+parameter for exporting parameter `set_val_param`.
+
+![local-parameter-set-val-param](/img/new_ui/dev/parameter/local_param_set_val_custom.png)
+
+You could get this value in downstream task using syntax `echo '${set_val_param}'`.
+
+### Export Local Parameter by `setValue` and Bash Variable
+
+If you want to export parameters with bash variable instead of constants value, and then use them in downstream tasks,
+you could use `setValue` in your task, which more flexible such as you can get variable for exists local or HTTP resource.
+You can use syntax like 
+
+```shell
+lines_num=$(wget https://raw.githubusercontent.com/apache/dolphinscheduler/dev/README.md -q -O - | wc -l | xargs)
+echo "#{setValue(set_val_var=${lines_num})}"
+```
+
+in Shell task(**do not forget the double quote, if you are using any variable with `setValue`**) and add `OUT` custom parameter
+for exporting parameter `set_val_var`
+.
+
+![local-parameter-set-val-bash](/img/new_ui/dev/parameter/local_param_set_val_bash.png)
+
+You could get this value in downstream task using syntax `echo '${set_val_var}'`.
diff --git a/docs/docs/zh/guide/parameter/local.md b/docs/docs/zh/guide/parameter/local.md
index b92c593ecf..6cddf35fa1 100644
--- a/docs/docs/zh/guide/parameter/local.md
+++ b/docs/docs/zh/guide/parameter/local.md
@@ -8,8 +8,16 @@
 
 本地参数配置方式如下:在任务定义页面,点击“自定义参数”右边的加号,填写对应的变量名称和对应的值,保存即可。
 
+* 如果要在单个任务中使用参数,请参阅通过自定义参数使用
+* 如果要在任务中使用配置参数并在下游任务中使用它们:
+  * 如果你只是想要简单使用,且不使用自定义参数, 请参阅 通过 `setValue` 和自定义参数 export 本地参数
+  * 如果想要使用自定义参数, 请参阅 通过 `setValue` 和自定义参数 export 本地参数
+  * 如果想要使用 Bash 参数, 请参阅 通过 `setValue` 和 Bash 环境变量参数 export 本地参数
+
 ## 任务样例
 
+### 通过自定义参数使用
+
 本样例展示了如何使用本地参数,打印输出当前日期。创建一个 Shell 任务,并编写脚本内容为 `echo ${dt}`。点击配置栏中的**自定义参数**,配置如下图所示:
 
 ![local-parameter01](/img/new_ui/dev/parameter/local_parameter01.png)
@@ -26,3 +34,41 @@
 ![local-parameter02](/img/new_ui/dev/parameter/local_parameter02.png)
 
 > 注:本地参数可以在当前任务节点的工作流中,设置其为 OUT 则可以传递给下游的工作流使用,可以参考:[参数传递](context.md)
+
+### 通过 `setValue` export 本地参数
+
+如果你想简单 export 参数然后在下游任务中使用它们,你可以在你的任务中使用 `setValue`,你可以将参数统一在一个任务中管理。在 Shell 任务中使用语法
+`echo '${setValue(set_val=123)}'`(**不要忘记单引号**) 并添加新的 `OUT` 自定义参数来 export 它。
+
+![local-parameter-set-val](/img/new_ui/dev/parameter/local_param_set_val.png)
+
+你可以在下游任务中使用语法 `echo '${set_val}'` 在获取设定的值。
+
+### 通过 `setValue` 和自定义参数 export 本地参数
+
+如果你想用自定义参数而不是常量值来实现参数 export,并下游任务中使用它们,你可以在通过 `setValue` 和 自定义参数实现,当你想改变参数的值时可以直接改变
+“自定义参数”模块中的值,这让程序更加容易维护。您可以在 Shell 任务中使用语法 `echo "#{setValue(set_val_param=${val})}"`(**如果你想要将任何
+变量赋值给 `setValue`** 请不要忘记使用双引号)并添加新的 `IN` 自定义参数用于输入变量 `val` 和 `OUT` 自定义参数用于 export 参数 `set_val_param`。
+
+![local-parameter-set-val-param](/img/new_ui/dev/parameter/local_param_set_val_custom.png)
+
+你可以在下游任务中使用语法 `echo '${set_val_param}'` 在获取设定的值。
+
+### 通过 `setValue` 和 Bash 环境变量参数 export 本地参数
+
+If you want to export parameters with bash variable instead of constants value, and then use them in downstream tasks, you could use `setValue` in your task, which more flexible such as you can get variable for exists local or HTTP resource. You can use syntax like
+
+如果你想用 bash 变量而不是常量值 export 参数,并在下游任务中使用它们,你可以在通过 `setValue` 和 Bash 变量实现,它更灵活,例如你动态获取现有的本地
+或 HTTP 资源获取设定变量。 您可以使用类似的语法
+
+```shell
+lines_num=$(wget https://raw.githubusercontent.com/apache/dolphinscheduler/dev/README.md -q -O - | wc -l | xargs)
+echo "#{setValue(set_val_var=${lines_num})}"
+```
+
+在 Shell 任务中(**如果你想要将任何变量赋值给 `setValue`** 请不要忘记使用双引号)和 `OUT` 自定义参数用于 export 参数 `set_val_var`。
+.
+
+![local-parameter-set-val-bash](/img/new_ui/dev/parameter/local_param_set_val_bash.png)
+
+你可以在下游任务中使用语法 `echo '${set_val_var}'` 在获取设定的值。
diff --git a/docs/img/new_ui/dev/parameter/local_param_set_val.png b/docs/img/new_ui/dev/parameter/local_param_set_val.png
new file mode 100644
index 0000000000..c44e63e297
Binary files /dev/null and b/docs/img/new_ui/dev/parameter/local_param_set_val.png differ
diff --git a/docs/img/new_ui/dev/parameter/local_param_set_val_bash.png b/docs/img/new_ui/dev/parameter/local_param_set_val_bash.png
new file mode 100644
index 0000000000..7c0f17976b
Binary files /dev/null and b/docs/img/new_ui/dev/parameter/local_param_set_val_bash.png differ
diff --git a/docs/img/new_ui/dev/parameter/local_param_set_val_custom.png b/docs/img/new_ui/dev/parameter/local_param_set_val_custom.png
new file mode 100644
index 0000000000..cdfa557b47
Binary files /dev/null and b/docs/img/new_ui/dev/parameter/local_param_set_val_custom.png differ