Google Cloud Pipeline Components
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
- breaking This library is designed for Kubeflow Pipelines (KFP) v2 syntax. If migrating from KFP v1, component definition and pipeline construction syntax will be significantly different. KFP v1's `kfp.components.load_component_from_url` or direct YAML loading is generally incompatible with GCPC's object-oriented component instantiation.
- gotcha Proper Google Cloud IAM permissions are critical. The service account used to run the pipeline on Vertex AI (or your user credentials for local development) must have sufficient roles, such as 'Vertex AI User', 'Storage Admin' (for artifact storage), and specific permissions for any underlying GCP services your components interact with (e.g., BigQuery User, Dataflow Admin).
- gotcha Most Vertex AI services are regional. Ensure that the `project` and `location` parameters passed to GCPC components (e.g., `CustomJobOp`, `BatchPredictionJobOp`) are consistent with the region where your resources exist or where you intend to run the job. Mismatched regions can lead to resource not found errors or increased latency.
Install
-
pip install google-cloud-pipeline-components
Imports
- aiplatform
from google_cloud_pipeline_components import aiplatform
- CustomJobOp
from google_cloud_pipeline_components.v1.custom_job import CustomJobOp
- BigQueryQueryJobOp
from google_cloud_pipeline_components.v1.bigquery import BigQueryQueryJobOp
Quickstart
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.