apache-airflow-providers-google 10.16.0rc1__py3-none-any.whl → 10.17.0__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/__init__.py +1 -1
- airflow/providers/google/ads/hooks/ads.py +5 -4
- airflow/providers/google/ads/operators/ads.py +1 -0
- airflow/providers/google/cloud/example_dags/example_cloud_sql_query.py +1 -0
- airflow/providers/google/cloud/example_dags/example_cloud_task.py +1 -0
- airflow/providers/google/cloud/example_dags/example_facebook_ads_to_gcs.py +1 -0
- airflow/providers/google/cloud/example_dags/example_looker.py +1 -0
- airflow/providers/google/cloud/example_dags/example_presto_to_gcs.py +1 -0
- airflow/providers/google/cloud/example_dags/example_salesforce_to_gcs.py +1 -0
- airflow/providers/google/cloud/fs/gcs.py +1 -2
- airflow/providers/google/cloud/hooks/automl.py +1 -0
- airflow/providers/google/cloud/hooks/bigquery.py +87 -24
- airflow/providers/google/cloud/hooks/bigquery_dts.py +1 -0
- airflow/providers/google/cloud/hooks/bigtable.py +1 -0
- airflow/providers/google/cloud/hooks/cloud_build.py +1 -0
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +1 -0
- airflow/providers/google/cloud/hooks/cloud_sql.py +1 -0
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +9 -4
- airflow/providers/google/cloud/hooks/compute.py +1 -0
- airflow/providers/google/cloud/hooks/compute_ssh.py +2 -2
- airflow/providers/google/cloud/hooks/dataflow.py +6 -5
- airflow/providers/google/cloud/hooks/datafusion.py +1 -0
- airflow/providers/google/cloud/hooks/datapipeline.py +1 -0
- airflow/providers/google/cloud/hooks/dataplex.py +1 -0
- airflow/providers/google/cloud/hooks/dataprep.py +1 -0
- airflow/providers/google/cloud/hooks/dataproc.py +3 -2
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +1 -0
- airflow/providers/google/cloud/hooks/datastore.py +1 -0
- airflow/providers/google/cloud/hooks/dlp.py +1 -0
- airflow/providers/google/cloud/hooks/functions.py +1 -0
- airflow/providers/google/cloud/hooks/gcs.py +12 -5
- airflow/providers/google/cloud/hooks/kms.py +1 -0
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +178 -300
- airflow/providers/google/cloud/hooks/life_sciences.py +1 -0
- airflow/providers/google/cloud/hooks/looker.py +1 -0
- airflow/providers/google/cloud/hooks/mlengine.py +1 -0
- airflow/providers/google/cloud/hooks/natural_language.py +1 -0
- airflow/providers/google/cloud/hooks/os_login.py +1 -0
- airflow/providers/google/cloud/hooks/pubsub.py +1 -0
- airflow/providers/google/cloud/hooks/secret_manager.py +1 -0
- airflow/providers/google/cloud/hooks/spanner.py +1 -0
- airflow/providers/google/cloud/hooks/speech_to_text.py +1 -0
- airflow/providers/google/cloud/hooks/stackdriver.py +1 -0
- airflow/providers/google/cloud/hooks/text_to_speech.py +1 -0
- airflow/providers/google/cloud/hooks/translate.py +1 -0
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +1 -0
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +255 -3
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +1 -0
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +1 -0
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +1 -0
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +197 -0
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +9 -9
- airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +231 -12
- airflow/providers/google/cloud/hooks/video_intelligence.py +1 -0
- airflow/providers/google/cloud/hooks/vision.py +1 -0
- airflow/providers/google/cloud/links/automl.py +1 -0
- airflow/providers/google/cloud/links/bigquery.py +1 -0
- airflow/providers/google/cloud/links/bigquery_dts.py +1 -0
- airflow/providers/google/cloud/links/cloud_memorystore.py +1 -0
- airflow/providers/google/cloud/links/cloud_sql.py +1 -0
- airflow/providers/google/cloud/links/cloud_tasks.py +1 -0
- airflow/providers/google/cloud/links/compute.py +1 -0
- airflow/providers/google/cloud/links/datacatalog.py +1 -0
- airflow/providers/google/cloud/links/dataflow.py +1 -0
- airflow/providers/google/cloud/links/dataform.py +1 -0
- airflow/providers/google/cloud/links/datafusion.py +1 -0
- airflow/providers/google/cloud/links/dataplex.py +1 -0
- airflow/providers/google/cloud/links/dataproc.py +1 -0
- airflow/providers/google/cloud/links/kubernetes_engine.py +28 -0
- airflow/providers/google/cloud/links/mlengine.py +1 -0
- airflow/providers/google/cloud/links/pubsub.py +1 -0
- airflow/providers/google/cloud/links/spanner.py +1 -0
- airflow/providers/google/cloud/links/stackdriver.py +1 -0
- airflow/providers/google/cloud/links/workflows.py +1 -0
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +18 -4
- airflow/providers/google/cloud/operators/automl.py +1 -0
- airflow/providers/google/cloud/operators/bigquery.py +21 -0
- airflow/providers/google/cloud/operators/bigquery_dts.py +1 -0
- airflow/providers/google/cloud/operators/bigtable.py +1 -0
- airflow/providers/google/cloud/operators/cloud_base.py +1 -0
- airflow/providers/google/cloud/operators/cloud_build.py +1 -0
- airflow/providers/google/cloud/operators/cloud_memorystore.py +1 -0
- airflow/providers/google/cloud/operators/cloud_sql.py +1 -0
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +11 -5
- airflow/providers/google/cloud/operators/compute.py +1 -0
- airflow/providers/google/cloud/operators/dataflow.py +1 -0
- airflow/providers/google/cloud/operators/datafusion.py +1 -0
- airflow/providers/google/cloud/operators/datapipeline.py +1 -0
- airflow/providers/google/cloud/operators/dataprep.py +1 -0
- airflow/providers/google/cloud/operators/dataproc.py +3 -2
- airflow/providers/google/cloud/operators/dataproc_metastore.py +1 -0
- airflow/providers/google/cloud/operators/datastore.py +1 -0
- airflow/providers/google/cloud/operators/functions.py +1 -0
- airflow/providers/google/cloud/operators/gcs.py +1 -0
- airflow/providers/google/cloud/operators/kubernetes_engine.py +600 -4
- airflow/providers/google/cloud/operators/life_sciences.py +1 -0
- airflow/providers/google/cloud/operators/looker.py +1 -0
- airflow/providers/google/cloud/operators/mlengine.py +283 -259
- airflow/providers/google/cloud/operators/natural_language.py +1 -0
- airflow/providers/google/cloud/operators/pubsub.py +1 -0
- airflow/providers/google/cloud/operators/spanner.py +1 -0
- airflow/providers/google/cloud/operators/speech_to_text.py +1 -0
- airflow/providers/google/cloud/operators/text_to_speech.py +1 -0
- airflow/providers/google/cloud/operators/translate.py +1 -0
- airflow/providers/google/cloud/operators/translate_speech.py +1 -0
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +14 -7
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +67 -13
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +26 -8
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +1 -0
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +306 -0
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +29 -48
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +52 -17
- airflow/providers/google/cloud/operators/video_intelligence.py +1 -0
- airflow/providers/google/cloud/operators/vision.py +1 -0
- airflow/providers/google/cloud/secrets/secret_manager.py +1 -0
- airflow/providers/google/cloud/sensors/bigquery.py +1 -0
- airflow/providers/google/cloud/sensors/bigquery_dts.py +1 -0
- airflow/providers/google/cloud/sensors/bigtable.py +1 -0
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +1 -0
- airflow/providers/google/cloud/sensors/dataflow.py +1 -0
- airflow/providers/google/cloud/sensors/dataform.py +1 -0
- airflow/providers/google/cloud/sensors/datafusion.py +1 -0
- airflow/providers/google/cloud/sensors/dataplex.py +1 -0
- airflow/providers/google/cloud/sensors/dataprep.py +1 -0
- airflow/providers/google/cloud/sensors/dataproc.py +1 -0
- airflow/providers/google/cloud/sensors/gcs.py +1 -0
- airflow/providers/google/cloud/sensors/looker.py +1 -0
- airflow/providers/google/cloud/sensors/pubsub.py +1 -0
- airflow/providers/google/cloud/sensors/tasks.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_postgres.py +1 -0
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -0
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +3 -2
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +1 -0
- airflow/providers/google/cloud/transfers/local_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/mysql_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/postgres_to_gcs.py +19 -1
- airflow/providers/google/cloud/transfers/s3_to_gcs.py +3 -5
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +1 -0
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +4 -2
- airflow/providers/google/cloud/triggers/bigquery.py +4 -3
- airflow/providers/google/cloud/triggers/cloud_batch.py +1 -1
- airflow/providers/google/cloud/triggers/cloud_run.py +1 -0
- airflow/providers/google/cloud/triggers/cloud_sql.py +2 -0
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +14 -2
- airflow/providers/google/cloud/triggers/dataplex.py +1 -0
- airflow/providers/google/cloud/triggers/dataproc.py +1 -0
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +72 -2
- airflow/providers/google/cloud/triggers/mlengine.py +2 -0
- airflow/providers/google/cloud/triggers/pubsub.py +3 -3
- airflow/providers/google/cloud/triggers/vertex_ai.py +107 -15
- airflow/providers/google/cloud/utils/field_sanitizer.py +2 -1
- airflow/providers/google/cloud/utils/field_validator.py +1 -0
- airflow/providers/google/cloud/utils/helpers.py +1 -0
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +1 -0
- airflow/providers/google/cloud/utils/mlengine_prediction_summary.py +1 -0
- airflow/providers/google/cloud/utils/openlineage.py +1 -0
- airflow/providers/google/common/auth_backend/google_openid.py +1 -0
- airflow/providers/google/common/hooks/base_google.py +2 -1
- airflow/providers/google/common/hooks/discovery_api.py +1 -0
- airflow/providers/google/common/links/storage.py +1 -0
- airflow/providers/google/common/utils/id_token_credentials.py +1 -0
- airflow/providers/google/firebase/hooks/firestore.py +1 -0
- airflow/providers/google/get_provider_info.py +9 -3
- airflow/providers/google/go_module_utils.py +1 -0
- airflow/providers/google/leveldb/hooks/leveldb.py +8 -7
- airflow/providers/google/marketing_platform/example_dags/example_display_video.py +1 -0
- airflow/providers/google/marketing_platform/hooks/analytics_admin.py +1 -0
- airflow/providers/google/marketing_platform/hooks/campaign_manager.py +1 -0
- airflow/providers/google/marketing_platform/hooks/display_video.py +1 -0
- airflow/providers/google/marketing_platform/hooks/search_ads.py +1 -0
- airflow/providers/google/marketing_platform/operators/analytics.py +1 -0
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +4 -2
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +1 -0
- airflow/providers/google/marketing_platform/operators/display_video.py +1 -0
- airflow/providers/google/marketing_platform/operators/search_ads.py +1 -0
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +1 -0
- airflow/providers/google/marketing_platform/sensors/display_video.py +2 -1
- airflow/providers/google/marketing_platform/sensors/search_ads.py +1 -0
- airflow/providers/google/suite/hooks/calendar.py +1 -0
- airflow/providers/google/suite/hooks/drive.py +1 -0
- airflow/providers/google/suite/hooks/sheets.py +1 -0
- airflow/providers/google/suite/sensors/drive.py +1 -0
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +7 -0
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +4 -1
- airflow/providers/google/suite/transfers/local_to_drive.py +1 -0
- {apache_airflow_providers_google-10.16.0rc1.dist-info → apache_airflow_providers_google-10.17.0.dist-info}/METADATA +18 -13
- {apache_airflow_providers_google-10.16.0rc1.dist-info → apache_airflow_providers_google-10.17.0.dist-info}/RECORD +196 -194
- {apache_airflow_providers_google-10.16.0rc1.dist-info → apache_airflow_providers_google-10.17.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-10.16.0rc1.dist-info → apache_airflow_providers_google-10.17.0.dist-info}/entry_points.txt +0 -0
@@ -22,12 +22,14 @@ from __future__ import annotations
|
|
22
22
|
|
23
23
|
from typing import TYPE_CHECKING, Sequence
|
24
24
|
|
25
|
+
from deprecated import deprecated
|
25
26
|
from google.api_core.exceptions import NotFound
|
26
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
27
28
|
from google.cloud.aiplatform import datasets
|
28
29
|
from google.cloud.aiplatform.models import Model
|
29
30
|
from google.cloud.aiplatform_v1.types.training_pipeline import TrainingPipeline
|
30
31
|
|
32
|
+
from airflow.exceptions import AirflowProviderDeprecationWarning
|
31
33
|
from airflow.providers.google.cloud.hooks.vertex_ai.auto_ml import AutoMLHook
|
32
34
|
from airflow.providers.google.cloud.links.vertex_ai import (
|
33
35
|
VertexAIModelLink,
|
@@ -174,7 +176,6 @@ class CreateAutoMLForecastingTrainingJobOperator(AutoMLTrainingJobBaseOperator):
|
|
174
176
|
gcp_conn_id=self.gcp_conn_id,
|
175
177
|
impersonation_chain=self.impersonation_chain,
|
176
178
|
)
|
177
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
178
179
|
model, training_id = self.hook.create_auto_ml_forecasting_training_job(
|
179
180
|
project_id=self.project_id,
|
180
181
|
region=self.region,
|
@@ -282,7 +283,6 @@ class CreateAutoMLImageTrainingJobOperator(AutoMLTrainingJobBaseOperator):
|
|
282
283
|
gcp_conn_id=self.gcp_conn_id,
|
283
284
|
impersonation_chain=self.impersonation_chain,
|
284
285
|
)
|
285
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
286
286
|
model, training_id = self.hook.create_auto_ml_image_training_job(
|
287
287
|
project_id=self.project_id,
|
288
288
|
region=self.region,
|
@@ -391,7 +391,6 @@ class CreateAutoMLTabularTrainingJobOperator(AutoMLTrainingJobBaseOperator):
|
|
391
391
|
impersonation_chain=self.impersonation_chain,
|
392
392
|
)
|
393
393
|
credentials, _ = self.hook.get_credentials_and_project_id()
|
394
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
395
394
|
model, training_id = self.hook.create_auto_ml_tabular_training_job(
|
396
395
|
project_id=self.project_id,
|
397
396
|
region=self.region,
|
@@ -486,7 +485,6 @@ class CreateAutoMLTextTrainingJobOperator(AutoMLTrainingJobBaseOperator):
|
|
486
485
|
gcp_conn_id=self.gcp_conn_id,
|
487
486
|
impersonation_chain=self.impersonation_chain,
|
488
487
|
)
|
489
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
490
488
|
model, training_id = self.hook.create_auto_ml_text_training_job(
|
491
489
|
project_id=self.project_id,
|
492
490
|
region=self.region,
|
@@ -563,7 +561,6 @@ class CreateAutoMLVideoTrainingJobOperator(AutoMLTrainingJobBaseOperator):
|
|
563
561
|
gcp_conn_id=self.gcp_conn_id,
|
564
562
|
impersonation_chain=self.impersonation_chain,
|
565
563
|
)
|
566
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
567
564
|
model, training_id = self.hook.create_auto_ml_video_training_job(
|
568
565
|
project_id=self.project_id,
|
569
566
|
region=self.region,
|
@@ -607,7 +604,7 @@ class DeleteAutoMLTrainingJobOperator(GoogleCloudBaseOperator):
|
|
607
604
|
AutoMLTabularTrainingJob, AutoMLTextTrainingJob, or AutoMLVideoTrainingJob.
|
608
605
|
"""
|
609
606
|
|
610
|
-
template_fields = ("
|
607
|
+
template_fields = ("training_pipeline_id", "region", "project_id", "impersonation_chain")
|
611
608
|
|
612
609
|
def __init__(
|
613
610
|
self,
|
@@ -623,7 +620,7 @@ class DeleteAutoMLTrainingJobOperator(GoogleCloudBaseOperator):
|
|
623
620
|
**kwargs,
|
624
621
|
) -> None:
|
625
622
|
super().__init__(**kwargs)
|
626
|
-
self.
|
623
|
+
self.training_pipeline_id = training_pipeline_id
|
627
624
|
self.region = region
|
628
625
|
self.project_id = project_id
|
629
626
|
self.retry = retry
|
@@ -632,6 +629,16 @@ class DeleteAutoMLTrainingJobOperator(GoogleCloudBaseOperator):
|
|
632
629
|
self.gcp_conn_id = gcp_conn_id
|
633
630
|
self.impersonation_chain = impersonation_chain
|
634
631
|
|
632
|
+
@property
|
633
|
+
@deprecated(
|
634
|
+
reason="`training_pipeline` is deprecated and will be removed in the future. "
|
635
|
+
"Please use `training_pipeline_id` instead.",
|
636
|
+
category=AirflowProviderDeprecationWarning,
|
637
|
+
)
|
638
|
+
def training_pipeline(self):
|
639
|
+
"""Alias for ``training_pipeline_id``, used for compatibility (deprecated)."""
|
640
|
+
return self.training_pipeline_id
|
641
|
+
|
635
642
|
def execute(self, context: Context):
|
636
643
|
hook = AutoMLHook(
|
637
644
|
gcp_conn_id=self.gcp_conn_id,
|
@@ -20,22 +20,27 @@
|
|
20
20
|
|
21
21
|
from __future__ import annotations
|
22
22
|
|
23
|
-
|
23
|
+
import warnings
|
24
|
+
from functools import cached_property
|
25
|
+
from typing import TYPE_CHECKING, Any, Sequence
|
24
26
|
|
25
27
|
from google.api_core.exceptions import NotFound
|
26
28
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
27
29
|
from google.cloud.aiplatform_v1.types import BatchPredictionJob
|
28
30
|
|
31
|
+
from airflow.configuration import conf
|
32
|
+
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
|
29
33
|
from airflow.providers.google.cloud.hooks.vertex_ai.batch_prediction_job import BatchPredictionJobHook
|
30
34
|
from airflow.providers.google.cloud.links.vertex_ai import (
|
31
35
|
VertexAIBatchPredictionJobLink,
|
32
36
|
VertexAIBatchPredictionJobListLink,
|
33
37
|
)
|
34
38
|
from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
|
39
|
+
from airflow.providers.google.cloud.triggers.vertex_ai import CreateBatchPredictionJobTrigger
|
35
40
|
|
36
41
|
if TYPE_CHECKING:
|
37
42
|
from google.api_core.retry import Retry
|
38
|
-
from google.cloud.aiplatform import Model, explain
|
43
|
+
from google.cloud.aiplatform import BatchPredictionJob as BatchPredictionJobObject, Model, explain
|
39
44
|
|
40
45
|
from airflow.utils.context import Context
|
41
46
|
|
@@ -131,7 +136,7 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
|
131
136
|
If this is set, then all resources created by the BatchPredictionJob will be encrypted with the
|
132
137
|
provided encryption key.
|
133
138
|
Overrides encryption_spec_key_name set in aiplatform.init.
|
134
|
-
:param sync: Whether to execute this method synchronously. If False, this method will be executed in
|
139
|
+
:param sync: (Deprecated) Whether to execute this method synchronously. If False, this method will be executed in
|
135
140
|
concurrent Future and any downstream object will be immediately returned and synced when the
|
136
141
|
Future has completed.
|
137
142
|
:param create_request_timeout: Optional. The timeout for the create request in seconds.
|
@@ -154,6 +159,8 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
|
154
159
|
If set as a sequence, the identities from the list must grant
|
155
160
|
Service Account Token Creator IAM role to the directly preceding identity, with first
|
156
161
|
account from the list granting this role to the originating account (templated).
|
162
|
+
:param deferrable: Optional. Run operator in the deferrable mode.
|
163
|
+
:param poll_interval: Interval size which defines how often job status is checked in deferrable mode.
|
157
164
|
"""
|
158
165
|
|
159
166
|
template_fields = ("region", "project_id", "model_name", "impersonation_chain")
|
@@ -188,6 +195,8 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
|
188
195
|
batch_size: int | None = None,
|
189
196
|
gcp_conn_id: str = "google_cloud_default",
|
190
197
|
impersonation_chain: str | Sequence[str] | None = None,
|
198
|
+
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
|
199
|
+
poll_interval: int = 10,
|
191
200
|
**kwargs,
|
192
201
|
) -> None:
|
193
202
|
super().__init__(**kwargs)
|
@@ -217,15 +226,24 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
|
217
226
|
self.batch_size = batch_size
|
218
227
|
self.gcp_conn_id = gcp_conn_id
|
219
228
|
self.impersonation_chain = impersonation_chain
|
220
|
-
self.
|
229
|
+
self.deferrable = deferrable
|
230
|
+
self.poll_interval = poll_interval
|
221
231
|
|
222
|
-
|
223
|
-
|
224
|
-
|
232
|
+
@cached_property
|
233
|
+
def hook(self) -> BatchPredictionJobHook:
|
234
|
+
return BatchPredictionJobHook(
|
225
235
|
gcp_conn_id=self.gcp_conn_id,
|
226
236
|
impersonation_chain=self.impersonation_chain,
|
227
237
|
)
|
228
|
-
|
238
|
+
|
239
|
+
def execute(self, context: Context):
|
240
|
+
warnings.warn(
|
241
|
+
"The 'sync' parameter is deprecated and will be removed after 28.08.2024.",
|
242
|
+
AirflowProviderDeprecationWarning,
|
243
|
+
stacklevel=2,
|
244
|
+
)
|
245
|
+
self.log.info("Creating Batch prediction job")
|
246
|
+
batch_prediction_job: BatchPredictionJobObject = self.hook.submit_batch_prediction_job(
|
229
247
|
region=self.region,
|
230
248
|
project_id=self.project_id,
|
231
249
|
job_display_name=self.job_display_name,
|
@@ -247,26 +265,62 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
|
247
265
|
explanation_parameters=self.explanation_parameters,
|
248
266
|
labels=self.labels,
|
249
267
|
encryption_spec_key_name=self.encryption_spec_key_name,
|
250
|
-
sync=self.sync,
|
251
268
|
create_request_timeout=self.create_request_timeout,
|
252
269
|
batch_size=self.batch_size,
|
253
270
|
)
|
254
|
-
|
255
|
-
|
256
|
-
batch_prediction_job_id = self.hook.extract_batch_prediction_job_id(batch_prediction_job)
|
271
|
+
batch_prediction_job.wait_for_resource_creation()
|
272
|
+
batch_prediction_job_id = batch_prediction_job.name
|
257
273
|
self.log.info("Batch prediction job was created. Job id: %s", batch_prediction_job_id)
|
258
274
|
|
259
275
|
self.xcom_push(context, key="batch_prediction_job_id", value=batch_prediction_job_id)
|
260
276
|
VertexAIBatchPredictionJobLink.persist(
|
261
277
|
context=context, task_instance=self, batch_prediction_job_id=batch_prediction_job_id
|
262
278
|
)
|
263
|
-
|
279
|
+
|
280
|
+
if self.deferrable:
|
281
|
+
self.defer(
|
282
|
+
trigger=CreateBatchPredictionJobTrigger(
|
283
|
+
conn_id=self.gcp_conn_id,
|
284
|
+
project_id=self.project_id,
|
285
|
+
location=self.region,
|
286
|
+
job_id=batch_prediction_job.name,
|
287
|
+
poll_interval=self.poll_interval,
|
288
|
+
impersonation_chain=self.impersonation_chain,
|
289
|
+
),
|
290
|
+
method_name="execute_complete",
|
291
|
+
)
|
292
|
+
|
293
|
+
batch_prediction_job.wait_for_completion()
|
294
|
+
self.log.info("Batch prediction job was completed. Job id: %s", batch_prediction_job_id)
|
295
|
+
return batch_prediction_job.to_dict()
|
264
296
|
|
265
297
|
def on_kill(self) -> None:
|
266
298
|
"""Act as a callback called when the operator is killed; cancel any running job."""
|
267
299
|
if self.hook:
|
268
300
|
self.hook.cancel_batch_prediction_job()
|
269
301
|
|
302
|
+
def execute_complete(self, context: Context, event: dict[str, Any]) -> dict[str, Any]:
|
303
|
+
if event and event["status"] == "error":
|
304
|
+
raise AirflowException(event["message"])
|
305
|
+
job: dict[str, Any] = event["job"]
|
306
|
+
self.log.info("Batch prediction job %s created and completed successfully.", job["name"])
|
307
|
+
job_id = self.hook.extract_batch_prediction_job_id(job)
|
308
|
+
self.xcom_push(
|
309
|
+
context,
|
310
|
+
key="batch_prediction_job_id",
|
311
|
+
value=job_id,
|
312
|
+
)
|
313
|
+
self.xcom_push(
|
314
|
+
context,
|
315
|
+
key="training_conf",
|
316
|
+
value={
|
317
|
+
"training_conf_id": job_id,
|
318
|
+
"region": self.region,
|
319
|
+
"project_id": self.project_id,
|
320
|
+
},
|
321
|
+
)
|
322
|
+
return event["job"]
|
323
|
+
|
270
324
|
|
271
325
|
class DeleteBatchPredictionJobOperator(GoogleCloudBaseOperator):
|
272
326
|
"""
|
@@ -16,16 +16,19 @@
|
|
16
16
|
# specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
18
|
"""This module contains Google Vertex AI operators."""
|
19
|
+
|
19
20
|
from __future__ import annotations
|
20
21
|
|
21
22
|
from typing import TYPE_CHECKING, Sequence
|
22
23
|
|
24
|
+
from deprecated import deprecated
|
23
25
|
from google.api_core.exceptions import NotFound
|
24
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
25
27
|
from google.cloud.aiplatform.models import Model
|
26
28
|
from google.cloud.aiplatform_v1.types.dataset import Dataset
|
27
29
|
from google.cloud.aiplatform_v1.types.training_pipeline import TrainingPipeline
|
28
30
|
|
31
|
+
from airflow.exceptions import AirflowProviderDeprecationWarning
|
29
32
|
from airflow.providers.google.cloud.hooks.vertex_ai.custom_job import CustomJobHook
|
30
33
|
from airflow.providers.google.cloud.links.vertex_ai import (
|
31
34
|
VertexAIModelLink,
|
@@ -465,8 +468,6 @@ class CreateCustomContainerTrainingJobOperator(CustomTrainingJobBaseOperator):
|
|
465
468
|
gcp_conn_id=self.gcp_conn_id,
|
466
469
|
impersonation_chain=self.impersonation_chain,
|
467
470
|
)
|
468
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
469
|
-
|
470
471
|
model, training_id, custom_job_id = self.hook.create_custom_container_training_job(
|
471
472
|
project_id=self.project_id,
|
472
473
|
region=self.region,
|
@@ -847,7 +848,6 @@ class CreateCustomPythonPackageTrainingJobOperator(CustomTrainingJobBaseOperator
|
|
847
848
|
gcp_conn_id=self.gcp_conn_id,
|
848
849
|
impersonation_chain=self.impersonation_chain,
|
849
850
|
)
|
850
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
851
851
|
model, training_id, custom_job_id = self.hook.create_custom_python_package_training_job(
|
852
852
|
project_id=self.project_id,
|
853
853
|
region=self.region,
|
@@ -1231,8 +1231,6 @@ class CreateCustomTrainingJobOperator(CustomTrainingJobBaseOperator):
|
|
1231
1231
|
gcp_conn_id=self.gcp_conn_id,
|
1232
1232
|
impersonation_chain=self.impersonation_chain,
|
1233
1233
|
)
|
1234
|
-
self.parent_model = self.parent_model.rpartition("@")[0] if self.parent_model else None
|
1235
|
-
|
1236
1234
|
model, training_id, custom_job_id = self.hook.create_custom_training_job(
|
1237
1235
|
project_id=self.project_id,
|
1238
1236
|
region=self.region,
|
@@ -1328,7 +1326,7 @@ class DeleteCustomTrainingJobOperator(GoogleCloudBaseOperator):
|
|
1328
1326
|
account from the list granting this role to the originating account (templated).
|
1329
1327
|
"""
|
1330
1328
|
|
1331
|
-
template_fields = ("
|
1329
|
+
template_fields = ("training_pipeline_id", "custom_job_id", "region", "project_id", "impersonation_chain")
|
1332
1330
|
|
1333
1331
|
def __init__(
|
1334
1332
|
self,
|
@@ -1345,8 +1343,8 @@ class DeleteCustomTrainingJobOperator(GoogleCloudBaseOperator):
|
|
1345
1343
|
**kwargs,
|
1346
1344
|
) -> None:
|
1347
1345
|
super().__init__(**kwargs)
|
1348
|
-
self.
|
1349
|
-
self.
|
1346
|
+
self.training_pipeline_id = training_pipeline_id
|
1347
|
+
self.custom_job_id = custom_job_id
|
1350
1348
|
self.region = region
|
1351
1349
|
self.project_id = project_id
|
1352
1350
|
self.retry = retry
|
@@ -1355,6 +1353,26 @@ class DeleteCustomTrainingJobOperator(GoogleCloudBaseOperator):
|
|
1355
1353
|
self.gcp_conn_id = gcp_conn_id
|
1356
1354
|
self.impersonation_chain = impersonation_chain
|
1357
1355
|
|
1356
|
+
@property
|
1357
|
+
@deprecated(
|
1358
|
+
reason="`training_pipeline` is deprecated and will be removed in the future. "
|
1359
|
+
"Please use `training_pipeline_id` instead.",
|
1360
|
+
category=AirflowProviderDeprecationWarning,
|
1361
|
+
)
|
1362
|
+
def training_pipeline(self):
|
1363
|
+
"""Alias for ``training_pipeline_id``, used for compatibility (deprecated)."""
|
1364
|
+
return self.training_pipeline_id
|
1365
|
+
|
1366
|
+
@property
|
1367
|
+
@deprecated(
|
1368
|
+
reason="`custom_job` is deprecated and will be removed in the future. "
|
1369
|
+
"Please use `custom_job_id` instead.",
|
1370
|
+
category=AirflowProviderDeprecationWarning,
|
1371
|
+
)
|
1372
|
+
def custom_job(self):
|
1373
|
+
"""Alias for ``custom_job_id``, used for compatibility (deprecated)."""
|
1374
|
+
return self.custom_job_id
|
1375
|
+
|
1358
1376
|
def execute(self, context: Context):
|
1359
1377
|
hook = CustomJobHook(
|
1360
1378
|
gcp_conn_id=self.gcp_conn_id,
|