Google Cloud Pipeline Components

2.22.0 · active · verified Sat Apr 11

This Python SDK provides a set of first-party (Google owned) pipeline components that enable users to build MLOps pipelines on Vertex AI using Kubeflow Pipelines (KFP) SDK. It integrates seamlessly with Vertex AI SDK and other Google Cloud services. The current version is 2.22.0, and releases are frequent, often aligned with KFP SDK updates.

Warnings

Install

Imports

Quickstart

This quickstart defines a simple KFP pipeline using a `CustomJobOp` from `google-cloud-pipeline-components`. This component allows you to run arbitrary containerized code on Vertex AI. Remember to replace placeholder `GCP_PROJECT_ID` and `GCP_REGION` with your actual Google Cloud project and desired region, ideally using environment variables or a configuration.

import kfp
from kfp import dsl
import os

# Import a Google Cloud Pipeline Component (GCPC)
from google_cloud_pipeline_components.v1.custom_job import CustomJobOp

@dsl.pipeline(name='gcp-quickstart-pipeline', description='A simple pipeline using GCPC')
def my_gcp_pipeline():
    # Define a CustomJobOp from google-cloud-pipeline-components
    # This component launches a custom container on Vertex AI
    custom_task = CustomJobOp(
        project=os.environ.get('GCP_PROJECT_ID', 'your-gcp-project-id'),
        location=os.environ.get('GCP_REGION', 'us-central1'),
        display_name='my-first-gcp-custom-job',
        container_uri='gcr.io/cloud-aiplatform/training/tf-gpu.2-8:latest',
        command=['sh', '-c', 'echo "Hello from GCPC!"'],
        replica_count=1,
        machine_type='n1-standard-4'
    )

# To run this pipeline, you would typically compile it:
# kfp.compiler.Compiler().compile(my_gcp_pipeline, 'pipeline.json')
# And then upload and run it on Vertex AI Pipelines.

view raw JSON →