apache-airflow-providers-google 14.0.0__py3-none-any.whl → 19.1.0rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/google/3rd-party-licenses/LICENSES.txt +14 -0
- airflow/providers/google/3rd-party-licenses/NOTICE +5 -0
- airflow/providers/google/__init__.py +3 -3
- airflow/providers/google/_vendor/__init__.py +0 -0
- airflow/providers/google/_vendor/json_merge_patch.py +91 -0
- airflow/providers/google/ads/hooks/ads.py +52 -43
- airflow/providers/google/ads/operators/ads.py +2 -2
- airflow/providers/google/ads/transfers/ads_to_gcs.py +3 -19
- airflow/providers/google/assets/gcs.py +1 -11
- airflow/providers/google/cloud/_internal_client/secret_manager_client.py +3 -2
- airflow/providers/google/cloud/bundles/gcs.py +161 -0
- airflow/providers/google/cloud/hooks/alloy_db.py +2 -3
- airflow/providers/google/cloud/hooks/bigquery.py +195 -318
- airflow/providers/google/cloud/hooks/bigquery_dts.py +8 -8
- airflow/providers/google/cloud/hooks/bigtable.py +3 -2
- airflow/providers/google/cloud/hooks/cloud_batch.py +8 -9
- airflow/providers/google/cloud/hooks/cloud_build.py +6 -65
- airflow/providers/google/cloud/hooks/cloud_composer.py +292 -24
- airflow/providers/google/cloud/hooks/cloud_logging.py +109 -0
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +4 -3
- airflow/providers/google/cloud/hooks/cloud_run.py +20 -11
- airflow/providers/google/cloud/hooks/cloud_sql.py +136 -64
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +35 -15
- airflow/providers/google/cloud/hooks/compute.py +7 -6
- airflow/providers/google/cloud/hooks/compute_ssh.py +7 -4
- airflow/providers/google/cloud/hooks/datacatalog.py +12 -3
- airflow/providers/google/cloud/hooks/dataflow.py +87 -242
- airflow/providers/google/cloud/hooks/dataform.py +9 -14
- airflow/providers/google/cloud/hooks/datafusion.py +7 -9
- airflow/providers/google/cloud/hooks/dataplex.py +13 -12
- airflow/providers/google/cloud/hooks/dataprep.py +2 -2
- airflow/providers/google/cloud/hooks/dataproc.py +76 -74
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +4 -3
- airflow/providers/google/cloud/hooks/dlp.py +5 -4
- airflow/providers/google/cloud/hooks/gcs.py +144 -33
- airflow/providers/google/cloud/hooks/gen_ai.py +196 -0
- airflow/providers/google/cloud/hooks/kms.py +3 -2
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +22 -17
- airflow/providers/google/cloud/hooks/looker.py +6 -1
- airflow/providers/google/cloud/hooks/managed_kafka.py +227 -3
- airflow/providers/google/cloud/hooks/mlengine.py +7 -8
- airflow/providers/google/cloud/hooks/natural_language.py +3 -2
- airflow/providers/google/cloud/hooks/os_login.py +3 -2
- airflow/providers/google/cloud/hooks/pubsub.py +6 -6
- airflow/providers/google/cloud/hooks/secret_manager.py +105 -12
- airflow/providers/google/cloud/hooks/spanner.py +75 -10
- airflow/providers/google/cloud/hooks/speech_to_text.py +3 -2
- airflow/providers/google/cloud/hooks/stackdriver.py +18 -18
- airflow/providers/google/cloud/hooks/tasks.py +4 -3
- airflow/providers/google/cloud/hooks/text_to_speech.py +3 -2
- airflow/providers/google/cloud/hooks/translate.py +8 -17
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +8 -222
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +9 -15
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +33 -283
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +5 -12
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +6 -12
- airflow/providers/google/cloud/hooks/vertex_ai/experiment_service.py +202 -0
- airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +311 -10
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +79 -75
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +7 -13
- airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +8 -12
- airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +6 -12
- airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +3 -2
- airflow/providers/google/cloud/hooks/vertex_ai/ray.py +223 -0
- airflow/providers/google/cloud/hooks/video_intelligence.py +3 -2
- airflow/providers/google/cloud/hooks/vision.py +7 -7
- airflow/providers/google/cloud/hooks/workflows.py +4 -3
- airflow/providers/google/cloud/links/alloy_db.py +0 -46
- airflow/providers/google/cloud/links/base.py +77 -7
- airflow/providers/google/cloud/links/bigquery.py +0 -47
- airflow/providers/google/cloud/links/bigquery_dts.py +0 -20
- airflow/providers/google/cloud/links/bigtable.py +0 -48
- airflow/providers/google/cloud/links/cloud_build.py +0 -73
- airflow/providers/google/cloud/links/cloud_functions.py +0 -33
- airflow/providers/google/cloud/links/cloud_memorystore.py +0 -58
- airflow/providers/google/cloud/links/{life_sciences.py → cloud_run.py} +5 -27
- airflow/providers/google/cloud/links/cloud_sql.py +0 -33
- airflow/providers/google/cloud/links/cloud_storage_transfer.py +17 -46
- airflow/providers/google/cloud/links/cloud_tasks.py +7 -26
- airflow/providers/google/cloud/links/compute.py +0 -58
- airflow/providers/google/cloud/links/data_loss_prevention.py +0 -169
- airflow/providers/google/cloud/links/datacatalog.py +23 -54
- airflow/providers/google/cloud/links/dataflow.py +0 -34
- airflow/providers/google/cloud/links/dataform.py +0 -64
- airflow/providers/google/cloud/links/datafusion.py +1 -90
- airflow/providers/google/cloud/links/dataplex.py +0 -154
- airflow/providers/google/cloud/links/dataprep.py +0 -24
- airflow/providers/google/cloud/links/dataproc.py +11 -89
- airflow/providers/google/cloud/links/datastore.py +0 -31
- airflow/providers/google/cloud/links/kubernetes_engine.py +11 -61
- airflow/providers/google/cloud/links/managed_kafka.py +11 -51
- airflow/providers/google/cloud/links/mlengine.py +0 -70
- airflow/providers/google/cloud/links/pubsub.py +0 -32
- airflow/providers/google/cloud/links/spanner.py +0 -33
- airflow/providers/google/cloud/links/stackdriver.py +0 -30
- airflow/providers/google/cloud/links/translate.py +17 -187
- airflow/providers/google/cloud/links/vertex_ai.py +28 -195
- airflow/providers/google/cloud/links/workflows.py +0 -52
- airflow/providers/google/cloud/log/gcs_task_handler.py +166 -118
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +14 -9
- airflow/providers/google/cloud/openlineage/CloudStorageTransferJobFacet.json +68 -0
- airflow/providers/google/cloud/openlineage/CloudStorageTransferRunFacet.json +60 -0
- airflow/providers/google/cloud/openlineage/DataFusionRunFacet.json +32 -0
- airflow/providers/google/cloud/openlineage/facets.py +141 -40
- airflow/providers/google/cloud/openlineage/mixins.py +14 -13
- airflow/providers/google/cloud/openlineage/utils.py +19 -3
- airflow/providers/google/cloud/operators/alloy_db.py +76 -61
- airflow/providers/google/cloud/operators/bigquery.py +104 -667
- airflow/providers/google/cloud/operators/bigquery_dts.py +12 -12
- airflow/providers/google/cloud/operators/bigtable.py +38 -7
- airflow/providers/google/cloud/operators/cloud_base.py +22 -1
- airflow/providers/google/cloud/operators/cloud_batch.py +18 -18
- airflow/providers/google/cloud/operators/cloud_build.py +80 -36
- airflow/providers/google/cloud/operators/cloud_composer.py +157 -71
- airflow/providers/google/cloud/operators/cloud_logging_sink.py +341 -0
- airflow/providers/google/cloud/operators/cloud_memorystore.py +74 -46
- airflow/providers/google/cloud/operators/cloud_run.py +39 -20
- airflow/providers/google/cloud/operators/cloud_sql.py +46 -61
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +92 -14
- airflow/providers/google/cloud/operators/compute.py +18 -50
- airflow/providers/google/cloud/operators/datacatalog.py +167 -29
- airflow/providers/google/cloud/operators/dataflow.py +38 -15
- airflow/providers/google/cloud/operators/dataform.py +19 -7
- airflow/providers/google/cloud/operators/datafusion.py +43 -43
- airflow/providers/google/cloud/operators/dataplex.py +212 -126
- airflow/providers/google/cloud/operators/dataprep.py +1 -5
- airflow/providers/google/cloud/operators/dataproc.py +134 -207
- airflow/providers/google/cloud/operators/dataproc_metastore.py +102 -84
- airflow/providers/google/cloud/operators/datastore.py +22 -6
- airflow/providers/google/cloud/operators/dlp.py +24 -45
- airflow/providers/google/cloud/operators/functions.py +21 -14
- airflow/providers/google/cloud/operators/gcs.py +15 -12
- airflow/providers/google/cloud/operators/gen_ai.py +389 -0
- airflow/providers/google/cloud/operators/kubernetes_engine.py +115 -106
- airflow/providers/google/cloud/operators/looker.py +1 -1
- airflow/providers/google/cloud/operators/managed_kafka.py +362 -40
- airflow/providers/google/cloud/operators/natural_language.py +5 -3
- airflow/providers/google/cloud/operators/pubsub.py +69 -21
- airflow/providers/google/cloud/operators/spanner.py +53 -45
- airflow/providers/google/cloud/operators/speech_to_text.py +5 -4
- airflow/providers/google/cloud/operators/stackdriver.py +5 -11
- airflow/providers/google/cloud/operators/tasks.py +6 -15
- airflow/providers/google/cloud/operators/text_to_speech.py +4 -3
- airflow/providers/google/cloud/operators/translate.py +46 -20
- airflow/providers/google/cloud/operators/translate_speech.py +4 -3
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +44 -34
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +34 -12
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +62 -53
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +75 -11
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +48 -12
- airflow/providers/google/cloud/operators/vertex_ai/experiment_service.py +435 -0
- airflow/providers/google/cloud/operators/vertex_ai/feature_store.py +532 -1
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +135 -116
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +16 -12
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +62 -14
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +35 -10
- airflow/providers/google/cloud/operators/vertex_ai/ray.py +393 -0
- airflow/providers/google/cloud/operators/video_intelligence.py +5 -3
- airflow/providers/google/cloud/operators/vision.py +7 -5
- airflow/providers/google/cloud/operators/workflows.py +24 -19
- airflow/providers/google/cloud/secrets/secret_manager.py +2 -1
- airflow/providers/google/cloud/sensors/bigquery.py +2 -2
- airflow/providers/google/cloud/sensors/bigquery_dts.py +6 -4
- airflow/providers/google/cloud/sensors/bigtable.py +14 -6
- airflow/providers/google/cloud/sensors/cloud_composer.py +535 -33
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +6 -5
- airflow/providers/google/cloud/sensors/dataflow.py +27 -10
- airflow/providers/google/cloud/sensors/dataform.py +2 -2
- airflow/providers/google/cloud/sensors/datafusion.py +4 -4
- airflow/providers/google/cloud/sensors/dataplex.py +7 -5
- airflow/providers/google/cloud/sensors/dataprep.py +2 -2
- airflow/providers/google/cloud/sensors/dataproc.py +10 -9
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +4 -3
- airflow/providers/google/cloud/sensors/gcs.py +22 -21
- airflow/providers/google/cloud/sensors/looker.py +5 -5
- airflow/providers/google/cloud/sensors/pubsub.py +20 -20
- airflow/providers/google/cloud/sensors/tasks.py +2 -2
- airflow/providers/google/cloud/sensors/vertex_ai/feature_store.py +2 -2
- airflow/providers/google/cloud/sensors/workflows.py +6 -4
- airflow/providers/google/cloud/transfers/adls_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +11 -8
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +14 -13
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +7 -3
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +12 -1
- airflow/providers/google/cloud/transfers/bigquery_to_postgres.py +24 -10
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +104 -5
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +18 -22
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +4 -5
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +45 -38
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/gcs_to_local.py +5 -3
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +10 -4
- airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +6 -2
- airflow/providers/google/cloud/transfers/gdrive_to_local.py +2 -2
- airflow/providers/google/cloud/transfers/http_to_gcs.py +193 -0
- airflow/providers/google/cloud/transfers/local_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/oracle_to_gcs.py +36 -11
- airflow/providers/google/cloud/transfers/postgres_to_gcs.py +44 -12
- airflow/providers/google/cloud/transfers/s3_to_gcs.py +12 -6
- airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +36 -14
- airflow/providers/google/cloud/transfers/sheets_to_gcs.py +3 -3
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +10 -10
- airflow/providers/google/cloud/triggers/bigquery.py +75 -34
- airflow/providers/google/cloud/triggers/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_batch.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_build.py +3 -2
- airflow/providers/google/cloud/triggers/cloud_composer.py +303 -47
- airflow/providers/google/cloud/triggers/cloud_run.py +2 -2
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +96 -5
- airflow/providers/google/cloud/triggers/dataflow.py +125 -2
- airflow/providers/google/cloud/triggers/datafusion.py +1 -1
- airflow/providers/google/cloud/triggers/dataplex.py +16 -3
- airflow/providers/google/cloud/triggers/dataproc.py +124 -53
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +46 -28
- airflow/providers/google/cloud/triggers/mlengine.py +1 -1
- airflow/providers/google/cloud/triggers/pubsub.py +17 -20
- airflow/providers/google/cloud/triggers/vertex_ai.py +8 -7
- airflow/providers/google/cloud/utils/bigquery.py +5 -7
- airflow/providers/google/cloud/utils/bigquery_get_data.py +1 -1
- airflow/providers/google/cloud/utils/credentials_provider.py +4 -3
- airflow/providers/google/cloud/utils/dataform.py +1 -1
- airflow/providers/google/cloud/utils/external_token_supplier.py +0 -1
- airflow/providers/google/cloud/utils/field_validator.py +1 -2
- airflow/providers/google/cloud/utils/validators.py +43 -0
- airflow/providers/google/common/auth_backend/google_openid.py +26 -9
- airflow/providers/google/common/consts.py +2 -1
- airflow/providers/google/common/deprecated.py +2 -1
- airflow/providers/google/common/hooks/base_google.py +40 -43
- airflow/providers/google/common/hooks/operation_helpers.py +78 -0
- airflow/providers/google/common/links/storage.py +0 -22
- airflow/providers/google/common/utils/get_secret.py +31 -0
- airflow/providers/google/common/utils/id_token_credentials.py +4 -5
- airflow/providers/google/firebase/operators/firestore.py +2 -2
- airflow/providers/google/get_provider_info.py +61 -216
- airflow/providers/google/go_module_utils.py +35 -3
- airflow/providers/google/leveldb/hooks/leveldb.py +30 -6
- airflow/providers/google/leveldb/operators/leveldb.py +2 -2
- airflow/providers/google/marketing_platform/hooks/analytics_admin.py +3 -2
- airflow/providers/google/marketing_platform/hooks/display_video.py +3 -109
- airflow/providers/google/marketing_platform/hooks/search_ads.py +1 -1
- airflow/providers/google/marketing_platform/links/analytics_admin.py +4 -5
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +7 -6
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +5 -5
- airflow/providers/google/marketing_platform/operators/display_video.py +28 -489
- airflow/providers/google/marketing_platform/operators/search_ads.py +2 -2
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +2 -2
- airflow/providers/google/marketing_platform/sensors/display_video.py +4 -64
- airflow/providers/google/suite/hooks/calendar.py +1 -1
- airflow/providers/google/suite/hooks/drive.py +2 -2
- airflow/providers/google/suite/hooks/sheets.py +15 -1
- airflow/providers/google/suite/operators/sheets.py +8 -3
- airflow/providers/google/suite/sensors/drive.py +2 -2
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +2 -2
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +1 -1
- airflow/providers/google/suite/transfers/local_to_drive.py +3 -3
- airflow/providers/google/suite/transfers/sql_to_sheets.py +5 -4
- airflow/providers/google/version_compat.py +15 -1
- {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-19.1.0rc1.dist-info}/METADATA +117 -72
- apache_airflow_providers_google-19.1.0rc1.dist-info/RECORD +331 -0
- {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-19.1.0rc1.dist-info}/WHEEL +1 -1
- apache_airflow_providers_google-19.1.0rc1.dist-info/licenses/NOTICE +5 -0
- airflow/providers/google/cloud/example_dags/example_cloud_task.py +0 -54
- airflow/providers/google/cloud/hooks/automl.py +0 -679
- airflow/providers/google/cloud/hooks/life_sciences.py +0 -159
- airflow/providers/google/cloud/links/automl.py +0 -193
- airflow/providers/google/cloud/operators/automl.py +0 -1360
- airflow/providers/google/cloud/operators/life_sciences.py +0 -119
- airflow/providers/google/cloud/operators/mlengine.py +0 -1515
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +0 -273
- apache_airflow_providers_google-14.0.0.dist-info/RECORD +0 -318
- /airflow/providers/google/cloud/{example_dags → bundles}/__init__.py +0 -0
- {apache_airflow_providers_google-14.0.0.dist-info → apache_airflow_providers_google-19.1.0rc1.dist-info}/entry_points.txt +0 -0
- {airflow/providers/google → apache_airflow_providers_google-19.1.0rc1.dist-info/licenses}/LICENSE +0 -0
|
@@ -23,6 +23,10 @@ from collections.abc import Sequence
|
|
|
23
23
|
from functools import cached_property
|
|
24
24
|
from typing import TYPE_CHECKING, Any
|
|
25
25
|
|
|
26
|
+
from google.api_core.exceptions import NotFound
|
|
27
|
+
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
|
28
|
+
from google.cloud.aiplatform_v1 import types
|
|
29
|
+
|
|
26
30
|
from airflow.configuration import conf
|
|
27
31
|
from airflow.exceptions import AirflowException
|
|
28
32
|
from airflow.providers.google.cloud.hooks.vertex_ai.pipeline_job import PipelineJobHook
|
|
@@ -32,16 +36,14 @@ from airflow.providers.google.cloud.links.vertex_ai import (
|
|
|
32
36
|
)
|
|
33
37
|
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
34
38
|
from airflow.providers.google.cloud.triggers.vertex_ai import RunPipelineJobTrigger
|
|
35
|
-
from google.api_core.exceptions import NotFound
|
|
36
|
-
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
|
37
|
-
from google.cloud.aiplatform_v1 import types
|
|
38
39
|
|
|
39
40
|
if TYPE_CHECKING:
|
|
40
|
-
from airflow.utils.context import Context
|
|
41
41
|
from google.api_core.retry import Retry
|
|
42
42
|
from google.cloud.aiplatform import PipelineJob
|
|
43
43
|
from google.cloud.aiplatform.metadata import experiment_resources
|
|
44
44
|
|
|
45
|
+
from airflow.providers.common.compat.sdk import Context
|
|
46
|
+
|
|
45
47
|
|
|
46
48
|
class RunPipelineJobOperator(GoogleCloudBaseOperator):
|
|
47
49
|
"""
|
|
@@ -110,6 +112,10 @@ class RunPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
110
112
|
"project_id",
|
|
111
113
|
"input_artifacts",
|
|
112
114
|
"impersonation_chain",
|
|
115
|
+
"template_path",
|
|
116
|
+
"pipeline_root",
|
|
117
|
+
"parameter_values",
|
|
118
|
+
"service_account",
|
|
113
119
|
]
|
|
114
120
|
operator_extra_links = (VertexAIPipelineJobLink(),)
|
|
115
121
|
|
|
@@ -160,6 +166,13 @@ class RunPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
160
166
|
self.deferrable = deferrable
|
|
161
167
|
self.poll_interval = poll_interval
|
|
162
168
|
|
|
169
|
+
@property
|
|
170
|
+
def extra_links_params(self) -> dict[str, Any]:
|
|
171
|
+
return {
|
|
172
|
+
"region": self.region,
|
|
173
|
+
"project_id": self.project_id,
|
|
174
|
+
}
|
|
175
|
+
|
|
163
176
|
def execute(self, context: Context):
|
|
164
177
|
self.log.info("Running Pipeline job")
|
|
165
178
|
pipeline_job_obj: PipelineJob = self.hook.submit_pipeline_job(
|
|
@@ -182,8 +195,8 @@ class RunPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
182
195
|
)
|
|
183
196
|
pipeline_job_id = pipeline_job_obj.job_id
|
|
184
197
|
self.log.info("Pipeline job was created. Job id: %s", pipeline_job_id)
|
|
185
|
-
|
|
186
|
-
VertexAIPipelineJobLink.persist(context=context,
|
|
198
|
+
context["ti"].xcom_push(key="pipeline_job_id", value=pipeline_job_id)
|
|
199
|
+
VertexAIPipelineJobLink.persist(context=context, pipeline_id=pipeline_job_id)
|
|
187
200
|
|
|
188
201
|
if self.deferrable:
|
|
189
202
|
pipeline_job_obj.wait_for_resource_creation()
|
|
@@ -274,6 +287,13 @@ class GetPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
274
287
|
self.gcp_conn_id = gcp_conn_id
|
|
275
288
|
self.impersonation_chain = impersonation_chain
|
|
276
289
|
|
|
290
|
+
@property
|
|
291
|
+
def extra_links_params(self) -> dict[str, Any]:
|
|
292
|
+
return {
|
|
293
|
+
"region": self.region,
|
|
294
|
+
"project_id": self.project_id,
|
|
295
|
+
}
|
|
296
|
+
|
|
277
297
|
def execute(self, context: Context):
|
|
278
298
|
hook = PipelineJobHook(
|
|
279
299
|
gcp_conn_id=self.gcp_conn_id,
|
|
@@ -290,9 +310,7 @@ class GetPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
290
310
|
timeout=self.timeout,
|
|
291
311
|
metadata=self.metadata,
|
|
292
312
|
)
|
|
293
|
-
VertexAIPipelineJobLink.persist(
|
|
294
|
-
context=context, task_instance=self, pipeline_id=self.pipeline_job_id
|
|
295
|
-
)
|
|
313
|
+
VertexAIPipelineJobLink.persist(context=context, pipeline_id=self.pipeline_job_id)
|
|
296
314
|
self.log.info("Pipeline job was gotten.")
|
|
297
315
|
return types.PipelineJob.to_dict(result)
|
|
298
316
|
except NotFound:
|
|
@@ -406,6 +424,13 @@ class ListPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
406
424
|
self.gcp_conn_id = gcp_conn_id
|
|
407
425
|
self.impersonation_chain = impersonation_chain
|
|
408
426
|
|
|
427
|
+
@property
|
|
428
|
+
def extra_links_params(self) -> dict[str, Any]:
|
|
429
|
+
return {
|
|
430
|
+
"region": self.region,
|
|
431
|
+
"project_id": self.project_id,
|
|
432
|
+
}
|
|
433
|
+
|
|
409
434
|
def execute(self, context: Context):
|
|
410
435
|
hook = PipelineJobHook(
|
|
411
436
|
gcp_conn_id=self.gcp_conn_id,
|
|
@@ -422,7 +447,7 @@ class ListPipelineJobOperator(GoogleCloudBaseOperator):
|
|
|
422
447
|
timeout=self.timeout,
|
|
423
448
|
metadata=self.metadata,
|
|
424
449
|
)
|
|
425
|
-
VertexAIPipelineJobListLink.persist(context=context
|
|
450
|
+
VertexAIPipelineJobListLink.persist(context=context)
|
|
426
451
|
return [types.PipelineJob.to_dict(result) for result in results]
|
|
427
452
|
|
|
428
453
|
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
"""This module contains Google Vertex AI Ray operators."""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from collections.abc import Sequence
|
|
23
|
+
from functools import cached_property
|
|
24
|
+
from typing import TYPE_CHECKING, Literal
|
|
25
|
+
|
|
26
|
+
from google.api_core.exceptions import NotFound
|
|
27
|
+
from google.cloud.aiplatform.vertex_ray.util import resources
|
|
28
|
+
|
|
29
|
+
from airflow.exceptions import AirflowException
|
|
30
|
+
from airflow.providers.google.cloud.hooks.vertex_ai.ray import RayHook
|
|
31
|
+
from airflow.providers.google.cloud.links.vertex_ai import (
|
|
32
|
+
VertexAIRayClusterLink,
|
|
33
|
+
VertexAIRayClusterListLink,
|
|
34
|
+
)
|
|
35
|
+
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
36
|
+
|
|
37
|
+
if TYPE_CHECKING:
|
|
38
|
+
from airflow.providers.common.compat.sdk import Context
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class RayBaseOperator(GoogleCloudBaseOperator):
|
|
42
|
+
"""
|
|
43
|
+
Base class for Ray operators.
|
|
44
|
+
|
|
45
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
46
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
47
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
48
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
49
|
+
credentials, or chained list of accounts required to get the access_token
|
|
50
|
+
of the last account in the list, which will be impersonated in the request.
|
|
51
|
+
If set as a string, the account must grant the originating account
|
|
52
|
+
the Service Account Token Creator IAM role.
|
|
53
|
+
If set as a sequence, the identities from the list must grant
|
|
54
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
55
|
+
account from the list granting this role to the originating account (templated).
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
template_fields: Sequence[str] = (
|
|
59
|
+
"location",
|
|
60
|
+
"gcp_conn_id",
|
|
61
|
+
"project_id",
|
|
62
|
+
"impersonation_chain",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def __init__(
|
|
66
|
+
self,
|
|
67
|
+
project_id: str,
|
|
68
|
+
location: str,
|
|
69
|
+
gcp_conn_id: str = "google_cloud_default",
|
|
70
|
+
impersonation_chain: str | Sequence[str] | None = None,
|
|
71
|
+
*args,
|
|
72
|
+
**kwargs,
|
|
73
|
+
) -> None:
|
|
74
|
+
super().__init__(*args, **kwargs)
|
|
75
|
+
self.location = location
|
|
76
|
+
self.project_id = project_id
|
|
77
|
+
self.gcp_conn_id = gcp_conn_id
|
|
78
|
+
self.impersonation_chain = impersonation_chain
|
|
79
|
+
|
|
80
|
+
@cached_property
|
|
81
|
+
def hook(self) -> RayHook:
|
|
82
|
+
return RayHook(
|
|
83
|
+
gcp_conn_id=self.gcp_conn_id,
|
|
84
|
+
impersonation_chain=self.impersonation_chain,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class CreateRayClusterOperator(RayBaseOperator):
|
|
89
|
+
"""
|
|
90
|
+
Create a Ray cluster on the Vertex AI.
|
|
91
|
+
|
|
92
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
93
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
94
|
+
:param head_node_type: The head node resource. Resources.node_count must be 1. If not set, default
|
|
95
|
+
value of Resources() class will be used.
|
|
96
|
+
:param python_version: Required. Python version for the ray cluster.
|
|
97
|
+
:param ray_version: Required. Ray version for the ray cluster.
|
|
98
|
+
Currently only 3 version are available: 2.9.3, 2.33, 2.42. For more information please refer to
|
|
99
|
+
https://github.com/googleapis/python-aiplatform/blob/main/setup.py#L101
|
|
100
|
+
:param network: Virtual private cloud (VPC) network. For Ray Client, VPC peering is required to
|
|
101
|
+
connect to the Ray Cluster managed in the Vertex API service. For Ray Job API, VPC network is not
|
|
102
|
+
required because Ray Cluster connection can be accessed through dashboard address.
|
|
103
|
+
:param service_account: Service account to be used for running Ray programs on the cluster.
|
|
104
|
+
:param cluster_name: This value may be up to 63 characters, and valid characters are `[a-z0-9_-]`.
|
|
105
|
+
The first character cannot be a number or hyphen.
|
|
106
|
+
:param worker_node_types: The list of Resources of the worker nodes. The same Resources object should
|
|
107
|
+
not appear multiple times in the list.
|
|
108
|
+
:param custom_images: The NodeImages which specifies head node and worker nodes images. All the
|
|
109
|
+
workers will share the same image. If each Resource has a specific custom image, use
|
|
110
|
+
`Resources.custom_image` for head/worker_node_type(s). Note that configuring
|
|
111
|
+
`Resources.custom_image` will override `custom_images` here. Allowlist only.
|
|
112
|
+
:param enable_metrics_collection: Enable Ray metrics collection for visualization.
|
|
113
|
+
:param enable_logging: Enable exporting Ray logs to Cloud Logging.
|
|
114
|
+
:param psc_interface_config: PSC-I config.
|
|
115
|
+
:param reserved_ip_ranges: A list of names for the reserved IP ranges under the VPC network that can
|
|
116
|
+
be used for this cluster. If set, we will deploy the cluster within the provided IP ranges.
|
|
117
|
+
Otherwise, the cluster is deployed to any IP ranges under the provided VPC network.
|
|
118
|
+
Example: ["vertex-ai-ip-range"].
|
|
119
|
+
:param labels: The labels with user-defined metadata to organize Ray cluster.
|
|
120
|
+
Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain
|
|
121
|
+
lowercase letters, numeric characters, underscores and dashes. International characters are allowed.
|
|
122
|
+
See https://goo.gl/xmQnxf for more information and examples of labels.
|
|
123
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
124
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
125
|
+
credentials, or chained list of accounts required to get the access_token
|
|
126
|
+
of the last account in the list, which will be impersonated in the request.
|
|
127
|
+
If set as a string, the account must grant the originating account
|
|
128
|
+
the Service Account Token Creator IAM role.
|
|
129
|
+
If set as a sequence, the identities from the list must grant
|
|
130
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
131
|
+
account from the list granting this role to the originating account (templated).
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
template_fields: Sequence[str] = tuple(
|
|
135
|
+
{"head_node_type", "worker_node_types"} | set(RayBaseOperator.template_fields)
|
|
136
|
+
)
|
|
137
|
+
operator_extra_links = (VertexAIRayClusterLink(),)
|
|
138
|
+
|
|
139
|
+
def __init__(
|
|
140
|
+
self,
|
|
141
|
+
python_version: str,
|
|
142
|
+
ray_version: Literal["2.9.3", "2.33", "2.42"],
|
|
143
|
+
head_node_type: resources.Resources = resources.Resources(),
|
|
144
|
+
network: str | None = None,
|
|
145
|
+
service_account: str | None = None,
|
|
146
|
+
cluster_name: str | None = None,
|
|
147
|
+
worker_node_types: list[resources.Resources] | None = None,
|
|
148
|
+
custom_images: resources.NodeImages | None = None,
|
|
149
|
+
enable_metrics_collection: bool = True,
|
|
150
|
+
enable_logging: bool = True,
|
|
151
|
+
psc_interface_config: resources.PscIConfig | None = None,
|
|
152
|
+
reserved_ip_ranges: list[str] | None = None,
|
|
153
|
+
labels: dict[str, str] | None = None,
|
|
154
|
+
*args,
|
|
155
|
+
**kwargs,
|
|
156
|
+
) -> None:
|
|
157
|
+
super().__init__(*args, **kwargs)
|
|
158
|
+
self.head_node_type = head_node_type
|
|
159
|
+
self.python_version = python_version
|
|
160
|
+
self.ray_version = ray_version
|
|
161
|
+
self.network = network
|
|
162
|
+
self.service_account = service_account
|
|
163
|
+
self.cluster_name = cluster_name
|
|
164
|
+
self.worker_node_types = worker_node_types
|
|
165
|
+
self.custom_images = custom_images
|
|
166
|
+
self.enable_metrics_collection = enable_metrics_collection
|
|
167
|
+
self.enable_logging = enable_logging
|
|
168
|
+
self.psc_interface_config = psc_interface_config
|
|
169
|
+
self.reserved_ip_ranges = reserved_ip_ranges
|
|
170
|
+
self.labels = labels
|
|
171
|
+
|
|
172
|
+
def execute(self, context: Context):
|
|
173
|
+
self.log.info("Creating a Ray cluster.")
|
|
174
|
+
try:
|
|
175
|
+
cluster_path = self.hook.create_ray_cluster(
|
|
176
|
+
project_id=self.project_id,
|
|
177
|
+
location=self.location,
|
|
178
|
+
head_node_type=self.head_node_type,
|
|
179
|
+
python_version=self.python_version,
|
|
180
|
+
ray_version=self.ray_version,
|
|
181
|
+
network=self.network,
|
|
182
|
+
service_account=self.service_account,
|
|
183
|
+
cluster_name=self.cluster_name,
|
|
184
|
+
worker_node_types=self.worker_node_types,
|
|
185
|
+
custom_images=self.custom_images,
|
|
186
|
+
enable_metrics_collection=self.enable_metrics_collection,
|
|
187
|
+
enable_logging=self.enable_logging,
|
|
188
|
+
psc_interface_config=self.psc_interface_config,
|
|
189
|
+
reserved_ip_ranges=self.reserved_ip_ranges,
|
|
190
|
+
labels=self.labels,
|
|
191
|
+
)
|
|
192
|
+
cluster_id = self.hook.extract_cluster_id(cluster_path)
|
|
193
|
+
context["ti"].xcom_push(
|
|
194
|
+
key="cluster_id",
|
|
195
|
+
value=cluster_id,
|
|
196
|
+
)
|
|
197
|
+
VertexAIRayClusterLink.persist(
|
|
198
|
+
context=context, location=self.location, cluster_id=cluster_id, project_id=self.project_id
|
|
199
|
+
)
|
|
200
|
+
self.log.info("Ray cluster was created.")
|
|
201
|
+
except Exception as error:
|
|
202
|
+
raise AirflowException(error)
|
|
203
|
+
return cluster_path
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class ListRayClustersOperator(RayBaseOperator):
|
|
207
|
+
"""
|
|
208
|
+
List Ray clusters under the currently authenticated project.
|
|
209
|
+
|
|
210
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
211
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
212
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
213
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
214
|
+
credentials, or chained list of accounts required to get the access_token
|
|
215
|
+
of the last account in the list, which will be impersonated in the request.
|
|
216
|
+
If set as a string, the account must grant the originating account
|
|
217
|
+
the Service Account Token Creator IAM role.
|
|
218
|
+
If set as a sequence, the identities from the list must grant
|
|
219
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
220
|
+
account from the list granting this role to the originating account (templated).
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
operator_extra_links = (VertexAIRayClusterListLink(),)
|
|
224
|
+
|
|
225
|
+
def execute(self, context: Context):
|
|
226
|
+
VertexAIRayClusterListLink.persist(context=context, project_id=self.project_id)
|
|
227
|
+
self.log.info("Listing Clusters from location %s.", self.location)
|
|
228
|
+
try:
|
|
229
|
+
ray_cluster_list = self.hook.list_ray_clusters(
|
|
230
|
+
project_id=self.project_id,
|
|
231
|
+
location=self.location,
|
|
232
|
+
)
|
|
233
|
+
ray_cluster_dict_list = [
|
|
234
|
+
self.hook.serialize_cluster_obj(ray_cluster) for ray_cluster in ray_cluster_list
|
|
235
|
+
]
|
|
236
|
+
except Exception as error:
|
|
237
|
+
raise AirflowException(error)
|
|
238
|
+
return ray_cluster_dict_list
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class GetRayClusterOperator(RayBaseOperator):
|
|
242
|
+
"""
|
|
243
|
+
Get Ray cluster.
|
|
244
|
+
|
|
245
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
246
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
247
|
+
:param cluster_id: Cluster resource ID.
|
|
248
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
249
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
250
|
+
credentials, or chained list of accounts required to get the access_token
|
|
251
|
+
of the last account in the list, which will be impersonated in the request.
|
|
252
|
+
If set as a string, the account must grant the originating account
|
|
253
|
+
the Service Account Token Creator IAM role.
|
|
254
|
+
If set as a sequence, the identities from the list must grant
|
|
255
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
256
|
+
account from the list granting this role to the originating account (templated).
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
template_fields: Sequence[str] = tuple({"cluster_id"} | set(RayBaseOperator.template_fields))
|
|
260
|
+
operator_extra_links = (VertexAIRayClusterLink(),)
|
|
261
|
+
|
|
262
|
+
def __init__(
|
|
263
|
+
self,
|
|
264
|
+
cluster_id: str,
|
|
265
|
+
*args,
|
|
266
|
+
**kwargs,
|
|
267
|
+
) -> None:
|
|
268
|
+
super().__init__(*args, **kwargs)
|
|
269
|
+
self.cluster_id = cluster_id
|
|
270
|
+
|
|
271
|
+
def execute(self, context: Context):
|
|
272
|
+
VertexAIRayClusterLink.persist(
|
|
273
|
+
context=context,
|
|
274
|
+
location=self.location,
|
|
275
|
+
cluster_id=self.cluster_id,
|
|
276
|
+
project_id=self.project_id,
|
|
277
|
+
)
|
|
278
|
+
self.log.info("Getting Cluster: %s", self.cluster_id)
|
|
279
|
+
try:
|
|
280
|
+
ray_cluster = self.hook.get_ray_cluster(
|
|
281
|
+
project_id=self.project_id,
|
|
282
|
+
location=self.location,
|
|
283
|
+
cluster_id=self.cluster_id,
|
|
284
|
+
)
|
|
285
|
+
self.log.info("Cluster data has been retrieved.")
|
|
286
|
+
ray_cluster_dict = self.hook.serialize_cluster_obj(ray_cluster)
|
|
287
|
+
return ray_cluster_dict
|
|
288
|
+
except NotFound as not_found_err:
|
|
289
|
+
self.log.info("The Cluster %s does not exist.", self.cluster_id)
|
|
290
|
+
raise AirflowException(not_found_err)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
class UpdateRayClusterOperator(RayBaseOperator):
|
|
294
|
+
"""
|
|
295
|
+
Update Ray cluster (currently support resizing node counts for worker nodes).
|
|
296
|
+
|
|
297
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
298
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
299
|
+
:param cluster_id: Cluster resource ID.
|
|
300
|
+
:param worker_node_types: The list of Resources of the resized worker nodes. The same Resources
|
|
301
|
+
object should not appear multiple times in the list.
|
|
302
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
303
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
304
|
+
credentials, or chained list of accounts required to get the access_token
|
|
305
|
+
of the last account in the list, which will be impersonated in the request.
|
|
306
|
+
If set as a string, the account must grant the originating account
|
|
307
|
+
the Service Account Token Creator IAM role.
|
|
308
|
+
If set as a sequence, the identities from the list must grant
|
|
309
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
310
|
+
account from the list granting this role to the originating account (templated).
|
|
311
|
+
"""
|
|
312
|
+
|
|
313
|
+
template_fields: Sequence[str] = tuple(
|
|
314
|
+
{"cluster_id", "worker_node_types"} | set(RayBaseOperator.template_fields)
|
|
315
|
+
)
|
|
316
|
+
operator_extra_links = (VertexAIRayClusterLink(),)
|
|
317
|
+
|
|
318
|
+
def __init__(
|
|
319
|
+
self,
|
|
320
|
+
cluster_id: str,
|
|
321
|
+
worker_node_types: list[resources.Resources],
|
|
322
|
+
*args,
|
|
323
|
+
**kwargs,
|
|
324
|
+
) -> None:
|
|
325
|
+
super().__init__(*args, **kwargs)
|
|
326
|
+
self.cluster_id = cluster_id
|
|
327
|
+
self.worker_node_types = worker_node_types
|
|
328
|
+
|
|
329
|
+
def execute(self, context: Context):
|
|
330
|
+
VertexAIRayClusterLink.persist(
|
|
331
|
+
context=context,
|
|
332
|
+
location=self.location,
|
|
333
|
+
cluster_id=self.cluster_id,
|
|
334
|
+
project_id=self.project_id,
|
|
335
|
+
)
|
|
336
|
+
self.log.info("Updating a Ray cluster.")
|
|
337
|
+
try:
|
|
338
|
+
cluster_path = self.hook.update_ray_cluster(
|
|
339
|
+
project_id=self.project_id,
|
|
340
|
+
location=self.location,
|
|
341
|
+
cluster_id=self.cluster_id,
|
|
342
|
+
worker_node_types=self.worker_node_types,
|
|
343
|
+
)
|
|
344
|
+
self.log.info("Ray cluster %s was updated.", self.cluster_id)
|
|
345
|
+
return cluster_path
|
|
346
|
+
except NotFound as not_found_err:
|
|
347
|
+
self.log.info("The Cluster %s does not exist.", self.cluster_id)
|
|
348
|
+
raise AirflowException(not_found_err)
|
|
349
|
+
except Exception as error:
|
|
350
|
+
raise AirflowException(error)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
class DeleteRayClusterOperator(RayBaseOperator):
|
|
354
|
+
"""
|
|
355
|
+
Delete Ray cluster.
|
|
356
|
+
|
|
357
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
|
358
|
+
:param location: Required. The ID of the Google Cloud region that the service belongs to.
|
|
359
|
+
:param cluster_id: Cluster resource ID.
|
|
360
|
+
:param gcp_conn_id: The connection ID to use connecting to Google Cloud.
|
|
361
|
+
:param impersonation_chain: Optional service account to impersonate using short-term
|
|
362
|
+
credentials, or chained list of accounts required to get the access_token
|
|
363
|
+
of the last account in the list, which will be impersonated in the request.
|
|
364
|
+
If set as a string, the account must grant the originating account
|
|
365
|
+
the Service Account Token Creator IAM role.
|
|
366
|
+
If set as a sequence, the identities from the list must grant
|
|
367
|
+
Service Account Token Creator IAM role to the directly preceding identity, with first
|
|
368
|
+
account from the list granting this role to the originating account (templated).
|
|
369
|
+
"""
|
|
370
|
+
|
|
371
|
+
template_fields: Sequence[str] = tuple({"cluster_id"} | set(RayBaseOperator.template_fields))
|
|
372
|
+
|
|
373
|
+
def __init__(
|
|
374
|
+
self,
|
|
375
|
+
cluster_id: str,
|
|
376
|
+
*args,
|
|
377
|
+
**kwargs,
|
|
378
|
+
) -> None:
|
|
379
|
+
super().__init__(*args, **kwargs)
|
|
380
|
+
self.cluster_id = cluster_id
|
|
381
|
+
|
|
382
|
+
def execute(self, context: Context):
|
|
383
|
+
try:
|
|
384
|
+
self.log.info("Deleting Ray cluster: %s", self.cluster_id)
|
|
385
|
+
self.hook.delete_ray_cluster(
|
|
386
|
+
project_id=self.project_id,
|
|
387
|
+
location=self.location,
|
|
388
|
+
cluster_id=self.cluster_id,
|
|
389
|
+
)
|
|
390
|
+
self.log.info("Ray cluster was deleted.")
|
|
391
|
+
except NotFound as not_found_err:
|
|
392
|
+
self.log.info("The Ray cluster ID %s does not exist.", self.cluster_id)
|
|
393
|
+
raise AirflowException(not_found_err)
|
|
@@ -22,16 +22,18 @@ from __future__ import annotations
|
|
|
22
22
|
from collections.abc import Sequence
|
|
23
23
|
from typing import TYPE_CHECKING
|
|
24
24
|
|
|
25
|
-
from airflow.providers.google.cloud.hooks.video_intelligence import CloudVideoIntelligenceHook
|
|
26
|
-
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
27
25
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
|
28
26
|
from google.cloud.videointelligence_v1 import Feature, VideoContext
|
|
29
27
|
from google.protobuf.json_format import MessageToDict
|
|
30
28
|
|
|
29
|
+
from airflow.providers.google.cloud.hooks.video_intelligence import CloudVideoIntelligenceHook
|
|
30
|
+
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
31
|
+
|
|
31
32
|
if TYPE_CHECKING:
|
|
32
|
-
from airflow.utils.context import Context
|
|
33
33
|
from google.api_core.retry import Retry
|
|
34
34
|
|
|
35
|
+
from airflow.providers.common.compat.sdk import Context
|
|
36
|
+
|
|
35
37
|
|
|
36
38
|
class CloudVideoIntelligenceDetectVideoLabelsOperator(GoogleCloudBaseOperator):
|
|
37
39
|
"""
|
|
@@ -23,9 +23,6 @@ from collections.abc import Sequence
|
|
|
23
23
|
from copy import deepcopy
|
|
24
24
|
from typing import TYPE_CHECKING, Any
|
|
25
25
|
|
|
26
|
-
from airflow.providers.google.cloud.hooks.vision import CloudVisionHook
|
|
27
|
-
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
28
|
-
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
|
|
29
26
|
from google.api_core.exceptions import AlreadyExists
|
|
30
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
|
31
28
|
from google.cloud.vision_v1 import (
|
|
@@ -36,11 +33,16 @@ from google.cloud.vision_v1 import (
|
|
|
36
33
|
ReferenceImage,
|
|
37
34
|
)
|
|
38
35
|
|
|
36
|
+
from airflow.providers.google.cloud.hooks.vision import CloudVisionHook
|
|
37
|
+
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
|
38
|
+
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
|
|
39
|
+
|
|
39
40
|
if TYPE_CHECKING:
|
|
40
|
-
from airflow.utils.context import Context
|
|
41
41
|
from google.api_core.retry import Retry
|
|
42
42
|
from google.protobuf.field_mask_pb2 import FieldMask
|
|
43
43
|
|
|
44
|
+
from airflow.providers.common.compat.sdk import Context
|
|
45
|
+
|
|
44
46
|
|
|
45
47
|
MetaData = Sequence[tuple[str, str]]
|
|
46
48
|
|
|
@@ -691,7 +693,7 @@ class CloudVisionUpdateProductOperator(GoogleCloudBaseOperator):
|
|
|
691
693
|
location=self.location,
|
|
692
694
|
product_id=self.product_id,
|
|
693
695
|
project_id=self.project_id,
|
|
694
|
-
update_mask=self.update_mask,
|
|
696
|
+
update_mask=self.update_mask,
|
|
695
697
|
retry=self.retry,
|
|
696
698
|
timeout=self.timeout,
|
|
697
699
|
metadata=self.metadata,
|