【问题标题】:How to parameterize Kubeflow Pipelines environment variables?如何参数化 Kubeflow Pipelines 环境变量?
【发布时间】:2021-09-08 08:03:14
【问题描述】:

我正在探索 Vertex AI Pipelines 以运行机器学习训练作业。 kubeflow pipeline docs 明确了如何参数化容器的命令/参数。

是否也可以将输入传递给环境变量或组件的图像名称?组件的 swagger schema 表明可以这样做,但此示例失败:

implementation:
  container:
    image: {concat: ["us.gcr.io/vcm-ml/emulator", {inputValue: tag}]
    # command is a list of strings (command-line arguments). 
    # The YAML language has two syntaxes for lists and you can use either of them. 
    # Here we use the "flow syntax" - comma-separated strings inside square brackets.
    command: [
      python3, 
      # Path of the program inside the container
      /pipelines/component/src/program.py,
      --input1-path,
      {inputPath: input_1},
      --param1, 
      --output1-path, 
    ]
    env:
      NAME: {inputValue: env}
inputs:
- {name: tag, type: String}
- {name: env, type: String}
- {name: input_1, type: String, description: 'Data for input_1'}

支持将{inputValue} 传递给container.envcontainer.tag。或者,是否可以使用 V2 python DSL 添加环境变量或更改图像名称。

【问题讨论】:

    标签: google-cloud-platform kubeflow-pipelines google-cloud-ai-platform-pipelines


    【解决方案1】:

    很抱歉给您带来了困惑。

    不幸的是,这里的 JsonSchema 是错误的(即它与 implementation 不同)。与image 相同。

    env 实现使用静态地图。 image 也是静态的。

    在 Kubeflow Pipelines (v1) 中,您可以在创建组件实例后将环境变量设置为动态值。但这可能不适用于 Vertex Pipelines。

    my_task = my_op(...)
    my_task.container.add_env_variable(V1EnvVar(name='MSG', value=task1.outputs["out1"]))
    

    如果这不起作用,您可以在 KFP 存储库中创建关于 env 支持的 GitHub 问题。

    对于图像,我们通常建议为不同的图像使用单独的组件文件。

    一种解决方法是设置变量的小型包装脚本:

    inputs:
    - {name: tag, type: String}
    - {name: env, type: String}
    - {name: input_1, type: String, description: 'Data for input_1'}
    implementation:
      container:
        image: "us.gcr.io/vcm-ml/emulator"
        command:
        - sh
        - -ec
        - 'NAME="$0" "$@"' # Set NAME to the first arg and execute the rest
        - {inputValue: env}
        - python3
          # Path of the program inside the container
        - /pipelines/component/src/program.py
        - --input1-path
        - {inputPath: input_1}
        - --param1 
        - --output1-path
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-27
      • 2016-10-15
      • 1970-01-01
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 2012-02-03
      • 1970-01-01
      相关资源
      最近更新 更多