如何引用在 DAG 外部创建的 sys.stdout 以在 DAG 内部使用 withParam?

问题描述

我正在使用 Argo 工作流程。

我的 entrypoint 中有一个 DAG 步骤,它遵循几个正常步骤。这些步骤之一执行 sys.stdout。进入 DAG 步骤后,我希望一些任务引用 sys.stdout 的结果。

我知道如果我们想在工作流从一个步骤进入下一个步骤(没有 DAG)时引用 sys.stdout,我们可以执行 {{steps.step-name.outputs.result}}。但是,这在 DAG 任务中不起作用。

如何在 DAG 任务中引用 sys.stdout 以便将其与 withParam 一起使用?

编辑:

工作流程如下所示:

  templates:
  - name: the-entrypoint
    steps:
    - - name: step01
        template: first-step
    - - name: step02
        template: second-step
    - - name: step03
        template: third-step
    - - name: step04-the-dag-step
        template: fourth-step

一般来说,如果third-step做了一个sys.stdout,我们可以通过{{steps.step03.outputs.result}}中的fourth-step来引用它。但是,在这种情况下,fourth-step 是一个 DAG,如果 DAG 任务之一想要使用 sys.stdout,则在 DAG 任务中调用 {{steps.step03.outputs.result}} 作为参数/参数会引发错误.

问题是如何在 sys.stdout DAG 任务中正确引用 third-step 生成的 fourth-step

解决方法

关于模板输出的一些背景

Argo Workflows 支持多种不同的 types of templates

每种类型的模板支持不同类型的引用模板内

private void loadFromDatabase_Click(object sender,RoutedEventArgs e) { LoadFromDatabase(SqliteDataAccess.LoadDatabase("Words")); } private void LoadFromDatabase(List<IWordModel> words) { WordsListBox.ItemsSource = null; //WordsListBox.ItemsSource = DataAccess.LoadDatabase(); WordsListBox.ItemsSource = words; WordsListBox.DisplayMemberPath = "WordPair"; } 模板中,您可以使用 var output = conn.Query<IWordModel>($"Select * from {table}",new DynamicParameters()); (用于命名参数)或 steps(用于标准输出)访问其他步骤的输出参数steps.step-name.outputs.parameters.param-namesteps.step-name.outputs.result 模板)。

示例 (see full Workflow):

script

container 模板中,您可以使用类似的语法访问各种任务的输出,只需使用 - name: output-parameter steps: - - name: generate-parameter template: whalesay - - name: consume-parameter template: print-message arguments: parameters: - name: message value: "{{steps.generate-parameter.outputs.parameters.hello-param}}" 而不是 dag

示例 (see full Workflow):

tasks.

steps. - name: main dag: tasks: - name: flip-coin template: flip-coin - name: heads depends: flip-coin template: heads when: "{{tasks.flip-coin.outputs.result}} == heads" - name: tails depends: flip-coin template: tails when: "{{tasks.flip-coin.outputs.result}} == tails" 模板中,您只能访问该模板的输入*。您不能从容器或脚本模板的步骤或任务模板直接访问步骤或任务的输出。

从 DAG 引用步骤输出

如上所述,DAG 模板不能直接引用 container 模板的步骤输出。但是 script 模板中的步骤可以将步骤输出传递给 DAG 模板

在您的示例中,它看起来像这样:

steps

tl;博士

steps templates: - name: the-entrypoint steps: - - name: step01 template: first-step - - name: step02 template: second-step - - name: step03 template: third-step - - name: step04-the-dag-step template: fourth-step arguments: parameters: - name: some-param value: "{{steps.step03.outputs.result}}" - name: fourth-step inputs: parameters: - name: some-param dag: tasks: # use the input parameter in the fourth-step template with "{{inputs.parameters.some-param}}" 变量旨在在单个步骤或任务模板中引用,但它们可以在模板之间显式传递 em>。如果您需要使用 DAG 中某个步骤的输出,请直接将该输出作为调用 DAG 的参数传递。

在您的情况下,DAG 模板作为四个步骤中的最后一步被调用,因此您将在此处传递参数。

* 好的,您还可以从 steps.tasks. 模板中访问 various other variables,但您无权访问范围为内部变量的变量在另一个模板中。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...