【发布时间】:2020-01-28 17:08:05
【问题描述】:
我正在探索将 Kubeflow 作为部署和连接典型 ML 管道的各种组件的选项。我正在使用 docker 容器作为 Kubeflow 组件,到目前为止,我一直无法成功使用 ContainerOp.file_outputs 对象在组件之间传递结果。
根据我对该功能的理解,创建并保存到声明为组件的 file_outputs 之一的文件应该会导致它持久存在并可供以下组件读取。
这就是我尝试在我的管道 python 代码中声明它的方式:
import kfp.dsl as dsl
import kfp.gcp as gcp
@dsl.pipeline(name='kubeflow demo')
def pipeline(project_id='kubeflow-demo-254012'):
data_collector = dsl.ContainerOp(
name='data collector',
image='eu.gcr.io/kubeflow-demo-254012/data-collector',
arguments=[ "--project_id", project_id ],
file_outputs={ "output": '/output.txt' }
)
data_preprocessor = dsl.ContainerOp(
name='data preprocessor',
image='eu.gcr.io/kubeflow-demo-254012/data-preprocessor',
arguments=[ "--project_id", project_id ]
)
data_preprocessor.after(data_collector)
#TODO: add other components
if __name__ == '__main__':
import kfp.compiler as compiler
compiler.Compiler().compile(pipeline, __file__ + '.tar.gz')
在data-collector.py 组件的python 代码中,我获取数据集,然后将其写入output.txt。我可以从同一组件内的文件中读取,但不能在 data-preprocessor.py 内读取,而我得到 FileNotFoundError。
file_outputs 的使用对于基于容器的 Kubeflow 组件是否无效,还是我在代码中错误地使用了它?如果在我的情况下不是一个选项,是否可以在管道声明 python 代码中以编程方式创建 Kubernetes 卷并使用它们而不是 file_outputs?
【问题讨论】:
标签: kubeflow kubeflow-pipelines