Source code for airflow.providers.google.cloud.links.vertex_ai
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations
from typing import TYPE_CHECKING
from airflow.providers.google.cloud.links.base import BaseGoogleLink
if TYPE_CHECKING:
from airflow.utils.context import Context
[docs]
VERTEX_AI_BASE_LINK = "/vertex-ai"
[docs]
VERTEX_AI_MODEL_LINK = (
VERTEX_AI_BASE_LINK
+ "/models/locations/{region}/models/{model_id}/versions/default/properties?project={project_id}"
)
[docs]
VERTEX_AI_MODEL_LIST_LINK = VERTEX_AI_BASE_LINK + "/models?project={project_id}"
[docs]
VERTEX_AI_MODEL_EXPORT_LINK = "/storage/browser/{bucket_name}/model-{model_id}?project={project_id}"
[docs]
VERTEX_AI_TRAINING_LINK = (
VERTEX_AI_BASE_LINK + "/locations/{region}/training/{training_id}/cpu?project={project_id}"
)
[docs]
VERTEX_AI_TRAINING_PIPELINES_LINK = VERTEX_AI_BASE_LINK + "/training/training-pipelines?project={project_id}"
[docs]
VERTEX_AI_DATASET_LINK = (
VERTEX_AI_BASE_LINK + "/locations/{region}/datasets/{dataset_id}/analyze?project={project_id}"
)
[docs]
VERTEX_AI_DATASET_LIST_LINK = VERTEX_AI_BASE_LINK + "/datasets?project={project_id}"
[docs]
VERTEX_AI_HYPERPARAMETER_TUNING_JOB_LIST_LINK = (
VERTEX_AI_BASE_LINK + "/training/hyperparameter-tuning-jobs?project={project_id}"
)
[docs]
VERTEX_AI_BATCH_PREDICTION_JOB_LINK = (
VERTEX_AI_BASE_LINK
+ "/locations/{region}/batch-predictions/{batch_prediction_job_id}?project={project_id}"
)
[docs]
VERTEX_AI_BATCH_PREDICTION_JOB_LIST_LINK = VERTEX_AI_BASE_LINK + "/batch-predictions?project={project_id}"
[docs]
VERTEX_AI_ENDPOINT_LINK = (
VERTEX_AI_BASE_LINK + "/locations/{region}/endpoints/{endpoint_id}?project={project_id}"
)
[docs]
VERTEX_AI_ENDPOINT_LIST_LINK = VERTEX_AI_BASE_LINK + "/endpoints?project={project_id}"
[docs]
VERTEX_AI_PIPELINE_JOB_LINK = (
VERTEX_AI_BASE_LINK + "/locations/{region}/pipelines/runs/{pipeline_id}?project={project_id}"
)
[docs]
VERTEX_AI_PIPELINE_JOB_LIST_LINK = VERTEX_AI_BASE_LINK + "/pipelines/runs?project={project_id}"
[docs]
VERTEX_AI_RAY_CLUSTER_LINK = (
VERTEX_AI_BASE_LINK + "/locations/{location}/ray-clusters/{cluster_id}?project={project_id}"
)
[docs]
VERTEX_AI_RAY_CLUSTER_LIST_LINK = VERTEX_AI_BASE_LINK + "/ray?project={project_id}"
[docs]
class VertexAIModelLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Model link."""
[docs]
name = "Vertex AI Model"
[docs]
class VertexAIModelListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Models Link."""
[docs]
class VertexAIModelExportLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Model Export Link."""
@staticmethod
@classmethod
[docs]
def persist(cls, context: Context, **value):
output_config = value.get("output_config")
bucket_name = cls.extract_bucket_name(output_config)
super().persist(
context=context,
project_id=value.get("project_id"),
model_id=value.get("model_id"),
bucket_name=bucket_name,
)
[docs]
class VertexAITrainingLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Training link."""
[docs]
name = "Vertex AI Training"
[docs]
class VertexAITrainingPipelinesLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Training Pipelines link."""
[docs]
name = "Vertex AI Training Pipelines"
[docs]
class VertexAIDatasetLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Dataset link."""
[docs]
class VertexAIDatasetListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Datasets Link."""
[docs]
class VertexAIHyperparameterTuningJobListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI HyperparameterTuningJobs Link."""
[docs]
name = "Hyperparameter Tuning Job List"
[docs]
key = "hyperparameter_tuning_jobs_conf"
[docs]
class VertexAIBatchPredictionJobLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI BatchPredictionJob link."""
[docs]
name = "Batch Prediction Job"
[docs]
key = "batch_prediction_job_conf"
[docs]
class VertexAIBatchPredictionJobListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI BatchPredictionJobList link."""
[docs]
name = "Batch Prediction Job List"
[docs]
key = "batch_prediction_jobs_conf"
[docs]
class VertexAIEndpointLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Endpoint link."""
[docs]
class VertexAIEndpointListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI EndpointList link."""
[docs]
class VertexAIPipelineJobLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI PipelineJob link."""
[docs]
key = "pipeline_job_conf"
[docs]
class VertexAIPipelineJobListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI PipelineJobList link."""
[docs]
name = "Pipeline Job List"
[docs]
key = "pipeline_job_list_conf"
[docs]
class VertexAIRayClusterLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Ray Cluster link."""
[docs]
key = "ray_cluster_conf"
[docs]
class VertexAIRayClusterListLink(BaseGoogleLink):
"""Helper class for constructing Vertex AI Ray Cluster List link."""
[docs]
name = "Ray Cluster List"
[docs]
key = "ray_cluster_list_conf"