apache-airflow-providers-google 10.17.0rc1__py3-none-any.whl → 10.18.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.
Files changed (91) hide show
  1. airflow/providers/google/__init__.py +5 -8
  2. airflow/providers/google/cloud/hooks/automl.py +35 -1
  3. airflow/providers/google/cloud/hooks/bigquery.py +126 -41
  4. airflow/providers/google/cloud/hooks/cloud_composer.py +250 -2
  5. airflow/providers/google/cloud/hooks/cloud_sql.py +154 -7
  6. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +7 -2
  7. airflow/providers/google/cloud/hooks/compute_ssh.py +2 -1
  8. airflow/providers/google/cloud/hooks/dataflow.py +246 -32
  9. airflow/providers/google/cloud/hooks/dataplex.py +6 -2
  10. airflow/providers/google/cloud/hooks/dlp.py +14 -14
  11. airflow/providers/google/cloud/hooks/gcs.py +6 -2
  12. airflow/providers/google/cloud/hooks/gdm.py +2 -2
  13. airflow/providers/google/cloud/hooks/kubernetes_engine.py +2 -2
  14. airflow/providers/google/cloud/hooks/mlengine.py +8 -4
  15. airflow/providers/google/cloud/hooks/pubsub.py +1 -1
  16. airflow/providers/google/cloud/hooks/secret_manager.py +252 -4
  17. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +1431 -74
  18. airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +91 -0
  19. airflow/providers/google/cloud/links/vertex_ai.py +2 -1
  20. airflow/providers/google/cloud/log/gcs_task_handler.py +2 -1
  21. airflow/providers/google/cloud/operators/automl.py +243 -37
  22. airflow/providers/google/cloud/operators/bigquery.py +164 -62
  23. airflow/providers/google/cloud/operators/bigquery_dts.py +4 -3
  24. airflow/providers/google/cloud/operators/bigtable.py +7 -6
  25. airflow/providers/google/cloud/operators/cloud_build.py +12 -11
  26. airflow/providers/google/cloud/operators/cloud_composer.py +147 -2
  27. airflow/providers/google/cloud/operators/cloud_memorystore.py +17 -16
  28. airflow/providers/google/cloud/operators/cloud_sql.py +60 -17
  29. airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +35 -16
  30. airflow/providers/google/cloud/operators/compute.py +12 -11
  31. airflow/providers/google/cloud/operators/datacatalog.py +21 -20
  32. airflow/providers/google/cloud/operators/dataflow.py +59 -42
  33. airflow/providers/google/cloud/operators/datafusion.py +11 -10
  34. airflow/providers/google/cloud/operators/datapipeline.py +3 -2
  35. airflow/providers/google/cloud/operators/dataprep.py +5 -4
  36. airflow/providers/google/cloud/operators/dataproc.py +20 -17
  37. airflow/providers/google/cloud/operators/datastore.py +8 -7
  38. airflow/providers/google/cloud/operators/dlp.py +31 -30
  39. airflow/providers/google/cloud/operators/functions.py +4 -3
  40. airflow/providers/google/cloud/operators/gcs.py +66 -41
  41. airflow/providers/google/cloud/operators/kubernetes_engine.py +256 -49
  42. airflow/providers/google/cloud/operators/life_sciences.py +2 -1
  43. airflow/providers/google/cloud/operators/mlengine.py +11 -10
  44. airflow/providers/google/cloud/operators/pubsub.py +6 -5
  45. airflow/providers/google/cloud/operators/spanner.py +7 -6
  46. airflow/providers/google/cloud/operators/speech_to_text.py +2 -1
  47. airflow/providers/google/cloud/operators/stackdriver.py +11 -10
  48. airflow/providers/google/cloud/operators/tasks.py +14 -13
  49. airflow/providers/google/cloud/operators/text_to_speech.py +2 -1
  50. airflow/providers/google/cloud/operators/translate_speech.py +2 -1
  51. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +333 -26
  52. airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +20 -12
  53. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +0 -1
  54. airflow/providers/google/cloud/operators/vision.py +13 -12
  55. airflow/providers/google/cloud/operators/workflows.py +12 -14
  56. airflow/providers/google/cloud/secrets/secret_manager.py +2 -1
  57. airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
  58. airflow/providers/google/cloud/sensors/bigtable.py +2 -1
  59. airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -1
  60. airflow/providers/google/cloud/sensors/dataflow.py +239 -52
  61. airflow/providers/google/cloud/sensors/datafusion.py +2 -1
  62. airflow/providers/google/cloud/sensors/dataproc.py +3 -2
  63. airflow/providers/google/cloud/sensors/gcs.py +14 -12
  64. airflow/providers/google/cloud/sensors/tasks.py +2 -1
  65. airflow/providers/google/cloud/sensors/workflows.py +2 -1
  66. airflow/providers/google/cloud/transfers/adls_to_gcs.py +8 -2
  67. airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +7 -1
  68. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +7 -1
  69. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +2 -1
  70. airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +1 -1
  71. airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -0
  72. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +5 -6
  73. airflow/providers/google/cloud/transfers/gcs_to_gcs.py +22 -12
  74. airflow/providers/google/cloud/triggers/bigquery.py +75 -6
  75. airflow/providers/google/cloud/triggers/cloud_composer.py +68 -0
  76. airflow/providers/google/cloud/triggers/cloud_sql.py +2 -1
  77. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +2 -1
  78. airflow/providers/google/cloud/triggers/dataflow.py +504 -4
  79. airflow/providers/google/cloud/triggers/dataproc.py +190 -27
  80. airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -3
  81. airflow/providers/google/cloud/triggers/mlengine.py +2 -1
  82. airflow/providers/google/cloud/triggers/vertex_ai.py +94 -0
  83. airflow/providers/google/common/hooks/base_google.py +45 -7
  84. airflow/providers/google/firebase/hooks/firestore.py +2 -2
  85. airflow/providers/google/firebase/operators/firestore.py +2 -1
  86. airflow/providers/google/get_provider_info.py +5 -3
  87. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/METADATA +18 -18
  88. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/RECORD +90 -90
  89. airflow/providers/google/cloud/example_dags/example_cloud_sql_query.py +0 -289
  90. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/WHEEL +0 -0
  91. {apache_airflow_providers_google-10.17.0rc1.dist-info → apache_airflow_providers_google-10.18.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,91 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from __future__ import annotations
19
+
20
+ from typing import TYPE_CHECKING, Sequence
21
+
22
+ from google.api_core.client_options import ClientOptions
23
+ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
24
+ from google.cloud.aiplatform_v1 import PredictionServiceClient
25
+
26
+ from airflow.providers.google.common.consts import CLIENT_INFO
27
+ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
28
+
29
+ if TYPE_CHECKING:
30
+ from google.api_core.retry import Retry
31
+ from google.cloud.aiplatform_v1.types import PredictResponse
32
+
33
+
34
+ class PredictionServiceHook(GoogleBaseHook):
35
+ """Hook for Google Cloud Vertex AI Prediction API."""
36
+
37
+ def get_prediction_service_client(self, region: str | None = None) -> PredictionServiceClient:
38
+ """
39
+ Return PredictionServiceClient object.
40
+
41
+ :param region: The ID of the Google Cloud region that the service belongs to. Default is None.
42
+
43
+ :return: `google.cloud.aiplatform_v1.services.prediction_service.client.PredictionServiceClient` instance.
44
+ """
45
+ if region and region != "global":
46
+ client_options = ClientOptions(api_endpoint=f"{region}-aiplatform.googleapis.com:443")
47
+ else:
48
+ client_options = ClientOptions()
49
+
50
+ return PredictionServiceClient(
51
+ credentials=self.get_credentials(), client_info=CLIENT_INFO, client_options=client_options
52
+ )
53
+
54
+ @GoogleBaseHook.fallback_to_default_project_id
55
+ def predict(
56
+ self,
57
+ endpoint_id: str,
58
+ instances: list[str],
59
+ location: str,
60
+ project_id: str = PROVIDE_PROJECT_ID,
61
+ parameters: dict[str, str] | None = None,
62
+ retry: Retry | _MethodDefault = DEFAULT,
63
+ timeout: float | None = None,
64
+ metadata: Sequence[tuple[str, str]] = (),
65
+ ) -> PredictResponse:
66
+ """
67
+ Perform an online prediction and returns the prediction result in the response.
68
+
69
+ :param endpoint_id: Name of the endpoint_id requested to serve the prediction.
70
+ :param instances: Required. The instances that are the input to the prediction call. A DeployedModel
71
+ may have an upper limit on the number of instances it supports per request, and when it is
72
+ exceeded the prediction call errors in case of AutoML Models, or, in case of customer created
73
+ Models, the behaviour is as documented by that Model.
74
+ :param parameters: Additional domain-specific parameters, any string must be up to 25000 characters long.
75
+ :param project_id: ID of the Google Cloud project where model is located if None then
76
+ default project_id is used.
77
+ :param location: The location of the project.
78
+ :param retry: A retry object used to retry requests. If `None` is specified, requests will not be
79
+ retried.
80
+ :param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
81
+ `retry` is specified, the timeout applies to each individual attempt.
82
+ :param metadata: Additional metadata that is provided to the method.
83
+ """
84
+ client = self.get_prediction_service_client(location)
85
+ endpoint = f"projects/{project_id}/locations/{location}/endpoints/{endpoint_id}"
86
+ return client.predict(
87
+ request={"endpoint": endpoint, "instances": instances, "parameters": parameters},
88
+ retry=retry,
89
+ timeout=timeout,
90
+ metadata=metadata,
91
+ )
@@ -25,7 +25,8 @@ if TYPE_CHECKING:
25
25
 
26
26
  VERTEX_AI_BASE_LINK = "/vertex-ai"
27
27
  VERTEX_AI_MODEL_LINK = (
28
- VERTEX_AI_BASE_LINK + "/locations/{region}/models/{model_id}/deploy?project={project_id}"
28
+ VERTEX_AI_BASE_LINK
29
+ + "/models/locations/{region}/models/{model_id}/versions/default/properties?project={project_id}"
29
30
  )
30
31
  VERTEX_AI_MODEL_LIST_LINK = VERTEX_AI_BASE_LINK + "/models?project={project_id}"
31
32
  VERTEX_AI_MODEL_EXPORT_LINK = "/storage/browser/{bucket_name}/model-{model_id}?project={project_id}"
@@ -32,6 +32,7 @@ from airflow.exceptions import AirflowNotFoundException
32
32
  from airflow.providers.google.cloud.hooks.gcs import GCSHook, _parse_gcs_url
33
33
  from airflow.providers.google.cloud.utils.credentials_provider import get_credentials_and_project_id
34
34
  from airflow.providers.google.common.consts import CLIENT_INFO
35
+ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
35
36
  from airflow.utils.log.file_task_handler import FileTaskHandler
36
37
  from airflow.utils.log.logging_mixin import LoggingMixin
37
38
 
@@ -82,7 +83,7 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin):
82
83
  gcp_key_path: str | None = None,
83
84
  gcp_keyfile_dict: dict | None = None,
84
85
  gcp_scopes: Collection[str] | None = _DEFAULT_SCOPESS,
85
- project_id: str | None = None,
86
+ project_id: str = PROVIDE_PROJECT_ID,
86
87
  **kwargs,
87
88
  ):
88
89
  super().__init__(base_log_folder, filename_template)
@@ -21,8 +21,10 @@ from __future__ import annotations
21
21
 
22
22
  import ast
23
23
  import warnings
24
+ from functools import cached_property
24
25
  from typing import TYPE_CHECKING, Sequence, Tuple
25
26
 
27
+ from deprecated import deprecated
26
28
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
27
29
  from google.cloud.automl_v1beta1 import (
28
30
  BatchPredictResult,
@@ -33,8 +35,9 @@ from google.cloud.automl_v1beta1 import (
33
35
  TableSpec,
34
36
  )
35
37
 
36
- from airflow.exceptions import AirflowProviderDeprecationWarning
38
+ from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
37
39
  from airflow.providers.google.cloud.hooks.automl import CloudAutoMLHook
40
+ from airflow.providers.google.cloud.hooks.vertex_ai.prediction_service import PredictionServiceHook
38
41
  from airflow.providers.google.cloud.links.automl import (
39
42
  AutoMLDatasetLink,
40
43
  AutoMLDatasetListLink,
@@ -43,6 +46,7 @@ from airflow.providers.google.cloud.links.automl import (
43
46
  AutoMLModelTrainLink,
44
47
  )
45
48
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
49
+ from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
46
50
 
47
51
  if TYPE_CHECKING:
48
52
  from google.api_core.retry import Retry
@@ -52,12 +56,36 @@ if TYPE_CHECKING:
52
56
  MetaData = Sequence[Tuple[str, str]]
53
57
 
54
58
 
59
+ def _raise_exception_for_deprecated_operator(
60
+ deprecated_class_name: str, alternative_class_names: str | list[str]
61
+ ):
62
+ if isinstance(alternative_class_names, str):
63
+ alternative_class_name_str = alternative_class_names
64
+ elif len(alternative_class_names) == 1:
65
+ alternative_class_name_str = alternative_class_names[0]
66
+ else:
67
+ alternative_class_name_str = ", ".join(f"`{cls_name}`" for cls_name in alternative_class_names[:-1])
68
+ alternative_class_name_str += f" or `{alternative_class_names[-1]}`"
69
+
70
+ raise AirflowException(
71
+ f"{deprecated_class_name} for text, image, and video prediction has been "
72
+ f"deprecated and no longer available. All the functionality of "
73
+ f"legacy AutoML Natural Language, Vision, Video Intelligence and Tables "
74
+ f"and new features are available on the Vertex AI platform. "
75
+ f"Please use {alternative_class_name_str} from Vertex AI."
76
+ )
77
+
78
+
55
79
  class AutoMLTrainModelOperator(GoogleCloudBaseOperator):
56
80
  """
57
81
  Creates Google Cloud AutoML model.
58
82
 
59
- AutoMLTrainModelOperator for text prediction is deprecated. Please use
60
- :class:`airflow.providers.google.cloud.operators.vertex_ai.auto_ml.CreateAutoMLTextTrainingJobOperator`
83
+ AutoMLTrainModelOperator for tables, video intelligence, vision and natural language has been deprecated
84
+ and no longer available. Please use
85
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.auto_ml.CreateAutoMLTabularTrainingJobOperator`,
86
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.auto_ml.CreateAutoMLVideoTrainingJobOperator`,
87
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.auto_ml.CreateAutoMLImageTrainingJobOperator`,
88
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.auto_ml.CreateAutoMLTextTrainingJobOperator`,
61
89
  instead.
62
90
 
63
91
  .. seealso::
@@ -100,7 +128,7 @@ class AutoMLTrainModelOperator(GoogleCloudBaseOperator):
100
128
  *,
101
129
  model: dict,
102
130
  location: str,
103
- project_id: str | None = None,
131
+ project_id: str = PROVIDE_PROJECT_ID,
104
132
  metadata: MetaData = (),
105
133
  timeout: float | None = None,
106
134
  retry: Retry | _MethodDefault = DEFAULT,
@@ -119,17 +147,16 @@ class AutoMLTrainModelOperator(GoogleCloudBaseOperator):
119
147
  self.impersonation_chain = impersonation_chain
120
148
 
121
149
  def execute(self, context: Context):
122
- # Output warning if running not AutoML Translation prediction job
150
+ # Raise exception if running not AutoML Translation prediction job
123
151
  if "translation_model_metadata" not in self.model:
124
- warnings.warn(
125
- "AutoMLTrainModelOperator for text, image and video prediction is deprecated. "
126
- "All the functionality of legacy "
127
- "AutoML Natural Language, Vision and Video Intelligence and new features are available "
128
- "on the Vertex AI platform. "
129
- "Please use `CreateAutoMLTextTrainingJobOperator`, `CreateAutoMLImageTrainingJobOperator` or"
130
- " `CreateAutoMLVideoTrainingJobOperator` from VertexAI.",
131
- AirflowProviderDeprecationWarning,
132
- stacklevel=3,
152
+ _raise_exception_for_deprecated_operator(
153
+ self.__class__.__name__,
154
+ [
155
+ "CreateAutoMLTabularTrainingJobOperator",
156
+ "CreateAutoMLVideoTrainingJobOperator",
157
+ "CreateAutoMLImageTrainingJobOperator",
158
+ "CreateAutoMLTextTrainingJobOperator",
159
+ ],
133
160
  )
134
161
  hook = CloudAutoMLHook(
135
162
  gcp_conn_id=self.gcp_conn_id,
@@ -173,7 +200,8 @@ class AutoMLPredictOperator(GoogleCloudBaseOperator):
173
200
  :ref:`howto/operator:AutoMLPredictOperator`
174
201
 
175
202
  :param model_id: Name of the model requested to serve the batch prediction.
176
- :param payload: Name od the model used for the prediction.
203
+ :param endpoint_id: Name of the endpoint used for the prediction.
204
+ :param payload: Name of the model used for the prediction.
177
205
  :param project_id: ID of the Google Cloud project where model is located if None then
178
206
  default project_id is used.
179
207
  :param location: The location of the project.
@@ -205,11 +233,13 @@ class AutoMLPredictOperator(GoogleCloudBaseOperator):
205
233
  def __init__(
206
234
  self,
207
235
  *,
208
- model_id: str,
236
+ model_id: str | None = None,
237
+ endpoint_id: str | None = None,
209
238
  location: str,
210
239
  payload: dict,
211
240
  operation_params: dict[str, str] | None = None,
212
- project_id: str | None = None,
241
+ instances: list[str] | None = None,
242
+ project_id: str = PROVIDE_PROJECT_ID,
213
243
  metadata: MetaData = (),
214
244
  timeout: float | None = None,
215
245
  retry: Retry | _MethodDefault = DEFAULT,
@@ -220,7 +250,9 @@ class AutoMLPredictOperator(GoogleCloudBaseOperator):
220
250
  super().__init__(**kwargs)
221
251
 
222
252
  self.model_id = model_id
253
+ self.endpoint_id = endpoint_id
223
254
  self.operation_params = operation_params # type: ignore
255
+ self.instances = instances
224
256
  self.location = location
225
257
  self.project_id = project_id
226
258
  self.metadata = metadata
@@ -230,23 +262,69 @@ class AutoMLPredictOperator(GoogleCloudBaseOperator):
230
262
  self.gcp_conn_id = gcp_conn_id
231
263
  self.impersonation_chain = impersonation_chain
232
264
 
233
- def execute(self, context: Context):
234
- hook = CloudAutoMLHook(
235
- gcp_conn_id=self.gcp_conn_id,
236
- impersonation_chain=self.impersonation_chain,
237
- )
238
- result = hook.predict(
265
+ @cached_property
266
+ def hook(self) -> CloudAutoMLHook | PredictionServiceHook:
267
+ if self.model_id:
268
+ return CloudAutoMLHook(
269
+ gcp_conn_id=self.gcp_conn_id,
270
+ impersonation_chain=self.impersonation_chain,
271
+ )
272
+ else: # endpoint_id defined
273
+ return PredictionServiceHook(
274
+ gcp_conn_id=self.gcp_conn_id,
275
+ impersonation_chain=self.impersonation_chain,
276
+ )
277
+
278
+ def _check_model_type(self):
279
+ hook = self.hook
280
+ model = hook.get_model(
239
281
  model_id=self.model_id,
240
- payload=self.payload,
241
282
  location=self.location,
242
283
  project_id=self.project_id,
243
- params=self.operation_params,
244
284
  retry=self.retry,
245
285
  timeout=self.timeout,
246
286
  metadata=self.metadata,
247
287
  )
288
+ if not hasattr(model, "translation_model_metadata"):
289
+ raise AirflowException(
290
+ "AutoMLPredictOperator for text, image, and video prediction has been deprecated. "
291
+ "Please use endpoint_id param instead of model_id param."
292
+ )
293
+
294
+ def execute(self, context: Context):
295
+ if self.model_id is None and self.endpoint_id is None:
296
+ raise AirflowException("You must specify model_id or endpoint_id!")
297
+
298
+ if self.model_id:
299
+ self._check_model_type()
300
+
301
+ hook = self.hook
302
+ if self.model_id:
303
+ result = hook.predict(
304
+ model_id=self.model_id,
305
+ payload=self.payload,
306
+ location=self.location,
307
+ project_id=self.project_id,
308
+ params=self.operation_params,
309
+ retry=self.retry,
310
+ timeout=self.timeout,
311
+ metadata=self.metadata,
312
+ )
313
+ else: # self.endpoint_id is defined
314
+ result = hook.predict(
315
+ endpoint_id=self.endpoint_id,
316
+ instances=self.instances,
317
+ payload=self.payload,
318
+ location=self.location,
319
+ project_id=self.project_id,
320
+ parameters=self.operation_params,
321
+ retry=self.retry,
322
+ timeout=self.timeout,
323
+ metadata=self.metadata,
324
+ )
325
+
248
326
  project_id = self.project_id or hook.project_id
249
- if project_id:
327
+ if project_id and self.model_id:
250
328
  AutoMLModelPredictLink.persist(
251
329
  context=context,
252
330
  task_instance=self,
@@ -260,6 +338,14 @@ class AutoMLBatchPredictOperator(GoogleCloudBaseOperator):
260
338
  """
261
339
  Perform a batch prediction on Google Cloud AutoML.
262
340
 
341
+ AutoMLBatchPredictOperator for tables, video intelligence, vision and natural language has been deprecated
342
+ and no longer available. Please use
343
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.batch_prediction_job.CreateBatchPredictionJobOperator`,
344
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.batch_prediction_job.GetBatchPredictionJobOperator`,
345
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.batch_prediction_job.ListBatchPredictionJobsOperator`,
346
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.batch_prediction_job.DeleteBatchPredictionJobOperator`,
347
+ instead.
348
+
263
349
  .. seealso::
264
350
  For more information on how to use this operator, take a look at the guide:
265
351
  :ref:`howto/operator:AutoMLBatchPredictOperator`
@@ -312,7 +398,7 @@ class AutoMLBatchPredictOperator(GoogleCloudBaseOperator):
312
398
  input_config: dict,
313
399
  output_config: dict,
314
400
  location: str,
315
- project_id: str | None = None,
401
+ project_id: str = PROVIDE_PROJECT_ID,
316
402
  prediction_params: dict[str, str] | None = None,
317
403
  metadata: MetaData = (),
318
404
  timeout: float | None = None,
@@ -340,6 +426,25 @@ class AutoMLBatchPredictOperator(GoogleCloudBaseOperator):
340
426
  gcp_conn_id=self.gcp_conn_id,
341
427
  impersonation_chain=self.impersonation_chain,
342
428
  )
429
+ model: Model = hook.get_model(
430
+ model_id=self.model_id,
431
+ location=self.location,
432
+ project_id=self.project_id,
433
+ retry=self.retry,
434
+ timeout=self.timeout,
435
+ metadata=self.metadata,
436
+ )
437
+
438
+ if not hasattr(model, "translation_model_metadata"):
439
+ _raise_exception_for_deprecated_operator(
440
+ self.__class__.__name__,
441
+ [
442
+ "CreateBatchPredictionJobOperator",
443
+ "GetBatchPredictionJobOperator",
444
+ "ListBatchPredictionJobsOperator",
445
+ "DeleteBatchPredictionJobOperator",
446
+ ],
447
+ )
343
448
  self.log.info("Fetch batch prediction.")
344
449
  operation = hook.batch_predict(
345
450
  model_id=self.model_id,
@@ -370,6 +475,10 @@ class AutoMLCreateDatasetOperator(GoogleCloudBaseOperator):
370
475
  """
371
476
  Creates a Google Cloud AutoML dataset.
372
477
 
478
+ AutoMLCreateDatasetOperator for tables, video intelligence, vision and natural language has been
479
+ deprecated and no longer available. Please use
480
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.dataset.CreateDatasetOperator` instead.
481
+
373
482
  .. seealso::
374
483
  For more information on how to use this operator, take a look at the guide:
375
484
  :ref:`howto/operator:AutoMLCreateDatasetOperator`
@@ -409,7 +518,7 @@ class AutoMLCreateDatasetOperator(GoogleCloudBaseOperator):
409
518
  *,
410
519
  dataset: dict,
411
520
  location: str,
412
- project_id: str | None = None,
521
+ project_id: str = PROVIDE_PROJECT_ID,
413
522
  metadata: MetaData = (),
414
523
  timeout: float | None = None,
415
524
  retry: Retry | _MethodDefault = DEFAULT,
@@ -429,6 +538,8 @@ class AutoMLCreateDatasetOperator(GoogleCloudBaseOperator):
429
538
  self.impersonation_chain = impersonation_chain
430
539
 
431
540
  def execute(self, context: Context):
541
+ if "translation_dataset_metadata" not in self.dataset:
542
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "CreateDatasetOperator")
432
543
  hook = CloudAutoMLHook(
433
544
  gcp_conn_id=self.gcp_conn_id,
434
545
  impersonation_chain=self.impersonation_chain,
@@ -462,6 +573,10 @@ class AutoMLImportDataOperator(GoogleCloudBaseOperator):
462
573
  """
463
574
  Imports data to a Google Cloud AutoML dataset.
464
575
 
576
+ AutoMLImportDataOperator for tables, video intelligence, vision and natural language has been deprecated
577
+ and no longer available. Please use
578
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.dataset.ImportDataOperator` instead.
579
+
465
580
  .. seealso::
466
581
  For more information on how to use this operator, take a look at the guide:
467
582
  :ref:`howto/operator:AutoMLImportDataOperator`
@@ -504,7 +619,7 @@ class AutoMLImportDataOperator(GoogleCloudBaseOperator):
504
619
  dataset_id: str,
505
620
  location: str,
506
621
  input_config: dict,
507
- project_id: str | None = None,
622
+ project_id: str = PROVIDE_PROJECT_ID,
508
623
  metadata: MetaData = (),
509
624
  timeout: float | None = None,
510
625
  retry: Retry | _MethodDefault = DEFAULT,
@@ -529,6 +644,16 @@ class AutoMLImportDataOperator(GoogleCloudBaseOperator):
529
644
  gcp_conn_id=self.gcp_conn_id,
530
645
  impersonation_chain=self.impersonation_chain,
531
646
  )
647
+ dataset: Dataset = hook.get_dataset(
648
+ dataset_id=self.dataset_id,
649
+ location=self.location,
650
+ project_id=self.project_id,
651
+ retry=self.retry,
652
+ timeout=self.timeout,
653
+ metadata=self.metadata,
654
+ )
655
+ if not hasattr(dataset, "translation_dataset_metadata"):
656
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "ImportDataOperator")
532
657
  self.log.info("Importing data to dataset...")
533
658
  operation = hook.import_data(
534
659
  dataset_id=self.dataset_id,
@@ -608,7 +733,7 @@ class AutoMLTablesListColumnSpecsOperator(GoogleCloudBaseOperator):
608
733
  field_mask: dict | None = None,
609
734
  filter_: str | None = None,
610
735
  page_size: int | None = None,
611
- project_id: str | None = None,
736
+ project_id: str = PROVIDE_PROJECT_ID,
612
737
  metadata: MetaData = (),
613
738
  timeout: float | None = None,
614
739
  retry: Retry | _MethodDefault = DEFAULT,
@@ -661,10 +786,22 @@ class AutoMLTablesListColumnSpecsOperator(GoogleCloudBaseOperator):
661
786
  return result
662
787
 
663
788
 
789
+ @deprecated(
790
+ reason=(
791
+ "Class `AutoMLTablesUpdateDatasetOperator` has been deprecated and no longer available. "
792
+ "Please use `UpdateDatasetOperator` instead"
793
+ ),
794
+ category=AirflowProviderDeprecationWarning,
795
+ action="error",
796
+ )
664
797
  class AutoMLTablesUpdateDatasetOperator(GoogleCloudBaseOperator):
665
798
  """
666
799
  Updates a dataset.
667
800
 
801
+ AutoMLTablesUpdateDatasetOperator has been deprecated and no longer available. Please use
802
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.dataset.UpdateDatasetOperator`
803
+ instead.
804
+
668
805
  .. seealso::
669
806
  For more information on how to use this operator, take a look at the guide:
670
807
  :ref:`howto/operator:AutoMLTablesUpdateDatasetOperator`
@@ -752,6 +889,10 @@ class AutoMLGetModelOperator(GoogleCloudBaseOperator):
752
889
  """
753
890
  Get Google Cloud AutoML model.
754
891
 
892
+ AutoMLGetModelOperator for tables, video intelligence, vision and natural language has been deprecated
893
+ and no longer available. Please use
894
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.model_service.GetModelOperator` instead.
895
+
755
896
  .. seealso::
756
897
  For more information on how to use this operator, take a look at the guide:
757
898
  :ref:`howto/operator:AutoMLGetModelOperator`
@@ -790,7 +931,7 @@ class AutoMLGetModelOperator(GoogleCloudBaseOperator):
790
931
  *,
791
932
  model_id: str,
792
933
  location: str,
793
- project_id: str | None = None,
934
+ project_id: str = PROVIDE_PROJECT_ID,
794
935
  metadata: MetaData = (),
795
936
  timeout: float | None = None,
796
937
  retry: Retry | _MethodDefault = DEFAULT,
@@ -822,6 +963,8 @@ class AutoMLGetModelOperator(GoogleCloudBaseOperator):
822
963
  timeout=self.timeout,
823
964
  metadata=self.metadata,
824
965
  )
966
+ if not hasattr(result, "translation_model_metadata"):
967
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "GetModelOperator")
825
968
  model = Model.to_dict(result)
826
969
  project_id = self.project_id or hook.project_id
827
970
  if project_id:
@@ -839,6 +982,10 @@ class AutoMLDeleteModelOperator(GoogleCloudBaseOperator):
839
982
  """
840
983
  Delete Google Cloud AutoML model.
841
984
 
985
+ AutoMLDeleteModelOperator for tables, video intelligence, vision and natural language has been deprecated
986
+ and no longer available. Please use
987
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.model_service.DeleteModelOperator` instead.
988
+
842
989
  .. seealso::
843
990
  For more information on how to use this operator, take a look at the guide:
844
991
  :ref:`howto/operator:AutoMLDeleteModelOperator`
@@ -876,7 +1023,7 @@ class AutoMLDeleteModelOperator(GoogleCloudBaseOperator):
876
1023
  *,
877
1024
  model_id: str,
878
1025
  location: str,
879
- project_id: str | None = None,
1026
+ project_id: str = PROVIDE_PROJECT_ID,
880
1027
  metadata: MetaData = (),
881
1028
  timeout: float | None = None,
882
1029
  retry: Retry | _MethodDefault = DEFAULT,
@@ -900,6 +1047,16 @@ class AutoMLDeleteModelOperator(GoogleCloudBaseOperator):
900
1047
  gcp_conn_id=self.gcp_conn_id,
901
1048
  impersonation_chain=self.impersonation_chain,
902
1049
  )
1050
+ model: Model = hook.get_model(
1051
+ model_id=self.model_id,
1052
+ location=self.location,
1053
+ project_id=self.project_id,
1054
+ retry=self.retry,
1055
+ timeout=self.timeout,
1056
+ metadata=self.metadata,
1057
+ )
1058
+ if not hasattr(model, "translation_model_metadata"):
1059
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "DeleteModelOperator")
903
1060
  operation = hook.delete_model(
904
1061
  model_id=self.model_id,
905
1062
  location=self.location,
@@ -912,6 +1069,14 @@ class AutoMLDeleteModelOperator(GoogleCloudBaseOperator):
912
1069
  self.log.info("Deletion is completed")
913
1070
 
914
1071
 
1072
+ @deprecated(
1073
+ reason=(
1074
+ "Class `AutoMLDeployModelOperator` has been deprecated and no longer available. Please use "
1075
+ "`DeployModelOperator` instead"
1076
+ ),
1077
+ category=AirflowProviderDeprecationWarning,
1078
+ action="error",
1079
+ )
915
1080
  class AutoMLDeployModelOperator(GoogleCloudBaseOperator):
916
1081
  """
917
1082
  Deploys a model; if a model is already deployed, deploying it with the same parameters has no effect.
@@ -922,6 +1087,10 @@ class AutoMLDeployModelOperator(GoogleCloudBaseOperator):
922
1087
  Only applicable for Text Classification, Image Object Detection and Tables; all other
923
1088
  domains manage deployment automatically.
924
1089
 
1090
+ AutoMLDeployModelOperator has been deprecated and no longer available. Please use
1091
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.endpoint_service.DeployModelOperator`
1092
+ instead.
1093
+
925
1094
  .. seealso::
926
1095
  For more information on how to use this operator, take a look at the guide:
927
1096
  :ref:`howto/operator:AutoMLDeployModelOperator`
@@ -962,7 +1131,7 @@ class AutoMLDeployModelOperator(GoogleCloudBaseOperator):
962
1131
  *,
963
1132
  model_id: str,
964
1133
  location: str,
965
- project_id: str | None = None,
1134
+ project_id: str = PROVIDE_PROJECT_ID,
966
1135
  image_detection_metadata: dict | None = None,
967
1136
  metadata: Sequence[tuple[str, str]] = (),
968
1137
  timeout: float | None = None,
@@ -988,6 +1157,16 @@ class AutoMLDeployModelOperator(GoogleCloudBaseOperator):
988
1157
  gcp_conn_id=self.gcp_conn_id,
989
1158
  impersonation_chain=self.impersonation_chain,
990
1159
  )
1160
+ model = hook.get_model(
1161
+ model_id=self.model_id,
1162
+ location=self.location,
1163
+ project_id=self.project_id,
1164
+ retry=self.retry,
1165
+ timeout=self.timeout,
1166
+ metadata=self.metadata,
1167
+ )
1168
+ if not hasattr(model, "translation_model_metadata"):
1169
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "DeployModelOperator")
991
1170
  self.log.info("Deploying model_id %s", self.model_id)
992
1171
 
993
1172
  operation = hook.deploy_model(
@@ -1053,7 +1232,7 @@ class AutoMLTablesListTableSpecsOperator(GoogleCloudBaseOperator):
1053
1232
  location: str,
1054
1233
  page_size: int | None = None,
1055
1234
  filter_: str | None = None,
1056
- project_id: str | None = None,
1235
+ project_id: str = PROVIDE_PROJECT_ID,
1057
1236
  metadata: MetaData = (),
1058
1237
  timeout: float | None = None,
1059
1238
  retry: Retry | _MethodDefault = DEFAULT,
@@ -1107,6 +1286,10 @@ class AutoMLListDatasetOperator(GoogleCloudBaseOperator):
1107
1286
  """
1108
1287
  Lists AutoML Datasets in project.
1109
1288
 
1289
+ AutoMLListDatasetOperator for tables, video intelligence, vision and natural language has been deprecated
1290
+ and no longer available. Please use
1291
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.dataset.ListDatasetsOperator` instead.
1292
+
1110
1293
  .. seealso::
1111
1294
  For more information on how to use this operator, take a look at the guide:
1112
1295
  :ref:`howto/operator:AutoMLListDatasetOperator`
@@ -1141,7 +1324,7 @@ class AutoMLListDatasetOperator(GoogleCloudBaseOperator):
1141
1324
  self,
1142
1325
  *,
1143
1326
  location: str,
1144
- project_id: str | None = None,
1327
+ project_id: str = PROVIDE_PROJECT_ID,
1145
1328
  metadata: MetaData = (),
1146
1329
  timeout: float | None = None,
1147
1330
  retry: Retry | _MethodDefault = DEFAULT,
@@ -1171,7 +1354,16 @@ class AutoMLListDatasetOperator(GoogleCloudBaseOperator):
1171
1354
  timeout=self.timeout,
1172
1355
  metadata=self.metadata,
1173
1356
  )
1174
- result = [Dataset.to_dict(dataset) for dataset in page_iterator]
1357
+ result = []
1358
+ for dataset in page_iterator:
1359
+ if not hasattr(dataset, "translation_dataset_metadata"):
1360
+ warnings.warn(
1361
+ "Class `AutoMLListDatasetOperator` has been deprecated and no longer available. "
1362
+ "Please use `ListDatasetsOperator` instead.",
1363
+ stacklevel=2,
1364
+ )
1365
+ else:
1366
+ result.append(Dataset.to_dict(dataset))
1175
1367
  self.log.info("Datasets obtained.")
1176
1368
 
1177
1369
  self.xcom_push(
@@ -1189,6 +1381,10 @@ class AutoMLDeleteDatasetOperator(GoogleCloudBaseOperator):
1189
1381
  """
1190
1382
  Deletes a dataset and all of its contents.
1191
1383
 
1384
+ AutoMLDeleteDatasetOperator for tables, video intelligence, vision and natural language has been
1385
+ deprecated and no longer available. Please use
1386
+ :class:`airflow.providers.google.cloud.operators.vertex_ai.dataset.DeleteDatasetOperator` instead.
1387
+
1192
1388
  .. seealso::
1193
1389
  For more information on how to use this operator, take a look at the guide:
1194
1390
  :ref:`howto/operator:AutoMLDeleteDatasetOperator`
@@ -1226,7 +1422,7 @@ class AutoMLDeleteDatasetOperator(GoogleCloudBaseOperator):
1226
1422
  *,
1227
1423
  dataset_id: str | list[str],
1228
1424
  location: str,
1229
- project_id: str | None = None,
1425
+ project_id: str = PROVIDE_PROJECT_ID,
1230
1426
  metadata: MetaData = (),
1231
1427
  timeout: float | None = None,
1232
1428
  retry: Retry | _MethodDefault = DEFAULT,
@@ -1259,6 +1455,16 @@ class AutoMLDeleteDatasetOperator(GoogleCloudBaseOperator):
1259
1455
  gcp_conn_id=self.gcp_conn_id,
1260
1456
  impersonation_chain=self.impersonation_chain,
1261
1457
  )
1458
+ dataset: Dataset = hook.get_dataset(
1459
+ dataset_id=self.dataset_id,
1460
+ location=self.location,
1461
+ project_id=self.project_id,
1462
+ retry=self.retry,
1463
+ timeout=self.timeout,
1464
+ metadata=self.metadata,
1465
+ )
1466
+ if not hasattr(dataset, "translation_dataset_metadata"):
1467
+ _raise_exception_for_deprecated_operator(self.__class__.__name__, "DeleteDatasetOperator")
1262
1468
  dataset_id_list = self._parse_dataset_id(self.dataset_id)
1263
1469
  for dataset_id in dataset_id_list:
1264
1470
  self.log.info("Deleting dataset %s", dataset_id)