apache-airflow-providers-google 19.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 (137) hide show
  1. airflow/providers/google/__init__.py +1 -1
  2. airflow/providers/google/ads/hooks/ads.py +1 -2
  3. airflow/providers/google/cloud/bundles/gcs.py +1 -1
  4. airflow/providers/google/cloud/hooks/alloy_db.py +1 -1
  5. airflow/providers/google/cloud/hooks/bigquery.py +15 -17
  6. airflow/providers/google/cloud/hooks/cloud_batch.py +1 -1
  7. airflow/providers/google/cloud/hooks/cloud_build.py +1 -1
  8. airflow/providers/google/cloud/hooks/cloud_composer.py +1 -1
  9. airflow/providers/google/cloud/hooks/cloud_memorystore.py +1 -1
  10. airflow/providers/google/cloud/hooks/cloud_run.py +1 -1
  11. airflow/providers/google/cloud/hooks/cloud_sql.py +1 -1
  12. airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +2 -1
  13. airflow/providers/google/cloud/hooks/compute.py +1 -1
  14. airflow/providers/google/cloud/hooks/compute_ssh.py +1 -1
  15. airflow/providers/google/cloud/hooks/datacatalog.py +2 -1
  16. airflow/providers/google/cloud/hooks/dataflow.py +2 -2
  17. airflow/providers/google/cloud/hooks/dataform.py +1 -1
  18. airflow/providers/google/cloud/hooks/datafusion.py +20 -18
  19. airflow/providers/google/cloud/hooks/dataplex.py +1 -1
  20. airflow/providers/google/cloud/hooks/dataproc.py +1 -1
  21. airflow/providers/google/cloud/hooks/dataproc_metastore.py +1 -1
  22. airflow/providers/google/cloud/hooks/dlp.py +1 -1
  23. airflow/providers/google/cloud/hooks/functions.py +1 -1
  24. airflow/providers/google/cloud/hooks/gcs.py +2 -2
  25. airflow/providers/google/cloud/hooks/gdm.py +1 -1
  26. airflow/providers/google/cloud/hooks/kubernetes_engine.py +1 -1
  27. airflow/providers/google/cloud/hooks/looker.py +1 -2
  28. airflow/providers/google/cloud/hooks/managed_kafka.py +1 -1
  29. airflow/providers/google/cloud/hooks/mlengine.py +1 -1
  30. airflow/providers/google/cloud/hooks/pubsub.py +3 -0
  31. airflow/providers/google/cloud/hooks/spanner.py +1 -1
  32. airflow/providers/google/cloud/hooks/stackdriver.py +1 -1
  33. airflow/providers/google/cloud/hooks/tasks.py +1 -1
  34. airflow/providers/google/cloud/hooks/translate.py +1 -1
  35. airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +2 -1
  36. airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +1 -1
  37. airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +1 -1
  38. airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +1 -1
  39. airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +1 -1
  40. airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +1 -1
  41. airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +1 -1
  42. airflow/providers/google/cloud/hooks/vertex_ai/ray.py +1 -1
  43. airflow/providers/google/cloud/hooks/vision.py +1 -1
  44. airflow/providers/google/cloud/log/gcs_task_handler.py +41 -13
  45. airflow/providers/google/cloud/operators/alloy_db.py +1 -1
  46. airflow/providers/google/cloud/operators/bigquery.py +2 -2
  47. airflow/providers/google/cloud/operators/bigquery_dts.py +1 -1
  48. airflow/providers/google/cloud/operators/bigtable.py +1 -1
  49. airflow/providers/google/cloud/operators/cloud_batch.py +1 -1
  50. airflow/providers/google/cloud/operators/cloud_build.py +1 -1
  51. airflow/providers/google/cloud/operators/cloud_composer.py +1 -1
  52. airflow/providers/google/cloud/operators/cloud_logging_sink.py +1 -1
  53. airflow/providers/google/cloud/operators/cloud_run.py +1 -1
  54. airflow/providers/google/cloud/operators/cloud_sql.py +1 -2
  55. airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +1 -1
  56. airflow/providers/google/cloud/operators/compute.py +1 -1
  57. airflow/providers/google/cloud/operators/dataflow.py +2 -1
  58. airflow/providers/google/cloud/operators/datafusion.py +1 -1
  59. airflow/providers/google/cloud/operators/dataplex.py +1 -1
  60. airflow/providers/google/cloud/operators/dataproc.py +2 -1
  61. airflow/providers/google/cloud/operators/dataproc_metastore.py +1 -1
  62. airflow/providers/google/cloud/operators/datastore.py +1 -1
  63. airflow/providers/google/cloud/operators/functions.py +1 -1
  64. airflow/providers/google/cloud/operators/gcs.py +2 -1
  65. airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -1
  66. airflow/providers/google/cloud/operators/looker.py +1 -1
  67. airflow/providers/google/cloud/operators/managed_kafka.py +1 -1
  68. airflow/providers/google/cloud/operators/pubsub.py +8 -1
  69. airflow/providers/google/cloud/operators/spanner.py +1 -1
  70. airflow/providers/google/cloud/operators/speech_to_text.py +1 -1
  71. airflow/providers/google/cloud/operators/text_to_speech.py +1 -1
  72. airflow/providers/google/cloud/operators/translate.py +1 -1
  73. airflow/providers/google/cloud/operators/translate_speech.py +1 -1
  74. airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +1 -1
  75. airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +1 -1
  76. airflow/providers/google/cloud/operators/vertex_ai/dataset.py +1 -1
  77. airflow/providers/google/cloud/operators/vertex_ai/experiment_service.py +1 -1
  78. airflow/providers/google/cloud/operators/vertex_ai/feature_store.py +1 -1
  79. airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +2 -1
  80. airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +1 -1
  81. airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +1 -1
  82. airflow/providers/google/cloud/operators/vertex_ai/ray.py +1 -1
  83. airflow/providers/google/cloud/secrets/secret_manager.py +3 -2
  84. airflow/providers/google/cloud/sensors/bigquery.py +2 -2
  85. airflow/providers/google/cloud/sensors/bigquery_dts.py +1 -2
  86. airflow/providers/google/cloud/sensors/cloud_composer.py +1 -2
  87. airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +1 -2
  88. airflow/providers/google/cloud/sensors/dataflow.py +1 -2
  89. airflow/providers/google/cloud/sensors/dataform.py +1 -2
  90. airflow/providers/google/cloud/sensors/datafusion.py +1 -2
  91. airflow/providers/google/cloud/sensors/dataplex.py +1 -2
  92. airflow/providers/google/cloud/sensors/dataproc.py +1 -2
  93. airflow/providers/google/cloud/sensors/dataproc_metastore.py +1 -2
  94. airflow/providers/google/cloud/sensors/gcs.py +1 -2
  95. airflow/providers/google/cloud/sensors/looker.py +1 -2
  96. airflow/providers/google/cloud/sensors/pubsub.py +1 -2
  97. airflow/providers/google/cloud/sensors/vertex_ai/feature_store.py +1 -2
  98. airflow/providers/google/cloud/sensors/workflows.py +1 -2
  99. airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +2 -1
  100. airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +6 -1
  101. airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +1 -1
  102. airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +1 -1
  103. airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +1 -1
  104. airflow/providers/google/cloud/transfers/gcs_to_gcs.py +2 -1
  105. airflow/providers/google/cloud/transfers/gcs_to_local.py +1 -1
  106. airflow/providers/google/cloud/transfers/gcs_to_sftp.py +1 -1
  107. airflow/providers/google/cloud/transfers/s3_to_gcs.py +1 -1
  108. airflow/providers/google/cloud/transfers/sftp_to_gcs.py +1 -1
  109. airflow/providers/google/cloud/triggers/bigquery.py +1 -1
  110. airflow/providers/google/cloud/triggers/cloud_composer.py +1 -1
  111. airflow/providers/google/cloud/triggers/cloud_run.py +1 -1
  112. airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +1 -1
  113. airflow/providers/google/cloud/triggers/dataproc.py +1 -1
  114. airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -1
  115. airflow/providers/google/cloud/triggers/vertex_ai.py +1 -1
  116. airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
  117. airflow/providers/google/cloud/utils/field_sanitizer.py +1 -1
  118. airflow/providers/google/cloud/utils/field_validator.py +1 -1
  119. airflow/providers/google/common/hooks/base_google.py +1 -2
  120. airflow/providers/google/common/hooks/operation_helpers.py +1 -1
  121. airflow/providers/google/firebase/hooks/firestore.py +1 -1
  122. airflow/providers/google/firebase/operators/firestore.py +1 -1
  123. airflow/providers/google/leveldb/hooks/leveldb.py +2 -2
  124. airflow/providers/google/marketing_platform/hooks/campaign_manager.py +1 -1
  125. airflow/providers/google/marketing_platform/hooks/search_ads.py +1 -1
  126. airflow/providers/google/marketing_platform/operators/analytics_admin.py +1 -1
  127. airflow/providers/google/marketing_platform/operators/campaign_manager.py +1 -1
  128. airflow/providers/google/marketing_platform/sensors/display_video.py +1 -2
  129. airflow/providers/google/suite/hooks/calendar.py +1 -1
  130. airflow/providers/google/suite/hooks/sheets.py +1 -1
  131. airflow/providers/google/suite/transfers/gcs_to_gdrive.py +1 -1
  132. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/METADATA +17 -17
  133. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/RECORD +137 -137
  134. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/WHEEL +0 -0
  135. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/entry_points.txt +0 -0
  136. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/licenses/LICENSE +0 -0
  137. {apache_airflow_providers_google-19.1.0rc1.dist-info → apache_airflow_providers_google-19.3.0.dist-info}/licenses/NOTICE +0 -0
@@ -31,7 +31,7 @@ import attrs
31
31
  import google.cloud.storage as storage
32
32
 
33
33
  from airflow.configuration import conf
34
- from airflow.exceptions import AirflowNotFoundException
34
+ from airflow.providers.common.compat.sdk import AirflowNotFoundException
35
35
  from airflow.providers.google.cloud.hooks.gcs import GCSHook, _parse_gcs_url
36
36
  from airflow.providers.google.cloud.utils.credentials_provider import (
37
37
  get_credentials_and_project_id,
@@ -43,9 +43,11 @@ from airflow.utils.log.file_task_handler import FileTaskHandler
43
43
  from airflow.utils.log.logging_mixin import LoggingMixin
44
44
 
45
45
  if TYPE_CHECKING:
46
+ from io import TextIOWrapper
47
+
46
48
  from airflow.models.taskinstance import TaskInstance
47
49
  from airflow.sdk.types import RuntimeTaskInstanceProtocol as RuntimeTI
48
- from airflow.utils.log.file_task_handler import LogMessages, LogSourceInfo
50
+ from airflow.utils.log.file_task_handler import LogResponse, RawLogStream, StreamingLogResponse
49
51
 
50
52
  _DEFAULT_SCOPESS = frozenset(
51
53
  [
@@ -149,11 +151,26 @@ class GCSRemoteLogIO(LoggingMixin): # noqa: D101
149
151
  exc, "resp", {}
150
152
  ).get("status") == "404"
151
153
 
152
- def read(self, relative_path: str, ti: RuntimeTI) -> tuple[LogSourceInfo, LogMessages | None]:
153
- messages = []
154
- logs = []
154
+ def read(self, relative_path: str, ti: RuntimeTI) -> LogResponse:
155
+ messages, log_streams = self.stream(relative_path, ti)
156
+ if not log_streams:
157
+ return messages, None
158
+
159
+ logs: list[str] = []
160
+ try:
161
+ # for each log_stream, exhaust the generator into a string
162
+ logs = ["".join(line for line in log_stream) for log_stream in log_streams]
163
+ except Exception as e:
164
+ if not AIRFLOW_V_3_0_PLUS:
165
+ messages.append(f"Unable to read remote log {e}")
166
+
167
+ return messages, logs
168
+
169
+ def stream(self, relative_path: str, ti: RuntimeTI) -> StreamingLogResponse:
170
+ messages: list[str] = []
171
+ log_streams: list[RawLogStream] = []
155
172
  remote_loc = os.path.join(self.remote_base, relative_path)
156
- uris = []
173
+ uris: list[str] = []
157
174
  bucket, prefix = _parse_gcs_url(remote_loc)
158
175
  blobs = list(self.client.list_blobs(bucket_or_name=bucket, prefix=prefix))
159
176
 
@@ -164,18 +181,29 @@ class GCSRemoteLogIO(LoggingMixin): # noqa: D101
164
181
  else:
165
182
  messages.extend(["Found remote logs:", *[f" * {x}" for x in sorted(uris)]])
166
183
  else:
167
- return messages, None
184
+ return messages, []
168
185
 
169
186
  try:
170
187
  for key in sorted(uris):
171
188
  blob = storage.Blob.from_string(key, self.client)
172
- remote_log = blob.download_as_bytes().decode()
173
- if remote_log:
174
- logs.append(remote_log)
189
+ stream = blob.open("r")
190
+ log_streams.append(self._get_log_stream(stream))
175
191
  except Exception as e:
176
192
  if not AIRFLOW_V_3_0_PLUS:
177
193
  messages.append(f"Unable to read remote log {e}")
178
- return messages, logs
194
+ return messages, log_streams
195
+
196
+ def _get_log_stream(self, stream: TextIOWrapper) -> RawLogStream:
197
+ """
198
+ Yield lines from the given stream.
199
+
200
+ :param stream: The opened stream to read from.
201
+ :yield: Lines of the log file.
202
+ """
203
+ try:
204
+ yield from stream
205
+ finally:
206
+ stream.close()
179
207
 
180
208
 
181
209
  class GCSTaskHandler(FileTaskHandler, LoggingMixin):
@@ -273,7 +301,7 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin):
273
301
  # Mark closed so we don't double write if close is called twice
274
302
  self.closed = True
275
303
 
276
- def _read_remote_logs(self, ti, try_number, metadata=None) -> tuple[LogSourceInfo, LogMessages]:
304
+ def _read_remote_logs(self, ti, try_number, metadata=None) -> LogResponse:
277
305
  # Explicitly getting log relative path is necessary as the given
278
306
  # task instance might be different than task instance passed in
279
307
  # in set_context method.
@@ -283,7 +311,7 @@ class GCSTaskHandler(FileTaskHandler, LoggingMixin):
283
311
 
284
312
  if logs is None:
285
313
  logs = []
286
- if not AIRFLOW_V_3_0_PLUS:
314
+ if not AIRFLOW_V_3_0_PLUS and not messages:
287
315
  messages.append(f"No logs found in GCS; ti={ti}")
288
316
 
289
317
  return messages, logs
@@ -27,7 +27,7 @@ from google.api_core.exceptions import NotFound
27
27
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
28
  from google.cloud import alloydb_v1
29
29
 
30
- from airflow.exceptions import AirflowException
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
  from airflow.providers.google.cloud.hooks.alloy_db import AlloyDbHook
32
32
  from airflow.providers.google.cloud.links.alloy_db import (
33
33
  AlloyDBBackupsLink,
@@ -33,8 +33,8 @@ from google.cloud.bigquery import DEFAULT_RETRY, CopyJob, ExtractJob, LoadJob, Q
33
33
  from google.cloud.bigquery.table import RowIterator, Table, TableListItem, TableReference
34
34
 
35
35
  from airflow.configuration import conf
36
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
37
- from airflow.providers.common.compat.sdk import AirflowSkipException
36
+ from airflow.exceptions import AirflowProviderDeprecationWarning
37
+ from airflow.providers.common.compat.sdk import AirflowException, AirflowSkipException
38
38
  from airflow.providers.common.sql.operators.sql import ( # for _parse_boolean
39
39
  SQLCheckOperator,
40
40
  SQLColumnCheckOperator,
@@ -33,7 +33,7 @@ from google.cloud.bigquery_datatransfer_v1 import (
33
33
  )
34
34
 
35
35
  from airflow.configuration import conf
36
- from airflow.exceptions import AirflowException
36
+ from airflow.providers.common.compat.sdk import AirflowException
37
37
  from airflow.providers.google.cloud.hooks.bigquery_dts import BiqQueryDataTransferServiceHook, get_object_id
38
38
  from airflow.providers.google.cloud.links.bigquery_dts import BigQueryDataTransferConfigLink
39
39
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -24,7 +24,7 @@ from typing import TYPE_CHECKING, Any
24
24
 
25
25
  import google.api_core.exceptions
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.bigtable import BigtableHook
29
29
  from airflow.providers.google.cloud.links.bigtable import (
30
30
  BigtableClusterLink,
@@ -23,7 +23,7 @@ from typing import TYPE_CHECKING
23
23
  from google.cloud.batch_v1 import Job, Task
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
26
+ from airflow.providers.common.compat.sdk import AirflowException
27
27
  from airflow.providers.google.cloud.hooks.cloud_batch import CloudBatchHook
28
28
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
29
29
  from airflow.providers.google.cloud.triggers.cloud_batch import CloudBatchJobFinishedTrigger
@@ -30,7 +30,7 @@ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
30
30
  from google.cloud.devtools.cloudbuild_v1.types import Build, BuildTrigger, RepoSource
31
31
 
32
32
  from airflow.configuration import conf
33
- from airflow.exceptions import AirflowException
33
+ from airflow.providers.common.compat.sdk import AirflowException
34
34
  from airflow.providers.google.cloud.hooks.cloud_build import CloudBuildHook
35
35
  from airflow.providers.google.cloud.links.cloud_build import (
36
36
  CloudBuildLink,
@@ -27,7 +27,7 @@ from google.cloud.orchestration.airflow.service_v1 import ImageVersion
27
27
  from google.cloud.orchestration.airflow.service_v1.types import Environment, ExecuteAirflowCommandResponse
28
28
 
29
29
  from airflow.configuration import conf
30
- from airflow.exceptions import AirflowException
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
  from airflow.providers.google.cloud.hooks.cloud_composer import CloudComposerHook
32
32
  from airflow.providers.google.cloud.links.base import BaseGoogleLink
33
33
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -25,7 +25,7 @@ import google.cloud.exceptions
25
25
  from google.api_core.exceptions import AlreadyExists
26
26
  from google.cloud.logging_v2.types import LogSink
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.cloud_logging import CloudLoggingHook
30
30
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
31
31
 
@@ -25,7 +25,7 @@ from google.api_core.exceptions import AlreadyExists
25
25
  from google.cloud.run_v2 import Job, Service
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException
28
+ from airflow.providers.common.compat.sdk import AirflowException
29
29
  from airflow.providers.google.cloud.hooks.cloud_run import CloudRunHook, CloudRunServiceHook
30
30
  from airflow.providers.google.cloud.links.cloud_run import CloudRunJobLoggingLink
31
31
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -27,8 +27,7 @@ from typing import TYPE_CHECKING, Any
27
27
  from googleapiclient.errors import HttpError
28
28
 
29
29
  from airflow.configuration import conf
30
- from airflow.exceptions import AirflowException
31
- from airflow.providers.common.compat.sdk import BaseHook
30
+ from airflow.providers.common.compat.sdk import AirflowException, BaseHook
32
31
  from airflow.providers.google.cloud.hooks.cloud_sql import CloudSQLDatabaseHook, CloudSQLHook
33
32
  from airflow.providers.google.cloud.links.cloud_sql import CloudSQLInstanceDatabaseLink, CloudSQLInstanceLink
34
33
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -25,8 +25,8 @@ from datetime import date, time, timedelta
25
25
  from typing import TYPE_CHECKING, Any
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException
29
28
  from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google.cloud.hooks.cloud_storage_transfer_service import (
31
31
  ACCESS_KEY_ID,
32
32
  AWS_ACCESS_KEY,
@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Any
26
26
  from google.api_core import exceptions
27
27
  from google.cloud.compute_v1.types import Instance, InstanceGroupManager, InstanceTemplate
28
28
 
29
- from airflow.exceptions import AirflowException
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google._vendor.json_merge_patch import merge
31
31
  from airflow.providers.google.cloud.hooks.compute import ComputeEngineHook
32
32
  from airflow.providers.google.cloud.links.compute import (
@@ -28,7 +28,7 @@ from typing import TYPE_CHECKING, Any
28
28
  from googleapiclient.errors import HttpError
29
29
 
30
30
  from airflow.configuration import conf
31
- from airflow.exceptions import AirflowException
31
+ from airflow.providers.common.compat.sdk import AirflowException
32
32
  from airflow.providers.google.cloud.hooks.dataflow import (
33
33
  DEFAULT_DATAFLOW_LOCATION,
34
34
  DataflowHook,
@@ -583,6 +583,7 @@ class DataflowStartFlexTemplateOperator(GoogleCloudBaseOperator):
583
583
  def hook(self) -> DataflowHook:
584
584
  hook = DataflowHook(
585
585
  gcp_conn_id=self.gcp_conn_id,
586
+ poll_sleep=self.poll_sleep,
586
587
  drain_pipeline=self.drain_pipeline,
587
588
  cancel_timeout=self.cancel_timeout,
588
589
  wait_until_finished=self.wait_until_finished,
@@ -26,7 +26,7 @@ from google.api_core.retry import exponential_sleep_generator
26
26
  from googleapiclient.errors import HttpError
27
27
 
28
28
  from airflow.configuration import conf
29
- from airflow.exceptions import AirflowException
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google.cloud.hooks.datafusion import SUCCESS_STATES, DataFusionHook, PipelineStates
31
31
  from airflow.providers.google.cloud.links.datafusion import (
32
32
  DataFusionInstanceLink,
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING, Any
25
25
 
26
26
  from google.protobuf.json_format import MessageToDict
27
27
 
28
- from airflow.exceptions import AirflowException
28
+ from airflow.providers.common.compat.sdk import AirflowException
29
29
  from airflow.providers.google.cloud.triggers.dataplex import (
30
30
  DataplexDataProfileJobTrigger,
31
31
  DataplexDataQualityJobTrigger,
@@ -36,7 +36,8 @@ from google.api_core.retry import Retry, exponential_sleep_generator
36
36
  from google.cloud.dataproc_v1 import Batch, Cluster, ClusterStatus, JobStatus
37
37
 
38
38
  from airflow.configuration import conf
39
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
39
+ from airflow.exceptions import AirflowProviderDeprecationWarning
40
+ from airflow.providers.common.compat.sdk import AirflowException
40
41
  from airflow.providers.google.cloud.hooks.dataproc import (
41
42
  DataprocHook,
42
43
  DataProcJobBuilder,
@@ -30,7 +30,7 @@ from google.cloud.metastore_v1 import MetadataExport, MetadataManagementActivity
30
30
  from google.cloud.metastore_v1.types import Backup, MetadataImport, Service
31
31
  from google.cloud.metastore_v1.types.metastore import DatabaseDumpSpec, Restore
32
32
 
33
- from airflow.exceptions import AirflowException
33
+ from airflow.providers.common.compat.sdk import AirflowException
34
34
  from airflow.providers.google.cloud.hooks.dataproc_metastore import DataprocMetastoreHook
35
35
  from airflow.providers.google.cloud.links.base import BaseGoogleLink
36
36
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -22,7 +22,7 @@ from __future__ import annotations
22
22
  from collections.abc import Sequence
23
23
  from typing import TYPE_CHECKING, Any
24
24
 
25
- from airflow.exceptions import AirflowException
25
+ from airflow.providers.common.compat.sdk import AirflowException
26
26
  from airflow.providers.google.cloud.hooks.datastore import DatastoreHook
27
27
  from airflow.providers.google.cloud.hooks.gcs import GCSHook
28
28
  from airflow.providers.google.cloud.links.datastore import (
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING, Any
25
25
 
26
26
  from googleapiclient.errors import HttpError
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.functions import CloudFunctionsHook
30
30
  from airflow.providers.google.cloud.links.cloud_functions import (
31
31
  CloudFunctionsDetailsLink,
@@ -38,7 +38,8 @@ if TYPE_CHECKING:
38
38
  from google.api_core.exceptions import Conflict
39
39
  from google.cloud.exceptions import GoogleCloudError
40
40
 
41
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
41
+ from airflow.exceptions import AirflowProviderDeprecationWarning
42
+ from airflow.providers.common.compat.sdk import AirflowException
42
43
  from airflow.providers.google.cloud.hooks.gcs import GCSHook
43
44
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
44
45
  from airflow.providers.google.common.links.storage import FileDetailsLink, StorageLink
@@ -29,7 +29,7 @@ from kubernetes.client import V1JobList, models as k8s
29
29
  from packaging.version import parse as parse_version
30
30
 
31
31
  from airflow.configuration import conf
32
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
32
+ from airflow.exceptions import AirflowProviderDeprecationWarning
33
33
  from airflow.providers.cncf.kubernetes.operators.job import KubernetesJobOperator
34
34
  from airflow.providers.cncf.kubernetes.operators.kueue import (
35
35
  KubernetesInstallKueueOperator,
@@ -41,6 +41,7 @@ from airflow.providers.cncf.kubernetes.operators.resource import (
41
41
  KubernetesDeleteResourceOperator,
42
42
  )
43
43
  from airflow.providers.cncf.kubernetes.utils.pod_manager import OnFinishAction
44
+ from airflow.providers.common.compat.sdk import AirflowException
44
45
  from airflow.providers.google.cloud.hooks.kubernetes_engine import (
45
46
  GKEHook,
46
47
  GKEKubernetesHook,
@@ -21,7 +21,7 @@ from __future__ import annotations
21
21
 
22
22
  from typing import TYPE_CHECKING
23
23
 
24
- from airflow.exceptions import AirflowException
24
+ from airflow.providers.common.compat.sdk import AirflowException
25
25
  from airflow.providers.google.cloud.hooks.looker import LookerHook
26
26
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
27
27
 
@@ -27,7 +27,7 @@ from google.api_core.exceptions import AlreadyExists, NotFound
27
27
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
28
  from google.cloud.managedkafka_v1 import types
29
29
 
30
- from airflow.exceptions import AirflowException
30
+ from airflow.providers.common.compat.sdk import AirflowException
31
31
  from airflow.providers.google.cloud.hooks.managed_kafka import ManagedKafkaHook
32
32
  from airflow.providers.google.cloud.links.managed_kafka import (
33
33
  ApacheKafkaClusterLink,
@@ -42,7 +42,7 @@ from google.cloud.pubsub_v1.types import (
42
42
  )
43
43
 
44
44
  from airflow.configuration import conf
45
- from airflow.exceptions import AirflowException
45
+ from airflow.providers.common.compat.sdk import AirflowException
46
46
  from airflow.providers.google.cloud.hooks.pubsub import PubSubHook
47
47
  from airflow.providers.google.cloud.links.pubsub import PubSubSubscriptionLink, PubSubTopicLink
48
48
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -680,6 +680,9 @@ class PubSubPublishMessageOperator(GoogleCloudBaseOperator):
680
680
  ordering_key in PubsubMessage will be delivered to the subscribers in the order
681
681
  in which they are received by the Pub/Sub system. Otherwise, they may be
682
682
  delivered in any order. Default is False.
683
+ :param enable_open_telemetry_tracing: If true, enables OpenTelemetry tracing for
684
+ published messages. This allows distributed tracing of messages as they flow
685
+ through Pub/Sub topics. Default is False.
683
686
  :param impersonation_chain: Optional service account to impersonate using short-term
684
687
  credentials, or chained list of accounts required to get the access_token
685
688
  of the last account in the list, which will be impersonated in the request.
@@ -695,6 +698,7 @@ class PubSubPublishMessageOperator(GoogleCloudBaseOperator):
695
698
  "topic",
696
699
  "messages",
697
700
  "enable_message_ordering",
701
+ "enable_open_telemetry_tracing",
698
702
  "impersonation_chain",
699
703
  )
700
704
  ui_color = "#0273d4"
@@ -707,6 +711,7 @@ class PubSubPublishMessageOperator(GoogleCloudBaseOperator):
707
711
  project_id: str = PROVIDE_PROJECT_ID,
708
712
  gcp_conn_id: str = "google_cloud_default",
709
713
  enable_message_ordering: bool = False,
714
+ enable_open_telemetry_tracing: bool = False,
710
715
  impersonation_chain: str | Sequence[str] | None = None,
711
716
  **kwargs,
712
717
  ) -> None:
@@ -716,6 +721,7 @@ class PubSubPublishMessageOperator(GoogleCloudBaseOperator):
716
721
  self.messages = messages
717
722
  self.gcp_conn_id = gcp_conn_id
718
723
  self.enable_message_ordering = enable_message_ordering
724
+ self.enable_open_telemetry_tracing = enable_open_telemetry_tracing
719
725
  self.impersonation_chain = impersonation_chain
720
726
 
721
727
  @cached_property
@@ -724,6 +730,7 @@ class PubSubPublishMessageOperator(GoogleCloudBaseOperator):
724
730
  gcp_conn_id=self.gcp_conn_id,
725
731
  impersonation_chain=self.impersonation_chain,
726
732
  enable_message_ordering=self.enable_message_ordering,
733
+ enable_open_telemetry_tracing=self.enable_open_telemetry_tracing,
727
734
  )
728
735
 
729
736
  def execute(self, context: Context) -> None:
@@ -23,7 +23,7 @@ from collections.abc import Sequence
23
23
  from functools import cached_property
24
24
  from typing import TYPE_CHECKING
25
25
 
26
- from airflow.exceptions import AirflowException
26
+ from airflow.providers.common.compat.sdk import AirflowException
27
27
  from airflow.providers.google.cloud.hooks.spanner import SpannerHook
28
28
  from airflow.providers.google.cloud.links.spanner import SpannerDatabaseLink, SpannerInstanceLink
29
29
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING
25
25
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
26
26
  from google.protobuf.json_format import MessageToDict
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.speech_to_text import CloudSpeechToTextHook, RecognitionAudio
30
30
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
31
31
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
@@ -25,7 +25,7 @@ from typing import TYPE_CHECKING
25
25
 
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.gcs import GCSHook
30
30
  from airflow.providers.google.cloud.hooks.text_to_speech import CloudTextToSpeechHook
31
31
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -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,
@@ -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
@@ -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,
@@ -30,7 +30,7 @@ from google.cloud.aiplatform_v1.types.dataset import Dataset
30
30
  from google.cloud.aiplatform_v1.types.training_pipeline import TrainingPipeline
31
31
 
32
32
  from airflow.configuration import conf
33
- from airflow.exceptions import AirflowException
33
+ from airflow.providers.common.compat.sdk import AirflowException
34
34
  from airflow.providers.google.cloud.hooks.vertex_ai.custom_job import CustomJobHook
35
35
  from airflow.providers.google.cloud.links.vertex_ai import (
36
36
  VertexAIModelLink,
@@ -26,7 +26,7 @@ from google.api_core.exceptions import NotFound
26
26
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
27
27
  from google.cloud.aiplatform_v1.types import Dataset, ExportDataConfig, ImportDataConfig
28
28
 
29
- from airflow.exceptions import AirflowException
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google.cloud.hooks.vertex_ai.dataset import DatasetHook
31
31
  from airflow.providers.google.cloud.links.vertex_ai import VertexAIDatasetLink, VertexAIDatasetListLink
32
32
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
@@ -22,7 +22,7 @@ from typing import TYPE_CHECKING
22
22
 
23
23
  from google.api_core import exceptions
24
24
 
25
- from airflow.exceptions import AirflowException
25
+ from airflow.providers.common.compat.sdk import AirflowException
26
26
  from airflow.providers.google.cloud.hooks.vertex_ai.experiment_service import (
27
27
  ExperimentHook,
28
28
  ExperimentRunHook,
@@ -26,7 +26,7 @@ from google.api_core.exceptions import GoogleAPICallError
26
26
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
27
27
  from google.cloud.aiplatform_v1beta1.types import FeatureViewDataFormat
28
28
 
29
- from airflow.exceptions import AirflowException
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google.cloud.hooks.vertex_ai.feature_store import FeatureStoreHook
31
31
  from airflow.providers.google.cloud.operators.cloud_base import GoogleCloudBaseOperator
32
32
  from airflow.providers.google.common.hooks.operation_helpers import OperationHelper
@@ -24,7 +24,8 @@ from typing import TYPE_CHECKING, Any, Literal
24
24
 
25
25
  from google.api_core import exceptions
26
26
 
27
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
27
+ from airflow.exceptions import AirflowProviderDeprecationWarning
28
+ from airflow.providers.common.compat.sdk import AirflowException
28
29
  from airflow.providers.google.cloud.hooks.vertex_ai.generative_model import (
29
30
  ExperimentRunHook,
30
31
  GenerativeModelHook,
@@ -28,7 +28,7 @@ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
28
  from google.cloud.aiplatform_v1 import types
29
29
 
30
30
  from airflow.configuration import conf
31
- from airflow.exceptions import AirflowException
31
+ from airflow.providers.common.compat.sdk import AirflowException
32
32
  from airflow.providers.google.cloud.hooks.vertex_ai.hyperparameter_tuning_job import (
33
33
  HyperparameterTuningJobHook,
34
34
  )
@@ -28,7 +28,7 @@ from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
28
28
  from google.cloud.aiplatform_v1 import types
29
29
 
30
30
  from airflow.configuration import conf
31
- from airflow.exceptions import AirflowException
31
+ from airflow.providers.common.compat.sdk import AirflowException
32
32
  from airflow.providers.google.cloud.hooks.vertex_ai.pipeline_job import PipelineJobHook
33
33
  from airflow.providers.google.cloud.links.vertex_ai import (
34
34
  VertexAIPipelineJobLink,
@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Literal
26
26
  from google.api_core.exceptions import NotFound
27
27
  from google.cloud.aiplatform.vertex_ray.util import resources
28
28
 
29
- from airflow.exceptions import AirflowException
29
+ from airflow.providers.common.compat.sdk import AirflowException
30
30
  from airflow.providers.google.cloud.hooks.vertex_ai.ray import RayHook
31
31
  from airflow.providers.google.cloud.links.vertex_ai import (
32
32
  VertexAIRayClusterLink,
@@ -23,7 +23,7 @@ from collections.abc import Sequence
23
23
 
24
24
  from google.auth.exceptions import DefaultCredentialsError
25
25
 
26
- from airflow.exceptions import AirflowException
26
+ from airflow.providers.common.compat.sdk import AirflowException
27
27
  from airflow.providers.google.cloud._internal_client.secret_manager_client import _SecretManagerClient
28
28
  from airflow.providers.google.cloud.utils.credentials_provider import (
29
29
  _get_target_principal_and_delegates,
@@ -160,11 +160,12 @@ class CloudSecretManagerBackend(BaseSecretsBackend, LoggingMixin):
160
160
 
161
161
  return self._get_secret(self.connections_prefix, conn_id)
162
162
 
163
- def get_variable(self, key: str) -> str | None:
163
+ def get_variable(self, key: str, team_name: str | None = None) -> str | None:
164
164
  """
165
165
  Get Airflow Variable from Environment Variable.
166
166
 
167
167
  :param key: Variable Key
168
+ :param team_name: Team name associated to the task trying to access the variable (if any)
168
169
  :return: Variable Value
169
170
  """
170
171
  if self.variables_prefix is None:
@@ -25,8 +25,8 @@ from datetime import timedelta
25
25
  from typing import TYPE_CHECKING, Any
26
26
 
27
27
  from airflow.configuration import conf
28
- from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
29
- from airflow.providers.common.compat.sdk import BaseSensorOperator
28
+ from airflow.exceptions import AirflowProviderDeprecationWarning
29
+ from airflow.providers.common.compat.sdk import AirflowException, BaseSensorOperator
30
30
  from airflow.providers.google.cloud.hooks.bigquery import BigQueryHook
31
31
  from airflow.providers.google.cloud.triggers.bigquery import (
32
32
  BigQueryTableExistenceTrigger,
@@ -25,8 +25,7 @@ from typing import TYPE_CHECKING
25
25
  from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
26
26
  from google.cloud.bigquery_datatransfer_v1 import TransferState
27
27
 
28
- from airflow.exceptions import AirflowException
29
- from airflow.providers.common.compat.sdk import BaseSensorOperator
28
+ from airflow.providers.common.compat.sdk import AirflowException, BaseSensorOperator
30
29
  from airflow.providers.google.cloud.hooks.bigquery_dts import BiqQueryDataTransferServiceHook
31
30
  from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID
32
31
 
@@ -30,8 +30,7 @@ from google.api_core.exceptions import NotFound
30
30
  from google.cloud.orchestration.airflow.service_v1.types import Environment, ExecuteAirflowCommandResponse
31
31
 
32
32
  from airflow.configuration import conf
33
- from airflow.exceptions import AirflowException
34
- from airflow.providers.common.compat.sdk import AirflowSkipException, BaseSensorOperator
33
+ from airflow.providers.common.compat.sdk import AirflowException, AirflowSkipException, BaseSensorOperator
35
34
  from airflow.providers.google.cloud.hooks.cloud_composer import CloudComposerHook
36
35
  from airflow.providers.google.cloud.triggers.cloud_composer import (
37
36
  CloudComposerDAGRunTrigger,
@@ -23,8 +23,7 @@ from collections.abc import Sequence
23
23
  from typing import TYPE_CHECKING, Any
24
24
 
25
25
  from airflow.configuration import conf
26
- from airflow.exceptions import AirflowException
27
- from airflow.providers.common.compat.sdk import BaseSensorOperator
26
+ from airflow.providers.common.compat.sdk import AirflowException, BaseSensorOperator
28
27
  from airflow.providers.google.cloud.hooks.cloud_storage_transfer_service import (
29
28
  COUNTERS,
30
29
  METADATA,