如何使用专用于GCP的TFX SDK实施Kubeflow“运行参数”?

问题描述

我目前正在使用Kubeflow作为协调器。协调器实际上是GCP上托管的AI平台管道的实例。如何使用Tensorflow Extended SDK创建运行时参数?我怀疑这是我应该使用的类,但是文档不是很有意义,也没有提供任何示例。 https://www.tensorflow.org/tfx/api_docs/python/tfx/orchestration/data_types/RuntimeParameter

类似下面的图片。

enter image description here

解决方法

例如,您要添加模块文件位置作为运行时参数,该参数将传递到TFX管道中的转换组件。

首先设置setup_pipeline.py并定义模块文件参数:

# setup_pipeline.py

from typing import Text
from tfx.orchestration import data_types,pipeline
from tfx.orchestration.kubeflow import kubeflow_dag_runner
from tfx.components import Transform

_module_file_param = data_types.RuntimeParameter(
    name='module-file',default=
    '/tfx-src/tfx/examples/iris/iris_utils_native_keras.py',ptype=Text,)

接下来,定义一个函数,该函数指定管道中使用的组件并传递参数。

def create_pipeline(...,module_file):
    # setup components:
    ...

    transform = Transform(
         ...
         module_file=module_file
      )
     ...

    components = [...,transform,...]

    return pipeline.Pipeline(
          ...,components=components
    )

最后,设置Kubeflow DAG运行器,以便它将参数传递到create_pipeline函数。有关更完整的示例,请参见here

if __name__ == "__main__":

    # instantiate a kfp_runner
    ...

    kfp_runner = kubeflow_dag_runner.KubeflowDagRunner(
        ...
    )

    kfp_runner.run(
        create_pipeline(...,module_file=_module_file_param
      ))

然后,您可以运行python -m setup_pipeline,这将生成指定管道配置的yaml文件,然后您可以将其上传到Kubeflow GCP界面。

相关问答

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