[英]How do i get the output from a custom container and pass to next pipeline in Vertex AI/Kubeflow pipeline?
我很难理解如何将容器中的结果作为 output 工件传递。 我知道我们需要将 output 写入文件,但我需要一些示例如何执行此操作。
https://www.kubeflow.org/docs/components/pipelines/sdk-v2/component-development/
这是 python 容器程序的最后一部分,我将 GCS 上的output.txt
url
。
with open('./output.txt', 'w') as f:
logging.info(f"Model path url is in {'./output.txt'}")
f.write(model_path)
这是组件.yaml
文件
name: Dummy Model Training
description: Train a dummy model and save to GCS
inputs:
- name: input_url
description: 'Input csv url.'
type: String
- name: gcs_url
description: 'GCS bucket url.'
type: String
outputs:
- name: gcs_model_path
description: 'Trained model path.'
type: String
implementation:
container:
image: ${CONTAINER_REGISTRY}
command: [
python, ./app/trainer.py,
--input_url, {inputValue: input_url},
--gcs_url, {inputValue: gcs_url},
]
首先,您的虚拟组件缺少对 output 的引用。您需要使用{outputPath: <output_name>}
或{outputUri: <output_name>}
将其传递到容器中,以便您的容器代码可以将数据写入此系统生成的路径或 URI(“gs://...”)。 要修复您的组件 yaml,它可以是:
name: Dummy Model Training
description: Train a dummy model and save to GCS
inputs:
- name: input_url
description: 'Input csv url.'
type: String
- name: gcs_url
description: 'GCS bucket url.'
type: String
outputs:
- name: gcs_model_path
description: 'Trained model path.'
type: String
implementation:
container:
image: ${CONTAINER_REGISTRY}
command: [
python, ./app/trainer.py,
--input_url, {inputValue: input_url},
--gcs_url, {inputValue: gcs_url},
--output_model_path, {outputPath: gcs_model_path}
]
然后你的代码应该写入这个传入的路径,而不是'./output.txt'
关于如何在下游组件中消费output。 这是一个简单但可运行的示例,您可以在 Vertex Pipelines 上试用它: https://github.com/kubeflow/pipelines/blob/bf2389a66c164457b0e10a820ba484992fd7dd1a/sdk/python/test_data/pipelines/two_step_pipeline.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.