如何在Argo工作流DAG中将一个节点的输出作为输入参数传递给另一个节点

时间:2020-01-17 19:13:27

标签: machine-learning workflow argoproj argo-workflows

我正在尝试使用Argo构建ML管道DAG。我遇到了一个问题,我需要将DAG中一个节点的值作为参数发送到其后续节点。说ARGO DAG结构如下:

{
  "apiVersion": "argoproj.io/v1alpha1",
  "kind": "Workflow",
  "metadata": {
    "generateName": "workflow01-"
  },
  "spec": {
    "entrypoint": "workflow01",
    "arguments": {
      "parameters": [
        {
          "name": "log-level",
          "value": "INFO"
        }
      ]
    },
    "templates": [
      {
        "name": "workflow01",
        "dag": {
          "tasks": [
            {
              "name": "A",
              "template": "task-container",
              "arguments": {
                "parameters": [
                  {
                    "name": "model-type",
                    "value": "INTENT-TRAIN"
                  }
                ]
              }
            },
            {
              "name": "B",
              "template": "task-container",
              "dependencies": ["A"],
              "arguments": {
                "parameters": [
                  {
                    "name": "model-type",
                    "value": "INTENT-EVALUATE"
                  }
                ]
              }
            }
          ]
        }
      },
      {
        "name": "task-container",
        "inputs": {
          "parameters": [
            {
              "name": "model-type",
              "value": "NIL"
            }
          ]
        },
        "container": {
          "env": [
            {
              "name": "LOG_LEVEL",
              "value": "{{workflow.parameters.log-level}}"
            },
            {
              "name": "MODEL_TYPE",
              "value": "{{inputs.parameters.model-type}}"
            }
          ]
        }
      }
    ]
  }
}

A -> B

B中发生的计算取决于A中已计算的值。

如何将A中计算出的值传递给B?

1 个答案:

答案 0 :(得分:1)

您可以为此使用Argo的“工件”-参见https://github.com/argoproj/argo/tree/master/examples#artifacts上的示例

另一种方法是设置共享卷:https://github.com/argoproj/argo/tree/master/examples#volumes