Using the Kubeflow Pipelines SDK
This guide provides examples that demonstrate how to use the Kubeflow Pipelines SDK.
Before you start
To follow the examples in this guide, you must have Kubeflow Pipelines SDK version 0.2.5 or higher installed. Use the following instructions to install the Kubeflow Pipelines SDK and check the SDK version.
- Install the Kubeflow Pipelines SDK
Run the following command to check the version of the SDK
pip list | grep kfp
The response should be something like this:
kfp 0.2.5 kfp-server-api 0.2.5
Use the following examples to learn more about the Kubeflow Pipelines SDK.
Creating a pipeline and a pipeline version using the SDK
The following example demonstrates how to use the Kubeflow Pipelines SDK to create a pipeline and a pipeline version.
In this example, you:
kfp.Clientto create a pipeline from a local file. When the pipeline is created, a default pipeline version is automatically created.
kfp.Clientto add a pipeline version to the pipeline that was created in the previous step.
import kfp import os host = <host> pipeline_file_path = <path to pipeline file> pipeline_name = <pipeline name> pipeline_version_file_path = <path to pipeline version file> pipeline_version_name = <pipeline version name> client = kfp.Client(host) pipeline_file = os.path.join(pipeline_file_path) pipeline = client.pipeline_uploads.upload_pipeline(pipeline_file, name=pipeline_name) pipeline_version_file = os.path.join(pipeline_version_file_path) pipeline_version = client.pipeline_uploads.upload_pipeline_version(pipeline_version_file, name=pipeline_version_name, pipelineid=pipeline.id)
- host: Your Kubeflow Pipelines cluster’s host name.
- path to pipeline file: The path to the directory where your pipeline YAML is stored.
- pipeline name: Your pipeline’s file name.
- path to pipeline version file: The path to the directory where the new version of your pipeline YAML is stored.
- pipeline version name: Your pipeline version’s file name.
Note: Pipeline names need to be unique across your Kubeflow Pipelines cluster. Pipeline version names need to be unique within each pipeline.
Adding a version to an existing pipeline using the SDK
To add a pipeline version for an existing pipeline, you must find the
pipeline’s ID and use it with the
upload_pipeline_version method. To
find a pipeline’s ID:
- Open the Kubeflow Pipelines UI. A list of your pipelines appears.
- Click the name of your pipeline. The pipeline details page appears.
- The pipeline ID is listed in the summary card, as shown below.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.