Custom Labels in Vertex AI Pipeline PipelineJobSchedule

256 views Asked by At

I would like to know the steps involved in adding custom labels to a Vertex AI pipeline’s PipelineJobSchedule. Can anyone please provide me with the necessary guidance as it's not working when I am adding inside the Pipelinejob parameters?

# https://cloud.google.com/vertex-ai/docs/pipelines/schedule-pipeline-run#create-a-schedule
pipeline_job = aiplatform.PipelineJob(
  template_path="COMPILED_PIPELINE_PATH",
  pipeline_root="PIPELINE_ROOT_PATH",
  display_name="DISPLAY_NAME",
  labels="{"name":"test_xx"}"
)
pipeline_job_schedule = aiplatform.PipelineJobSchedule(
  pipeline_job=pipeline_job,
  display_name="SCHEDULE_NAME"
)

pipeline_job_schedule.create(
  cron="TZ=CRON",
  max_concurrent_run_count=MAX_CONCURRENT_RUN_COUNT,
  max_run_count=MAX_RUN_COUNT,
)
2

There are 2 answers

0
Rituraj kumar On BEST ANSWER

There was a bug in the Vertex AI platform SDK which has been discussed in the Github issue ticket below. It has been fixed in SDK versions 1.37.0 (released on December 5th, 2023).

GitHub Issue ticket

1
Charly On

What about trying this:

from google.cloud import aiplatform

# Define custom labels as a dictionary
custom_labels = {
    "name": "test_xx",
}

# Create the pipeline job
pipeline_job = aiplatform.PipelineJob(
    template_path="COMPILED_PIPELINE_PATH",
    pipeline_root="PIPELINE_ROOT_PATH",
    display_name="DISPLAY_NAME",
    labels=custom_labels  # Set custom labels here
)

# Create the pipeline job schedule
pipeline_job_schedule = aiplatform.PipelineJobSchedule(
    pipeline_job=pipeline_job,
    display_name="SCHEDULE_NAME"
)

# Specify other schedule parameters and create the schedule
pipeline_job_schedule.create(
    cron="TZ=CRON",
    max_concurrent_run_count=MAX_CONCURRENT_RUN_COUNT,
    max_run_count=MAX_RUN_COUNT
)