# only need if you are using Colab
from google.colab import auth
auth.authenticate_user()GOOGLE_CLOUD_PROJECT = "gcp-ml-172005"
GOOGLE_CLOUD_REGION = "us-central1"

PIPELINE_NAME = "penguin-vertex-training"
PUBSUB_TOPIC = f"trigger-{PIPELINE_NAME}"
SCHEDULER_JOB_NAME = "MLOpsJob"import json

data = '{"num_epochs": "3", "learning_rate": "1e-2"}'
data = json.dumps(data)import json
from google.cloud import scheduler_v1
from google.cloud.scheduler_v1.types.target import PubsubTarget
from google.cloud.scheduler_v1.types.job import Job
from google.cloud.scheduler_v1.types.cloudscheduler import CreateJobRequest

client = scheduler_v1.CloudSchedulerClient.from_service_account_json(
    r"./gcp-ml-172005-528977a75f85.json")parent = client.common_location_path(GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_REGION)

data = {"num_epochs": "3", "learning_rate": "1e-2"}
data = json.dumps(data).encode('utf-8')
pubsub_target = PubsubTarget(
    topic_name=f"projects/{GOOGLE_CLOUD_PROJECT}/topics/{PUBSUB_TOPIC}", 
    data=data)

job = Job(name=f"projects/{GOOGLE_CLOUD_PROJECT}/locations/{GOOGLE_CLOUD_REGION}/jobs/traing_for_model", 
          pubsub_target=pubsub_target, 
          schedule="*/3 * * * *")

req = CreateJobRequest(parent=parent, job=job)result_job = client.create_job(req)result_job