apache-airflow-providers-google 15.1.0rc1__py3-none-any.whl → 19.3.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 (257) hide show
  1. airflow/providers/google/3rd-party-licenses/NOTICE +2 -12
  2. airflow/providers/google/__init__.py +3 -3
  3. airflow/providers/google/ads/hooks/ads.py +39 -6
  4. airflow/providers/google/ads/operators/ads.py +2 -2
  5. airflow/providers/google/ads/transfers/ads_to_gcs.py +2 -2
  6. airflow/providers/google/assets/gcs.py +1 -11
  7. airflow/providers/google/cloud/bundles/__init__.py +16 -0
  8. airflow/providers/google/cloud/bundles/gcs.py +161 -0
  9. airflow/providers/google/cloud/hooks/alloy_db.py +1 -1
  10. airflow/providers/google/cloud/hooks/bigquery.py +176 -293
  11. airflow/providers/google/cloud/hooks/cloud_batch.py +1 -1
  12. airflow/providers/google/cloud/hooks/cloud_build.py +1 -1
  13. airflow/providers/google/cloud/hooks/cloud_composer.py +288 -15
  14. airflow/providers/google/cloud/hooks/cloud_logging.py +109 -0
  15. airflow/providers/google/cloud/hooks/cloud_memorystore.py +1 -1
  16. airflow/providers/google/cloud/hooks/cloud_run.py +18 -10
  17. airflow/providers/google/cloud/hooks/cloud_sql.py +102 -23
  18. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +29 -7
  19. airflow/providers/google/cloud/hooks/compute.py +1 -1
  20. airflow/providers/google/cloud/hooks/compute_ssh.py +6 -2
  21. airflow/providers/google/cloud/hooks/datacatalog.py +10 -1
  22. airflow/providers/google/cloud/hooks/dataflow.py +72 -95
  23. airflow/providers/google/cloud/hooks/dataform.py +1 -1
  24. airflow/providers/google/cloud/hooks/datafusion.py +21 -19
  25. airflow/providers/google/cloud/hooks/dataplex.py +2 -2
  26. airflow/providers/google/cloud/hooks/dataprep.py +1 -1
  27. airflow/providers/google/cloud/hooks/dataproc.py +73 -72
  28. airflow/providers/google/cloud/hooks/dataproc_metastore.py +1 -1
  29. airflow/providers/google/cloud/hooks/dlp.py +1 -1
  30. airflow/providers/google/cloud/hooks/functions.py +1 -1
  31. airflow/providers/google/cloud/hooks/gcs.py +112 -15
  32. airflow/providers/google/cloud/hooks/gdm.py +1 -1
  33. airflow/providers/google/cloud/hooks/gen_ai.py +196 -0
  34. airflow/providers/google/cloud/hooks/kubernetes_engine.py +3 -3
  35. airflow/providers/google/cloud/hooks/looker.py +6 -2
  36. airflow/providers/google/cloud/hooks/managed_kafka.py +1 -1
  37. airflow/providers/google/cloud/hooks/mlengine.py +4 -3
  38. airflow/providers/google/cloud/hooks/pubsub.py +3 -0
  39. airflow/providers/google/cloud/hooks/secret_manager.py +102 -10
  40. airflow/providers/google/cloud/hooks/spanner.py +74 -9
  41. airflow/providers/google/cloud/hooks/stackdriver.py +11 -9
  42. airflow/providers/google/cloud/hooks/tasks.py +1 -1
  43. airflow/providers/google/cloud/hooks/translate.py +2 -2
  44. airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +2 -210
  45. airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +3 -3
  46. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +28 -2
  47. airflow/providers/google/cloud/hooks/vertex_ai/experiment_service.py +202 -0
  48. airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +308 -8
  49. airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +79 -75
  50. airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +1 -1
  51. airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +1 -1
  52. airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +1 -1
  53. airflow/providers/google/cloud/hooks/vertex_ai/ray.py +223 -0
  54. airflow/providers/google/cloud/hooks/vision.py +3 -3
  55. airflow/providers/google/cloud/hooks/workflows.py +1 -1
  56. airflow/providers/google/cloud/links/alloy_db.py +0 -46
  57. airflow/providers/google/cloud/links/base.py +77 -13
  58. airflow/providers/google/cloud/links/bigquery.py +0 -47
  59. airflow/providers/google/cloud/links/bigquery_dts.py +0 -20
  60. airflow/providers/google/cloud/links/bigtable.py +0 -48
  61. airflow/providers/google/cloud/links/cloud_build.py +0 -73
  62. airflow/providers/google/cloud/links/cloud_functions.py +0 -33
  63. airflow/providers/google/cloud/links/cloud_memorystore.py +0 -58
  64. airflow/providers/google/cloud/links/{life_sciences.py → cloud_run.py} +5 -27
  65. airflow/providers/google/cloud/links/cloud_sql.py +0 -33
  66. airflow/providers/google/cloud/links/cloud_storage_transfer.py +17 -44
  67. airflow/providers/google/cloud/links/cloud_tasks.py +7 -26
  68. airflow/providers/google/cloud/links/compute.py +0 -58
  69. airflow/providers/google/cloud/links/data_loss_prevention.py +0 -169
  70. airflow/providers/google/cloud/links/datacatalog.py +23 -54
  71. airflow/providers/google/cloud/links/dataflow.py +0 -34
  72. airflow/providers/google/cloud/links/dataform.py +0 -64
  73. airflow/providers/google/cloud/links/datafusion.py +1 -96
  74. airflow/providers/google/cloud/links/dataplex.py +0 -154
  75. airflow/providers/google/cloud/links/dataprep.py +0 -24
  76. airflow/providers/google/cloud/links/dataproc.py +11 -95
  77. airflow/providers/google/cloud/links/datastore.py +0 -31
  78. airflow/providers/google/cloud/links/kubernetes_engine.py +9 -60
  79. airflow/providers/google/cloud/links/managed_kafka.py +0 -70
  80. airflow/providers/google/cloud/links/mlengine.py +0 -70
  81. airflow/providers/google/cloud/links/pubsub.py +0 -32
  82. airflow/providers/google/cloud/links/spanner.py +0 -33
  83. airflow/providers/google/cloud/links/stackdriver.py +0 -30
  84. airflow/providers/google/cloud/links/translate.py +17 -187
  85. airflow/providers/google/cloud/links/vertex_ai.py +28 -195
  86. airflow/providers/google/cloud/links/workflows.py +0 -52
  87. airflow/providers/google/cloud/log/gcs_task_handler.py +58 -22
  88. airflow/providers/google/cloud/log/stackdriver_task_handler.py +9 -6
  89. airflow/providers/google/cloud/openlineage/CloudStorageTransferJobFacet.json +68 -0
  90. airflow/providers/google/cloud/openlineage/CloudStorageTransferRunFacet.json +60 -0
  91. airflow/providers/google/cloud/openlineage/DataFusionRunFacet.json +32 -0
  92. airflow/providers/google/cloud/openlineage/facets.py +102 -1
  93. airflow/providers/google/cloud/openlineage/mixins.py +10 -8
  94. airflow/providers/google/cloud/openlineage/utils.py +15 -1
  95. airflow/providers/google/cloud/operators/alloy_db.py +71 -56
  96. airflow/providers/google/cloud/operators/bigquery.py +73 -636
  97. airflow/providers/google/cloud/operators/bigquery_dts.py +4 -6
  98. airflow/providers/google/cloud/operators/bigtable.py +37 -8
  99. airflow/providers/google/cloud/operators/cloud_base.py +21 -1
  100. airflow/providers/google/cloud/operators/cloud_batch.py +3 -3
  101. airflow/providers/google/cloud/operators/cloud_build.py +76 -33
  102. airflow/providers/google/cloud/operators/cloud_composer.py +129 -41
  103. airflow/providers/google/cloud/operators/cloud_logging_sink.py +341 -0
  104. airflow/providers/google/cloud/operators/cloud_memorystore.py +69 -43
  105. airflow/providers/google/cloud/operators/cloud_run.py +24 -6
  106. airflow/providers/google/cloud/operators/cloud_sql.py +8 -17
  107. airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +93 -12
  108. airflow/providers/google/cloud/operators/compute.py +9 -41
  109. airflow/providers/google/cloud/operators/datacatalog.py +157 -21
  110. airflow/providers/google/cloud/operators/dataflow.py +40 -16
  111. airflow/providers/google/cloud/operators/dataform.py +15 -5
  112. airflow/providers/google/cloud/operators/datafusion.py +42 -21
  113. airflow/providers/google/cloud/operators/dataplex.py +194 -110
  114. airflow/providers/google/cloud/operators/dataprep.py +1 -5
  115. airflow/providers/google/cloud/operators/dataproc.py +80 -36
  116. airflow/providers/google/cloud/operators/dataproc_metastore.py +97 -89
  117. airflow/providers/google/cloud/operators/datastore.py +23 -7
  118. airflow/providers/google/cloud/operators/dlp.py +6 -29
  119. airflow/providers/google/cloud/operators/functions.py +17 -8
  120. airflow/providers/google/cloud/operators/gcs.py +12 -9
  121. airflow/providers/google/cloud/operators/gen_ai.py +389 -0
  122. airflow/providers/google/cloud/operators/kubernetes_engine.py +62 -100
  123. airflow/providers/google/cloud/operators/looker.py +2 -2
  124. airflow/providers/google/cloud/operators/managed_kafka.py +108 -53
  125. airflow/providers/google/cloud/operators/natural_language.py +1 -1
  126. airflow/providers/google/cloud/operators/pubsub.py +68 -15
  127. airflow/providers/google/cloud/operators/spanner.py +26 -13
  128. airflow/providers/google/cloud/operators/speech_to_text.py +2 -3
  129. airflow/providers/google/cloud/operators/stackdriver.py +1 -9
  130. airflow/providers/google/cloud/operators/tasks.py +1 -12
  131. airflow/providers/google/cloud/operators/text_to_speech.py +2 -3
  132. airflow/providers/google/cloud/operators/translate.py +41 -17
  133. airflow/providers/google/cloud/operators/translate_speech.py +2 -3
  134. airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +39 -19
  135. airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +30 -10
  136. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +55 -27
  137. airflow/providers/google/cloud/operators/vertex_ai/dataset.py +70 -8
  138. airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +43 -9
  139. airflow/providers/google/cloud/operators/vertex_ai/experiment_service.py +435 -0
  140. airflow/providers/google/cloud/operators/vertex_ai/feature_store.py +532 -1
  141. airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +135 -115
  142. airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +12 -10
  143. airflow/providers/google/cloud/operators/vertex_ai/model_service.py +57 -11
  144. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +31 -8
  145. airflow/providers/google/cloud/operators/vertex_ai/ray.py +393 -0
  146. airflow/providers/google/cloud/operators/video_intelligence.py +1 -1
  147. airflow/providers/google/cloud/operators/vision.py +2 -2
  148. airflow/providers/google/cloud/operators/workflows.py +18 -15
  149. airflow/providers/google/cloud/secrets/secret_manager.py +3 -2
  150. airflow/providers/google/cloud/sensors/bigquery.py +3 -3
  151. airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -3
  152. airflow/providers/google/cloud/sensors/bigtable.py +11 -4
  153. airflow/providers/google/cloud/sensors/cloud_composer.py +533 -30
  154. airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -3
  155. airflow/providers/google/cloud/sensors/dataflow.py +26 -10
  156. airflow/providers/google/cloud/sensors/dataform.py +2 -3
  157. airflow/providers/google/cloud/sensors/datafusion.py +4 -5
  158. airflow/providers/google/cloud/sensors/dataplex.py +2 -3
  159. airflow/providers/google/cloud/sensors/dataprep.py +2 -2
  160. airflow/providers/google/cloud/sensors/dataproc.py +2 -3
  161. airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -3
  162. airflow/providers/google/cloud/sensors/gcs.py +4 -5
  163. airflow/providers/google/cloud/sensors/looker.py +2 -3
  164. airflow/providers/google/cloud/sensors/pubsub.py +4 -5
  165. airflow/providers/google/cloud/sensors/tasks.py +2 -2
  166. airflow/providers/google/cloud/sensors/vertex_ai/feature_store.py +2 -3
  167. airflow/providers/google/cloud/sensors/workflows.py +2 -3
  168. airflow/providers/google/cloud/transfers/adls_to_gcs.py +1 -1
  169. airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +2 -2
  170. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +4 -3
  171. airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +11 -8
  172. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +10 -5
  173. airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +7 -3
  174. airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +12 -1
  175. airflow/providers/google/cloud/transfers/bigquery_to_postgres.py +24 -10
  176. airflow/providers/google/cloud/transfers/bigquery_to_sql.py +104 -5
  177. airflow/providers/google/cloud/transfers/calendar_to_gcs.py +1 -1
  178. airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +3 -3
  179. airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +4 -4
  180. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +21 -13
  181. airflow/providers/google/cloud/transfers/gcs_to_gcs.py +4 -3
  182. airflow/providers/google/cloud/transfers/gcs_to_local.py +6 -4
  183. airflow/providers/google/cloud/transfers/gcs_to_sftp.py +11 -5
  184. airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +6 -2
  185. airflow/providers/google/cloud/transfers/gdrive_to_local.py +2 -2
  186. airflow/providers/google/cloud/transfers/http_to_gcs.py +193 -0
  187. airflow/providers/google/cloud/transfers/local_to_gcs.py +2 -2
  188. airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -1
  189. airflow/providers/google/cloud/transfers/oracle_to_gcs.py +36 -11
  190. airflow/providers/google/cloud/transfers/postgres_to_gcs.py +42 -9
  191. airflow/providers/google/cloud/transfers/s3_to_gcs.py +13 -7
  192. airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +2 -2
  193. airflow/providers/google/cloud/transfers/sftp_to_gcs.py +14 -5
  194. airflow/providers/google/cloud/transfers/sheets_to_gcs.py +3 -3
  195. airflow/providers/google/cloud/transfers/sql_to_gcs.py +10 -10
  196. airflow/providers/google/cloud/triggers/bigquery.py +76 -35
  197. airflow/providers/google/cloud/triggers/cloud_build.py +1 -1
  198. airflow/providers/google/cloud/triggers/cloud_composer.py +303 -47
  199. airflow/providers/google/cloud/triggers/cloud_run.py +3 -3
  200. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +92 -2
  201. airflow/providers/google/cloud/triggers/dataflow.py +122 -0
  202. airflow/providers/google/cloud/triggers/datafusion.py +1 -1
  203. airflow/providers/google/cloud/triggers/dataplex.py +14 -2
  204. airflow/providers/google/cloud/triggers/dataproc.py +123 -53
  205. airflow/providers/google/cloud/triggers/kubernetes_engine.py +47 -28
  206. airflow/providers/google/cloud/triggers/mlengine.py +1 -1
  207. airflow/providers/google/cloud/triggers/pubsub.py +15 -19
  208. airflow/providers/google/cloud/triggers/vertex_ai.py +1 -1
  209. airflow/providers/google/cloud/utils/bigquery_get_data.py +1 -1
  210. airflow/providers/google/cloud/utils/credentials_provider.py +2 -2
  211. airflow/providers/google/cloud/utils/field_sanitizer.py +1 -1
  212. airflow/providers/google/cloud/utils/field_validator.py +2 -3
  213. airflow/providers/google/common/auth_backend/google_openid.py +4 -4
  214. airflow/providers/google/common/deprecated.py +2 -1
  215. airflow/providers/google/common/hooks/base_google.py +27 -9
  216. airflow/providers/google/common/hooks/operation_helpers.py +1 -1
  217. airflow/providers/google/common/links/storage.py +0 -22
  218. airflow/providers/google/common/utils/get_secret.py +31 -0
  219. airflow/providers/google/common/utils/id_token_credentials.py +3 -4
  220. airflow/providers/google/firebase/hooks/firestore.py +1 -1
  221. airflow/providers/google/firebase/operators/firestore.py +3 -3
  222. airflow/providers/google/get_provider_info.py +56 -52
  223. airflow/providers/google/go_module_utils.py +35 -3
  224. airflow/providers/google/leveldb/hooks/leveldb.py +27 -2
  225. airflow/providers/google/leveldb/operators/leveldb.py +2 -2
  226. airflow/providers/google/marketing_platform/hooks/campaign_manager.py +1 -1
  227. airflow/providers/google/marketing_platform/hooks/display_video.py +3 -109
  228. airflow/providers/google/marketing_platform/hooks/search_ads.py +1 -1
  229. airflow/providers/google/marketing_platform/links/analytics_admin.py +5 -14
  230. airflow/providers/google/marketing_platform/operators/analytics_admin.py +2 -3
  231. airflow/providers/google/marketing_platform/operators/campaign_manager.py +6 -6
  232. airflow/providers/google/marketing_platform/operators/display_video.py +28 -489
  233. airflow/providers/google/marketing_platform/operators/search_ads.py +2 -2
  234. airflow/providers/google/marketing_platform/sensors/campaign_manager.py +2 -2
  235. airflow/providers/google/marketing_platform/sensors/display_video.py +3 -64
  236. airflow/providers/google/suite/hooks/calendar.py +2 -2
  237. airflow/providers/google/suite/hooks/sheets.py +16 -2
  238. airflow/providers/google/suite/operators/sheets.py +8 -3
  239. airflow/providers/google/suite/sensors/drive.py +2 -2
  240. airflow/providers/google/suite/transfers/gcs_to_gdrive.py +3 -3
  241. airflow/providers/google/suite/transfers/gcs_to_sheets.py +1 -1
  242. airflow/providers/google/suite/transfers/local_to_drive.py +3 -3
  243. airflow/providers/google/suite/transfers/sql_to_sheets.py +5 -4
  244. airflow/providers/google/version_compat.py +15 -1
  245. {apache_airflow_providers_google-15.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/METADATA +90 -46
  246. apache_airflow_providers_google-19.3.0.dist-info/RECORD +331 -0
  247. apache_airflow_providers_google-19.3.0.dist-info/licenses/NOTICE +5 -0
  248. airflow/providers/google/cloud/hooks/automl.py +0 -673
  249. airflow/providers/google/cloud/hooks/life_sciences.py +0 -159
  250. airflow/providers/google/cloud/links/automl.py +0 -193
  251. airflow/providers/google/cloud/operators/automl.py +0 -1362
  252. airflow/providers/google/cloud/operators/life_sciences.py +0 -119
  253. airflow/providers/google/cloud/operators/mlengine.py +0 -112
  254. apache_airflow_providers_google-15.1.0rc1.dist-info/RECORD +0 -321
  255. {apache_airflow_providers_google-15.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/WHEEL +0 -0
  256. {apache_airflow_providers_google-15.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/entry_points.txt +0 -0
  257. {airflow/providers/google → apache_airflow_providers_google-19.3.0.dist-info/licenses}/LICENSE +0 -0
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING, cast
25
25
  from google.api_core.exceptions import GoogleAPICallError
26
26
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
27
27
 
28
- from airflow.exceptions import AirflowException
28
+ from airflow.providers.common.compat.sdk import AirflowException
29
29
  from airflow.providers.google.cloud.hooks.translate import CloudTranslateHook, TranslateHook
30
30
  from airflow.providers.google.cloud.links.translate import (
31
31
  TranslateResultByOutputConfigLink,
@@ -37,6 +37,7 @@ from airflow.providers.google.cloud.links.translate import (
37
37
  TranslationNativeDatasetLink,
38
38
  )
39
39
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
40
+ from airflow.providers.google.cloud.operators.vertex_ai.dataset import DatasetImportDataResultsCheckHelper
40
41
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
41
42
 
42
43
  if TYPE_CHECKING:
@@ -55,7 +56,7 @@ if TYPE_CHECKING:
55
56
  )
56
57
  from google.cloud.translate_v3.types.translation_service import Glossary, GlossaryInputConfig
57
58
 
58
- from airflow.utils.context import Context
59
+ from airflow.providers.common.compat.sdk import Context
59
60
 
60
61
 
61
62
  class CloudTranslateTextOperator(GoogleCloudBaseOperator):
@@ -394,7 +395,6 @@ class TranslateTextBatchOperator(GoogleCloudBaseOperator):
394
395
  self.log.info("Translate text batch job started.")
395
396
  TranslateTextBatchLink.persist(
396
397
  context=context,
397
- task_instance=self,
398
398
  project_id=self.project_id or hook.project_id,
399
399
  output_config=self.output_config,
400
400
  )
@@ -480,15 +480,15 @@ class TranslateCreateDatasetOperator(GoogleCloudBaseOperator):
480
480
  result = hook.wait_for_operation_result(result_operation)
481
481
  result = type(result).to_dict(result)
482
482
  dataset_id = hook.extract_object_id(result)
483
- self.xcom_push(context, key="dataset_id", value=dataset_id)
483
+ context["ti"].xcom_push(key="dataset_id", value=dataset_id)
484
484
  self.log.info("Dataset creation complete. The dataset_id: %s.", dataset_id)
485
485
 
486
486
  project_id = self.project_id or hook.project_id
487
487
  TranslationNativeDatasetLink.persist(
488
488
  context=context,
489
- task_instance=self,
490
489
  dataset_id=dataset_id,
491
490
  project_id=project_id,
491
+ location=self.location,
492
492
  )
493
493
  return result
494
494
 
@@ -556,7 +556,6 @@ class TranslateDatasetsListOperator(GoogleCloudBaseOperator):
556
556
  project_id = self.project_id or hook.project_id
557
557
  TranslationDatasetsListLink.persist(
558
558
  context=context,
559
- task_instance=self,
560
559
  project_id=project_id,
561
560
  )
562
561
  self.log.info("Requesting datasets list")
@@ -577,7 +576,7 @@ class TranslateDatasetsListOperator(GoogleCloudBaseOperator):
577
576
  return result_ids
578
577
 
579
578
 
580
- class TranslateImportDataOperator(GoogleCloudBaseOperator):
579
+ class TranslateImportDataOperator(GoogleCloudBaseOperator, DatasetImportDataResultsCheckHelper):
581
580
  """
582
581
  Import data to the translation dataset.
583
582
 
@@ -604,6 +603,7 @@ class TranslateImportDataOperator(GoogleCloudBaseOperator):
604
603
  If set as a sequence, the identities from the list must grant
605
604
  Service Account Token Creator IAM role to the directly preceding identity, with first
606
605
  account from the list granting this role to the originating account (templated).
606
+ :param raise_for_empty_result: Raise an error if no additional data has been populated after the import.
607
607
  """
608
608
 
609
609
  template_fields: Sequence[str] = (
@@ -629,6 +629,7 @@ class TranslateImportDataOperator(GoogleCloudBaseOperator):
629
629
  retry: Retry | _MethodDefault = DEFAULT,
630
630
  gcp_conn_id: str = "google_cloud_default",
631
631
  impersonation_chain: str | Sequence[str] | None = None,
632
+ raise_for_empty_result: bool = False,
632
633
  **kwargs,
633
634
  ) -> None:
634
635
  super().__init__(**kwargs)
@@ -641,9 +642,21 @@ class TranslateImportDataOperator(GoogleCloudBaseOperator):
641
642
  self.retry = retry
642
643
  self.gcp_conn_id = gcp_conn_id
643
644
  self.impersonation_chain = impersonation_chain
645
+ self.raise_for_empty_result = raise_for_empty_result
644
646
 
645
647
  def execute(self, context: Context):
646
648
  hook = TranslateHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
649
+ initial_dataset_size = self._get_number_of_ds_items(
650
+ dataset=hook.get_dataset(
651
+ dataset_id=self.dataset_id,
652
+ project_id=self.project_id,
653
+ location=self.location,
654
+ retry=self.retry,
655
+ timeout=self.timeout,
656
+ metadata=self.metadata,
657
+ ),
658
+ total_key_name="example_count",
659
+ )
647
660
  self.log.info("Importing data to dataset...")
648
661
  operation = hook.import_dataset_data(
649
662
  dataset_id=self.dataset_id,
@@ -657,12 +670,27 @@ class TranslateImportDataOperator(GoogleCloudBaseOperator):
657
670
  project_id = self.project_id or hook.project_id
658
671
  TranslationNativeDatasetLink.persist(
659
672
  context=context,
660
- task_instance=self,
661
673
  dataset_id=self.dataset_id,
662
674
  project_id=project_id,
675
+ location=self.location,
663
676
  )
664
677
  hook.wait_for_operation_done(operation=operation, timeout=self.timeout)
678
+
679
+ result_dataset_size = self._get_number_of_ds_items(
680
+ dataset=hook.get_dataset(
681
+ dataset_id=self.dataset_id,
682
+ project_id=self.project_id,
683
+ location=self.location,
684
+ retry=self.retry,
685
+ timeout=self.timeout,
686
+ metadata=self.metadata,
687
+ ),
688
+ total_key_name="example_count",
689
+ )
690
+ if self.raise_for_empty_result:
691
+ self._raise_for_empty_import_result(self.dataset_id, initial_dataset_size, result_dataset_size)
665
692
  self.log.info("Importing data finished!")
693
+ return {"total_imported": int(result_dataset_size) - int(initial_dataset_size)}
666
694
 
667
695
 
668
696
  class TranslateDeleteDatasetOperator(GoogleCloudBaseOperator):
@@ -821,16 +849,16 @@ class TranslateCreateModelOperator(GoogleCloudBaseOperator):
821
849
  result = hook.wait_for_operation_result(operation=result_operation)
822
850
  result = type(result).to_dict(result)
823
851
  model_id = hook.extract_object_id(result)
824
- self.xcom_push(context, key="model_id", value=model_id)
852
+ context["ti"].xcom_push(key="model_id", value=model_id)
825
853
  self.log.info("Model creation complete. The model_id: %s.", model_id)
826
854
 
827
855
  project_id = self.project_id or hook.project_id
828
856
  TranslationModelLink.persist(
829
857
  context=context,
830
- task_instance=self,
831
858
  dataset_id=self.dataset_id,
832
859
  model_id=model_id,
833
860
  project_id=project_id,
861
+ location=self.location,
834
862
  )
835
863
  return result
836
864
 
@@ -898,7 +926,6 @@ class TranslateModelsListOperator(GoogleCloudBaseOperator):
898
926
  project_id = self.project_id or hook.project_id
899
927
  TranslationModelsListLink.persist(
900
928
  context=context,
901
- task_instance=self,
902
929
  project_id=project_id,
903
930
  )
904
931
  self.log.info("Requesting models list")
@@ -1141,7 +1168,6 @@ class TranslateDocumentOperator(GoogleCloudBaseOperator):
1141
1168
  if self.document_output_config:
1142
1169
  TranslateResultByOutputConfigLink.persist(
1143
1170
  context=context,
1144
- task_instance=self,
1145
1171
  project_id=self.project_id or hook.project_id,
1146
1172
  output_config=self.document_output_config,
1147
1173
  )
@@ -1304,7 +1330,6 @@ class TranslateDocumentBatchOperator(GoogleCloudBaseOperator):
1304
1330
  self.log.info("Batch document translation job started.")
1305
1331
  TranslateResultByOutputConfigLink.persist(
1306
1332
  context=context,
1307
- task_instance=self,
1308
1333
  project_id=self.project_id or hook.project_id,
1309
1334
  output_config=self.output_config,
1310
1335
  )
@@ -1411,7 +1436,7 @@ class TranslateCreateGlossaryOperator(GoogleCloudBaseOperator):
1411
1436
  result = type(result).to_dict(result)
1412
1437
 
1413
1438
  glossary_id = hook.extract_object_id(result)
1414
- self.xcom_push(context, key="glossary_id", value=glossary_id)
1439
+ context["ti"].xcom_push(key="glossary_id", value=glossary_id)
1415
1440
  self.log.info("Glossary creation complete. The glossary_id: %s.", glossary_id)
1416
1441
  return result
1417
1442
 
@@ -1610,7 +1635,6 @@ class TranslateListGlossariesOperator(GoogleCloudBaseOperator):
1610
1635
  project_id = self.project_id or hook.project_id
1611
1636
  TranslationGlossariesListLink.persist(
1612
1637
  context=context,
1613
- task_instance=self,
1614
1638
  project_id=project_id,
1615
1639
  )
1616
1640
  self.log.info("Requesting glossaries list")
@@ -1630,8 +1654,8 @@ class TranslateListGlossariesOperator(GoogleCloudBaseOperator):
1630
1654
  raise AirflowException(e)
1631
1655
 
1632
1656
  result_ids = []
1633
- for glossary_item in results_pager:
1634
- glossary_item = type(glossary_item).to_dict(glossary_item)
1657
+ for glossary_item_raw in results_pager:
1658
+ glossary_item = type(glossary_item_raw).to_dict(glossary_item_raw)
1635
1659
  glossary_id = hook.extract_object_id(glossary_item)
1636
1660
  result_ids.append(glossary_id)
1637
1661
  self.log.info("Fetching the glossaries list complete. Glossary id-s: %s", result_ids)
@@ -24,7 +24,7 @@ from typing import TYPE_CHECKING
24
24
 
25
25
  from google.protobuf.json_format import MessageToDict
26
26
 
27
- from airflow.exceptions import AirflowException
27
+ from airflow.providers.common.compat.sdk import AirflowException
28
28
  from airflow.providers.google.cloud.hooks.speech_to_text import CloudSpeechToTextHook
29
29
  from airflow.providers.google.cloud.hooks.translate import CloudTranslateHook
30
30
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -34,7 +34,7 @@ from airflow.providers.google.common.links.storage import FileDetailsLink
34
34
  if TYPE_CHECKING:
35
35
  from google.cloud.speech_v1.types import RecognitionAudio, RecognitionConfig
36
36
 
37
- from airflow.utils.context import Context
37
+ from airflow.providers.common.compat.sdk import Context
38
38
 
39
39
 
40
40
  class CloudTranslateSpeechOperator(GoogleCloudBaseOperator):
@@ -173,7 +173,6 @@ class CloudTranslateSpeechOperator(GoogleCloudBaseOperator):
173
173
  if self.audio.uri:
174
174
  FileDetailsLink.persist(
175
175
  context=context,
176
- task_instance=self,
177
176
  # Slice from: "gs://{BUCKET_NAME}/{FILE_NAME}" to: "{BUCKET_NAME}/{FILE_NAME}"
178
177
  uri=self.audio.uri[5:],
179
178
  project_id=self.project_id or translate_hook.project_id,
@@ -21,7 +21,7 @@
21
21
  from __future__ import annotations
22
22
 
23
23
  from collections.abc import Sequence
24
- from typing import TYPE_CHECKING
24
+ from typing import TYPE_CHECKING, Any
25
25
 
26
26
  from google.api_core.exceptions import NotFound
27
27
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
@@ -29,6 +29,7 @@ from google.cloud.aiplatform import datasets
29
29
  from google.cloud.aiplatform.models import Model
30
30
  from google.cloud.aiplatform_v1.types.training_pipeline import TrainingPipeline
31
31
 
32
+ from airflow.exceptions import AirflowProviderDeprecationWarning
32
33
  from airflow.providers.google.cloud.hooks.vertex_ai.auto_ml import AutoMLHook
33
34
  from airflow.providers.google.cloud.links.vertex_ai import (
34
35
  VertexAIModelLink,
@@ -36,11 +37,12 @@ from airflow.providers.google.cloud.links.vertex_ai import (
36
37
  VertexAITrainingPipelinesLink,
37
38
  )
38
39
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
40
+ from airflow.providers.google.common.deprecated import deprecated
39
41
 
40
42
  if TYPE_CHECKING:
41
43
  from google.api_core.retry import Retry
42
44
 
43
- from airflow.utils.context import Context
45
+ from airflow.providers.common.compat.sdk import Context
44
46
 
45
47
 
46
48
  class AutoMLTrainingJobBaseOperator(GoogleCloudBaseOperator):
@@ -91,6 +93,13 @@ class AutoMLTrainingJobBaseOperator(GoogleCloudBaseOperator):
91
93
  self.impersonation_chain = impersonation_chain
92
94
  self.hook: AutoMLHook | None = None
93
95
 
96
+ @property
97
+ def extra_links_params(self) -> dict[str, Any]:
98
+ return {
99
+ "region": self.region,
100
+ "project_id": self.project_id,
101
+ }
102
+
94
103
  def on_kill(self) -> None:
95
104
  """Act as a callback called when the operator is killed; cancel any running job."""
96
105
  if self.hook:
@@ -242,12 +251,12 @@ class CreateAutoMLForecastingTrainingJobOperator(AutoMLTrainingJobBaseOperator):
242
251
  if model:
243
252
  result = Model.to_dict(model)
244
253
  model_id = self.hook.extract_model_id(result)
245
- self.xcom_push(context, key="model_id", value=model_id)
246
- VertexAIModelLink.persist(context=context, task_instance=self, model_id=model_id)
254
+ context["ti"].xcom_push(key="model_id", value=model_id)
255
+ VertexAIModelLink.persist(context=context, model_id=model_id)
247
256
  else:
248
257
  result = model # type: ignore
249
- self.xcom_push(context, key="training_id", value=training_id)
250
- VertexAITrainingLink.persist(context=context, task_instance=self, training_id=training_id)
258
+ context["ti"].xcom_push(key="training_id", value=training_id)
259
+ VertexAITrainingLink.persist(context=context, training_id=training_id)
251
260
  return result
252
261
 
253
262
 
@@ -334,12 +343,12 @@ class CreateAutoMLImageTrainingJobOperator(AutoMLTrainingJobBaseOperator):
334
343
  if model:
335
344
  result = Model.to_dict(model)
336
345
  model_id = self.hook.extract_model_id(result)
337
- self.xcom_push(context, key="model_id", value=model_id)
338
- VertexAIModelLink.persist(context=context, task_instance=self, model_id=model_id)
346
+ context["ti"].xcom_push(key="model_id", value=model_id)
347
+ VertexAIModelLink.persist(context=context, model_id=model_id)
339
348
  else:
340
349
  result = model # type: ignore
341
- self.xcom_push(context, key="training_id", value=training_id)
342
- VertexAITrainingLink.persist(context=context, task_instance=self, training_id=training_id)
350
+ context["ti"].xcom_push(key="training_id", value=training_id)
351
+ VertexAITrainingLink.persist(context=context, training_id=training_id)
343
352
  return result
344
353
 
345
354
 
@@ -457,15 +466,20 @@ class CreateAutoMLTabularTrainingJobOperator(AutoMLTrainingJobBaseOperator):
457
466
  if model:
458
467
  result = Model.to_dict(model)
459
468
  model_id = self.hook.extract_model_id(result)
460
- self.xcom_push(context, key="model_id", value=model_id)
461
- VertexAIModelLink.persist(context=context, task_instance=self, model_id=model_id)
469
+ context["ti"].xcom_push(key="model_id", value=model_id)
470
+ VertexAIModelLink.persist(context=context, model_id=model_id)
462
471
  else:
463
472
  result = model # type: ignore
464
- self.xcom_push(context, key="training_id", value=training_id)
465
- VertexAITrainingLink.persist(context=context, task_instance=self, training_id=training_id)
473
+ context["ti"].xcom_push(key="training_id", value=training_id)
474
+ VertexAITrainingLink.persist(context=context, training_id=training_id)
466
475
  return result
467
476
 
468
477
 
478
+ @deprecated(
479
+ planned_removal_date="March 24, 2026",
480
+ use_instead="airflow.providers.google.cloud.operators.vertex_ai.generative_model.SupervisedFineTuningTrainOperator",
481
+ category=AirflowProviderDeprecationWarning,
482
+ )
469
483
  class CreateAutoMLVideoTrainingJobOperator(AutoMLTrainingJobBaseOperator):
470
484
  """Create Auto ML Video Training job."""
471
485
 
@@ -531,12 +545,12 @@ class CreateAutoMLVideoTrainingJobOperator(AutoMLTrainingJobBaseOperator):
531
545
  if model:
532
546
  result = Model.to_dict(model)
533
547
  model_id = self.hook.extract_model_id(result)
534
- self.xcom_push(context, key="model_id", value=model_id)
535
- VertexAIModelLink.persist(context=context, task_instance=self, model_id=model_id)
548
+ context["ti"].xcom_push(key="model_id", value=model_id)
549
+ VertexAIModelLink.persist(context=context, model_id=model_id)
536
550
  else:
537
551
  result = model # type: ignore
538
- self.xcom_push(context, key="training_id", value=training_id)
539
- VertexAITrainingLink.persist(context=context, task_instance=self, training_id=training_id)
552
+ context["ti"].xcom_push(key="training_id", value=training_id)
553
+ VertexAITrainingLink.persist(context=context, training_id=training_id)
540
554
  return result
541
555
 
542
556
 
@@ -640,6 +654,12 @@ class ListAutoMLTrainingJobOperator(GoogleCloudBaseOperator):
640
654
  self.gcp_conn_id = gcp_conn_id
641
655
  self.impersonation_chain = impersonation_chain
642
656
 
657
+ @property
658
+ def extra_links_params(self) -> dict[str, Any]:
659
+ return {
660
+ "project_id": self.project_id,
661
+ }
662
+
643
663
  def execute(self, context: Context):
644
664
  hook = AutoMLHook(
645
665
  gcp_conn_id=self.gcp_conn_id,
@@ -656,5 +676,5 @@ class ListAutoMLTrainingJobOperator(GoogleCloudBaseOperator):
656
676
  timeout=self.timeout,
657
677
  metadata=self.metadata,
658
678
  )
659
- VertexAITrainingPipelinesLink.persist(context=context, task_instance=self)
679
+ VertexAITrainingPipelinesLink.persist(context=context)
660
680
  return [TrainingPipeline.to_dict(result) for result in results]
@@ -29,7 +29,7 @@ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
29
29
  from google.cloud.aiplatform_v1.types import BatchPredictionJob
30
30
 
31
31
  from airflow.configuration import conf
32
- from airflow.exceptions import AirflowException
32
+ from airflow.providers.common.compat.sdk import AirflowException
33
33
  from airflow.providers.google.cloud.hooks.vertex_ai.batch_prediction_job import BatchPredictionJobHook
34
34
  from airflow.providers.google.cloud.links.vertex_ai import (
35
35
  VertexAIBatchPredictionJobLink,
@@ -42,7 +42,7 @@ if TYPE_CHECKING:
42
42
  from google.api_core.retry import Retry
43
43
  from google.cloud.aiplatform import BatchPredictionJob as BatchPredictionJobObject, Model, explain
44
44
 
45
- from airflow.utils.context import Context
45
+ from airflow.providers.common.compat.sdk import Context
46
46
 
47
47
 
48
48
  class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
@@ -231,6 +231,13 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
231
231
  impersonation_chain=self.impersonation_chain,
232
232
  )
233
233
 
234
+ @property
235
+ def extra_links_params(self) -> dict[str, Any]:
236
+ return {
237
+ "region": self.region,
238
+ "project_id": self.project_id,
239
+ }
240
+
234
241
  def execute(self, context: Context):
235
242
  self.log.info("Creating Batch prediction job")
236
243
  batch_prediction_job: BatchPredictionJobObject = self.hook.submit_batch_prediction_job(
@@ -262,9 +269,10 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
262
269
  batch_prediction_job_id = batch_prediction_job.name
263
270
  self.log.info("Batch prediction job was created. Job id: %s", batch_prediction_job_id)
264
271
 
265
- self.xcom_push(context, key="batch_prediction_job_id", value=batch_prediction_job_id)
272
+ context["ti"].xcom_push(key="batch_prediction_job_id", value=batch_prediction_job_id)
266
273
  VertexAIBatchPredictionJobLink.persist(
267
- context=context, task_instance=self, batch_prediction_job_id=batch_prediction_job_id
274
+ context=context,
275
+ batch_prediction_job_id=batch_prediction_job_id,
268
276
  )
269
277
 
270
278
  if self.deferrable:
@@ -295,13 +303,11 @@ class CreateBatchPredictionJobOperator(GoogleCloudBaseOperator):
295
303
  job: dict[str, Any] = event["job"]
296
304
  self.log.info("Batch prediction job %s created and completed successfully.", job["name"])
297
305
  job_id = self.hook.extract_batch_prediction_job_id(job)
298
- self.xcom_push(
299
- context,
306
+ context["ti"].xcom_push(
300
307
  key="batch_prediction_job_id",
301
308
  value=job_id,
302
309
  )
303
- self.xcom_push(
304
- context,
310
+ context["ti"].xcom_push(
305
311
  key="training_conf",
306
312
  value={
307
313
  "training_conf_id": job_id,
@@ -427,6 +433,13 @@ class GetBatchPredictionJobOperator(GoogleCloudBaseOperator):
427
433
  self.gcp_conn_id = gcp_conn_id
428
434
  self.impersonation_chain = impersonation_chain
429
435
 
436
+ @property
437
+ def extra_links_params(self) -> dict[str, Any]:
438
+ return {
439
+ "region": self.region,
440
+ "project_id": self.project_id,
441
+ }
442
+
430
443
  def execute(self, context: Context):
431
444
  hook = BatchPredictionJobHook(
432
445
  gcp_conn_id=self.gcp_conn_id,
@@ -445,7 +458,8 @@ class GetBatchPredictionJobOperator(GoogleCloudBaseOperator):
445
458
  )
446
459
  self.log.info("Batch prediction job was gotten.")
447
460
  VertexAIBatchPredictionJobLink.persist(
448
- context=context, task_instance=self, batch_prediction_job_id=self.batch_prediction_job
461
+ context=context,
462
+ batch_prediction_job_id=self.batch_prediction_job,
449
463
  )
450
464
  return BatchPredictionJob.to_dict(result)
451
465
  except NotFound:
@@ -517,6 +531,12 @@ class ListBatchPredictionJobsOperator(GoogleCloudBaseOperator):
517
531
  self.gcp_conn_id = gcp_conn_id
518
532
  self.impersonation_chain = impersonation_chain
519
533
 
534
+ @property
535
+ def extra_links_params(self) -> dict[str, Any]:
536
+ return {
537
+ "project_id": self.project_id,
538
+ }
539
+
520
540
  def execute(self, context: Context):
521
541
  hook = BatchPredictionJobHook(
522
542
  gcp_conn_id=self.gcp_conn_id,
@@ -533,5 +553,5 @@ class ListBatchPredictionJobsOperator(GoogleCloudBaseOperator):
533
553
  timeout=self.timeout,
534
554
  metadata=self.metadata,
535
555
  )
536
- VertexAIBatchPredictionJobListLink.persist(context=context, task_instance=self)
556
+ VertexAIBatchPredictionJobListLink.persist(context=context)
537
557
  return [BatchPredictionJob.to_dict(result) for result in results]