| Previous usage | New usage |
|---|---|
| ```python from kfp.components import create_component_from_func from kfp.components import func_to_container_op @create_component_from_func def component1(...): ... def component2(...): ... component2 = create_component_from_func(component2) @func_to_container_op def component3(...): ... @dsl.pipeline(name='my-pipeline') def pipeline(): component1(...) component2(...) component3(...) ``` | ```python from kfp import dsl @dsl.component def component1(...): ... @dsl.component def component2(...): ... @dsl.component def component3(...): ... @dsl.pipeline(name='my-pipeline') def pipeline(): component1(...) component2(...) component3(...) ``` |
| Previous usage | New usage |
|---|---|
| ```python def my_pipeline(): trainer_component(100, 0.1) ``` | ```python def my_pipeline(): trainer_component(epochs=100, learning_rate=0.1) ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp import dsl # v1 ContainerOp will not be supported. component_op = dsl.ContainerOp(...) # v1 ContainerOp from class will not be supported. class FlipCoinOp(dsl.ContainerOp): ``` | ```python from kfp import dsl @dsl.container_component def flip_coin(rand: int, result: dsl.OutputPath(str)): return ContainerSpec( image='gcr.io/flip-image' command=['flip'], arguments=['--seed', rand, '--result-file', result]) ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp.v2.google.client import AIPlatformClient api_client = AIPlatformClient( project_id=PROJECT_ID, region=REGION, ) response = api_client.create_run_from_job_spec( job_spec_path=PACKAGE_PATH, pipeline_root=PIPELINE_ROOT, ) ``` | ```python # pip install google-cloud-aiplatform from google.cloud import aiplatform aiplatform.init( project=PROJECT_ID, location=REGION, ) job = aiplatform.PipelineJob( display_name=DISPLAY_NAME, template_path=PACKAGE_PATH, pipeline_root=PIPELINE_ROOT, ) job.submit() ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp import components from kfp.v2 import dsl from kfp.v2.google.experimental import run_as_aiplatform_custom_job training_op = components.load_component_from_url(...) @dsl.pipeline(name='my-pipeline') def pipeline(): training_task = training_op(...) run_as_aiplatform_custom_job( training_task, ...) ``` | ```python # pip install google-cloud-pipeline-components from kfp import components from kfp import dsl from google_cloud_pipeline_components.v1.custom_job import utils training_op = components.load_component_from_url(...) @dsl.pipeline(name='my-pipeline') def pipeline(): utils.create_custom_training_job_from_component(training_op, ...) ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp.v2 import dsl from kfp.v2 import compiler @dsl.pipeline(name='my-pipeline') def pipeline(): ... compiler.Compiler().compile(...) ``` | ```python from kfp import dsl from kfp import compiler @dsl.pipeline(name='my-pipeline') def pipeline(): ... compiler.Compiler().compile(...) ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp.v2.dsl import component @component(output_component_file='my_component.yaml') def my_component(input: str): ... ``` | ```python from kfp.dsl import component from kfp import compiler @component() def my_component(input: str): ... compiler.Compiler().compile(my_component, 'my_component.yaml') ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp.v2 import compiler # .json extension, deprecated format compiler.Compiler().compile(pipeline, package_path='my_pipeline.json') ``` | ```python from kfp import compiler # .yaml extension, preferred format compiler.Compiler().compile(pipeline, package_path='my_pipeline.yaml') ``` |
| Previous usage | New usage |
|---|---|
| ```python from kfp.components import importer_node ``` | ```python from kfp.dsl import importer_node ``` |
| Previous usage | New usage |
|---|---|
| ```python @dsl.pipeline def my_pipeline(): task.add_node_selector_constraint( label_name='cloud.google.com/gke-accelerator', value='NVIDIA_TESLA_A100', ) ``` | ```python @dsl.pipeline def my_pipeline(): task.set_accelerator_type(accelerator="NVIDIA_TESLA_K80") ``` |