Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 使用python的dsl.ContainerOp_Kubernetes_Kubeflow_Kubeflow Pipelines - Fatal编程技术网

Kubernetes 使用python的dsl.ContainerOp

Kubernetes 使用python的dsl.ContainerOp,kubernetes,kubeflow,kubeflow-pipelines,Kubernetes,Kubeflow,Kubeflow Pipelines,将.py文件下载到执行环境中有哪些选项 在本例中: class Preprocess(dsl.ContainerOp): def __init__(self, name, bucket, cutoff_year): super(Preprocess, self).__init__( name=name, # image needs to be a compile-time string image='gcr.io/<project>/

将.py文件下载到执行环境中有哪些选项

在本例中:

class Preprocess(dsl.ContainerOp):

  def __init__(self, name, bucket, cutoff_year):
    super(Preprocess, self).__init__(
      name=name,
      # image needs to be a compile-time string
      image='gcr.io/<project>/<image-name>/cpu:v1',
      command=['python3', 'run_preprocess.py'],
      arguments=[
        '--bucket', bucket,
        '--cutoff_year', cutoff_year,
        '--kfp'
      ],
      file_outputs={'blob-path': '/blob_path.txt'}
    )
类预处理(dsl.ContainerOp):
定义初始(自我、姓名、存储桶、截止年):
超级(预处理,自我).\u初始化__(
name=name,
#图像需要是编译时字符串
image='gcr.io///cpu:v1',
命令=['python3','run_preprocess.py'],
论据=[
“桶”,桶,
--截止年,截止年,
“--kfp”
],
文件_outputs={'blob-path':'/blob_path.txt'}
)
正在从CLI调用run_preprocess.py文件

问题是:如何将文件放在那里

我看到了这个有趣的例子:,它在运行管道之前克隆了代码

另一种方法是使用Dockerfile进行git克隆(尽管构建映像需要花费很长时间)


还有哪些选项?

要使用python启动KFP开发,请尝试以下教程:

它在运行管道之前克隆代码 另一种方法是使用Dockerfile进行git克隆(尽管构建映像需要花费很长时间)

理想情况下,文件应该位于容器映像内(Dockerfile方法)。这确保了最大的再现性

对于不太复杂的python脚本,轻量级python组件特性允许您从python函数创建组件。在这种情况下,脚本代码存储在组件命令行中,因此不需要将代码上传到任何地方

将脚本放在远程位置(如云存储或网站)是可能的,但会降低可靠性和再现性

附言

尽管这一形象需要很长时间才能建立起来

不应该。第一次它可能会很慢,因为必须拉基本图像,但在那之后它应该很快,因为只有新层被推。(这需要选择一个安装了所有依赖项的良好基础映像,以便Dockerfile只添加脚本)