kubeflow pipelineのサンプルコード
41
import kfp
from kfp import compiler, dsl, components
def _preprocess(n: int) -> str:
return f"preprocess {n}"
def _process(nums: str) -> int:
return 1
@kfp.dsl.pipeline(name="parallel-pipeline")
def pipeline(n: int) -> None:
image = "python:3.8-alpine"
preprocess_func = components.func_to_container_op(_preprocess,
base_image=image)
preprocess_op = preprocess_func(n)
process_func = components.func_to_container_op(_process,
base_image=image)
process_op = process_func(preprocess_op.output)
# preprocessの後にprocess
process_op.after(preprocess_op)
return process_op.output