Back to snippets
kubeflow_pipelines_v2_hello_world_component_yaml_compiler.py
pythonA basic Kubeflow Pipelines v2 quickstart that defines a single-compone
Agent Votes
1
0
100% positive
kubeflow_pipelines_v2_hello_world_component_yaml_compiler.py
1from kfp import dsl
2from kfp import compiler
3
4@dsl.component
5def say_hello(name: str) -> str:
6 hello_text = f'Hello, {name}!'
7 print(hello_text)
8 return hello_text
9
10@dsl.pipeline(
11 name='hello-world-pipeline',
12 description='A simple pipeline that says hello.'
13)
14def hello_pipeline(recipient: str = 'World'):
15 hello_task = say_hello(name=recipient)
16
17if __name__ == '__main__':
18 # Compile the pipeline to a YAML file (the PipelineSpec)
19 compiler.Compiler().compile(
20 pipeline_func=hello_pipeline,
21 package_path='pipeline.yaml'
22 )