apache-airflow-providers-google 10.18.0rc2__py3-none-any.whl → 10.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/google/__init__.py +1 -1
- airflow/providers/google/cloud/hooks/bigquery.py +11 -10
- airflow/providers/google/cloud/links/automl.py +38 -0
- airflow/providers/google/cloud/links/translate.py +180 -0
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +1 -2
- airflow/providers/google/cloud/openlineage/BigQueryErrorRunFacet.json +30 -0
- airflow/providers/google/cloud/openlineage/BigQueryJobRunFacet.json +37 -0
- airflow/providers/google/cloud/openlineage/__init__.py +16 -0
- airflow/providers/google/cloud/openlineage/utils.py +388 -0
- airflow/providers/google/cloud/operators/automl.py +75 -63
- airflow/providers/google/cloud/operators/bigquery.py +1 -62
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +5 -0
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +6 -0
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +7 -4
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +1 -1
- airflow/providers/google/cloud/triggers/pubsub.py +8 -11
- airflow/providers/google/cloud/utils/credentials_provider.py +41 -32
- airflow/providers/google/common/hooks/base_google.py +11 -5
- airflow/providers/google/get_provider_info.py +8 -2
- {apache_airflow_providers_google-10.18.0rc2.dist-info → apache_airflow_providers_google-10.19.0.dist-info}/METADATA +14 -14
- {apache_airflow_providers_google-10.18.0rc2.dist-info → apache_airflow_providers_google-10.19.0.dist-info}/RECORD +24 -20
- airflow/providers/google/cloud/utils/openlineage.py +0 -81
- {apache_airflow_providers_google-10.18.0rc2.dist-info → apache_airflow_providers_google-10.19.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-10.18.0rc2.dist-info → apache_airflow_providers_google-10.19.0.dist-info}/entry_points.txt +0 -0
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
|
|
29
29
|
|
30
30
|
__all__ = ["__version__"]
|
31
31
|
|
32
|
-
__version__ = "10.
|
32
|
+
__version__ = "10.19.0"
|
33
33
|
|
34
34
|
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
35
35
|
"2.7.0"
|
@@ -1588,7 +1588,7 @@ class BigQueryHook(GoogleBaseHook, DbApiHook):
|
|
1588
1588
|
job_id: str,
|
1589
1589
|
project_id: str = PROVIDE_PROJECT_ID,
|
1590
1590
|
location: str | None = None,
|
1591
|
-
) ->
|
1591
|
+
) -> BigQueryJob | UnknownJob:
|
1592
1592
|
"""Retrieve a BigQuery job.
|
1593
1593
|
|
1594
1594
|
.. seealso:: https://cloud.google.com/bigquery/docs/reference/v2/jobs
|
@@ -1596,8 +1596,8 @@ class BigQueryHook(GoogleBaseHook, DbApiHook):
|
|
1596
1596
|
:param job_id: The ID of the job. The ID must contain only letters (a-z, A-Z),
|
1597
1597
|
numbers (0-9), underscores (_), or dashes (-). The maximum length is 1,024
|
1598
1598
|
characters.
|
1599
|
-
:param project_id: Google Cloud Project where the job is running
|
1600
|
-
:param location:
|
1599
|
+
:param project_id: Google Cloud Project where the job is running.
|
1600
|
+
:param location: Location where the job is running.
|
1601
1601
|
"""
|
1602
1602
|
client = self.get_client(project_id=project_id, location=location)
|
1603
1603
|
job = client.get_job(job_id=job_id, project=project_id, location=location)
|
@@ -2849,15 +2849,16 @@ class BigQueryCursor(BigQueryBaseCursor):
|
|
2849
2849
|
return -1
|
2850
2850
|
|
2851
2851
|
def execute(self, operation: str, parameters: dict | None = None) -> None:
|
2852
|
-
"""Execute a BigQuery query, and
|
2852
|
+
"""Execute a BigQuery query, and update the BigQueryCursor description.
|
2853
2853
|
|
2854
2854
|
:param operation: The query to execute.
|
2855
2855
|
:param parameters: Parameters to substitute into the query.
|
2856
2856
|
"""
|
2857
2857
|
sql = _bind_parameters(operation, parameters) if parameters else operation
|
2858
2858
|
self.flush_results()
|
2859
|
-
|
2860
|
-
|
2859
|
+
job = self._run_query(sql)
|
2860
|
+
self.job_id = job.job_id
|
2861
|
+
self.location = self.location or job.location
|
2861
2862
|
query_results = self._get_query_result()
|
2862
2863
|
if "schema" in query_results:
|
2863
2864
|
self.description = _format_schema_for_description(query_results["schema"])
|
@@ -2997,15 +2998,15 @@ class BigQueryCursor(BigQueryBaseCursor):
|
|
2997
2998
|
self,
|
2998
2999
|
sql,
|
2999
3000
|
location: str | None = None,
|
3000
|
-
) ->
|
3001
|
-
"""Run job query."""
|
3001
|
+
) -> BigQueryJob:
|
3002
|
+
"""Run a job query and return the job instance."""
|
3002
3003
|
if not self.project_id:
|
3003
3004
|
raise ValueError("The project_id should be set")
|
3004
3005
|
|
3005
3006
|
configuration = self._prepare_query_configuration(sql)
|
3006
3007
|
job = self.hook.insert_job(configuration=configuration, project_id=self.project_id, location=location)
|
3007
3008
|
|
3008
|
-
return job
|
3009
|
+
return job
|
3009
3010
|
|
3010
3011
|
def _prepare_query_configuration(
|
3011
3012
|
self,
|
@@ -3357,7 +3358,7 @@ class BigQueryAsyncHook(GoogleBaseAsyncHook):
|
|
3357
3358
|
|
3358
3359
|
async def _get_job(
|
3359
3360
|
self, job_id: str | None, project_id: str = PROVIDE_PROJECT_ID, location: str | None = None
|
3360
|
-
) ->
|
3361
|
+
) -> BigQueryJob | UnknownJob:
|
3361
3362
|
"""
|
3362
3363
|
Get BigQuery job by its ID, project ID and location.
|
3363
3364
|
|
@@ -21,6 +21,9 @@ from __future__ import annotations
|
|
21
21
|
|
22
22
|
from typing import TYPE_CHECKING
|
23
23
|
|
24
|
+
from deprecated import deprecated
|
25
|
+
|
26
|
+
from airflow.exceptions import AirflowProviderDeprecationWarning
|
24
27
|
from airflow.providers.google.cloud.links.base import BaseGoogleLink
|
25
28
|
|
26
29
|
if TYPE_CHECKING:
|
@@ -44,6 +47,13 @@ AUTOML_MODEL_PREDICT_LINK = (
|
|
44
47
|
)
|
45
48
|
|
46
49
|
|
50
|
+
@deprecated(
|
51
|
+
reason=(
|
52
|
+
"Class `AutoMLDatasetLink` has been deprecated and will be removed after 31.12.2024. "
|
53
|
+
"Please use `TranslationLegacyDatasetLink` from `airflow/providers/google/cloud/links/translate.py` instead."
|
54
|
+
),
|
55
|
+
category=AirflowProviderDeprecationWarning,
|
56
|
+
)
|
47
57
|
class AutoMLDatasetLink(BaseGoogleLink):
|
48
58
|
"""Helper class for constructing AutoML Dataset link."""
|
49
59
|
|
@@ -65,6 +75,13 @@ class AutoMLDatasetLink(BaseGoogleLink):
|
|
65
75
|
)
|
66
76
|
|
67
77
|
|
78
|
+
@deprecated(
|
79
|
+
reason=(
|
80
|
+
"Class `AutoMLDatasetListLink` has been deprecated and will be removed after 31.12.2024. "
|
81
|
+
"Please use `TranslationDatasetListLink` from `airflow/providers/google/cloud/links/translate.py` instead."
|
82
|
+
),
|
83
|
+
category=AirflowProviderDeprecationWarning,
|
84
|
+
)
|
68
85
|
class AutoMLDatasetListLink(BaseGoogleLink):
|
69
86
|
"""Helper class for constructing AutoML Dataset List link."""
|
70
87
|
|
@@ -87,6 +104,13 @@ class AutoMLDatasetListLink(BaseGoogleLink):
|
|
87
104
|
)
|
88
105
|
|
89
106
|
|
107
|
+
@deprecated(
|
108
|
+
reason=(
|
109
|
+
"Class `AutoMLModelLink` has been deprecated and will be removed after 31.12.2024. "
|
110
|
+
"Please use `TranslationLegacyModelLink` from `airflow/providers/google/cloud/links/translate.py` instead."
|
111
|
+
),
|
112
|
+
category=AirflowProviderDeprecationWarning,
|
113
|
+
)
|
90
114
|
class AutoMLModelLink(BaseGoogleLink):
|
91
115
|
"""Helper class for constructing AutoML Model link."""
|
92
116
|
|
@@ -114,6 +138,13 @@ class AutoMLModelLink(BaseGoogleLink):
|
|
114
138
|
)
|
115
139
|
|
116
140
|
|
141
|
+
@deprecated(
|
142
|
+
reason=(
|
143
|
+
"Class `AutoMLModelTrainLink` has been deprecated and will be removed after 31.12.2024. "
|
144
|
+
"Please use `TranslationLegacyModelTrainLink` from `airflow/providers/google/cloud/links/translate.py` instead."
|
145
|
+
),
|
146
|
+
category=AirflowProviderDeprecationWarning,
|
147
|
+
)
|
117
148
|
class AutoMLModelTrainLink(BaseGoogleLink):
|
118
149
|
"""Helper class for constructing AutoML Model Train link."""
|
119
150
|
|
@@ -138,6 +169,13 @@ class AutoMLModelTrainLink(BaseGoogleLink):
|
|
138
169
|
)
|
139
170
|
|
140
171
|
|
172
|
+
@deprecated(
|
173
|
+
reason=(
|
174
|
+
"Class `AutoMLModelPredictLink` has been deprecated and will be removed after 31.12.2024. "
|
175
|
+
"Please use `TranslationLegacyModelPredictLink` from `airflow/providers/google/cloud/links/translate.py` instead."
|
176
|
+
),
|
177
|
+
category=AirflowProviderDeprecationWarning,
|
178
|
+
)
|
141
179
|
class AutoMLModelPredictLink(BaseGoogleLink):
|
142
180
|
"""Helper class for constructing AutoML Model Predict link."""
|
143
181
|
|
@@ -0,0 +1,180 @@
|
|
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
|
+
"""This module contains Google Translate links."""
|
18
|
+
|
19
|
+
from __future__ import annotations
|
20
|
+
|
21
|
+
from typing import TYPE_CHECKING
|
22
|
+
|
23
|
+
from airflow.providers.google.cloud.links.base import BASE_LINK, BaseGoogleLink
|
24
|
+
|
25
|
+
if TYPE_CHECKING:
|
26
|
+
from airflow.utils.context import Context
|
27
|
+
|
28
|
+
|
29
|
+
TRANSLATION_BASE_LINK = BASE_LINK + "/translation"
|
30
|
+
TRANSLATION_LEGACY_DATASET_LINK = (
|
31
|
+
TRANSLATION_BASE_LINK + "/locations/{location}/datasets/{dataset_id}/sentences?project={project_id}"
|
32
|
+
)
|
33
|
+
TRANSLATION_DATASET_LIST_LINK = TRANSLATION_BASE_LINK + "/datasets?project={project_id}"
|
34
|
+
TRANSLATION_LEGACY_MODEL_LINK = (
|
35
|
+
TRANSLATION_BASE_LINK
|
36
|
+
+ "/locations/{location}/datasets/{dataset_id}/evaluate;modelId={model_id}?project={project_id}"
|
37
|
+
)
|
38
|
+
TRANSLATION_LEGACY_MODEL_TRAIN_LINK = (
|
39
|
+
TRANSLATION_BASE_LINK + "/locations/{location}/datasets/{dataset_id}/train?project={project_id}"
|
40
|
+
)
|
41
|
+
TRANSLATION_LEGACY_MODEL_PREDICT_LINK = (
|
42
|
+
TRANSLATION_BASE_LINK
|
43
|
+
+ "/locations/{location}/datasets/{dataset_id}/predict;modelId={model_id}?project={project_id}"
|
44
|
+
)
|
45
|
+
|
46
|
+
|
47
|
+
class TranslationLegacyDatasetLink(BaseGoogleLink):
|
48
|
+
"""
|
49
|
+
Helper class for constructing Legacy Translation Dataset link.
|
50
|
+
|
51
|
+
Legacy Datasets are created and managed by AutoML API.
|
52
|
+
"""
|
53
|
+
|
54
|
+
name = "Translation Legacy Dataset"
|
55
|
+
key = "translation_legacy_dataset"
|
56
|
+
format_str = TRANSLATION_LEGACY_DATASET_LINK
|
57
|
+
|
58
|
+
@staticmethod
|
59
|
+
def persist(
|
60
|
+
context: Context,
|
61
|
+
task_instance,
|
62
|
+
dataset_id: str,
|
63
|
+
project_id: str,
|
64
|
+
):
|
65
|
+
task_instance.xcom_push(
|
66
|
+
context,
|
67
|
+
key=TranslationLegacyDatasetLink.key,
|
68
|
+
value={"location": task_instance.location, "dataset_id": dataset_id, "project_id": project_id},
|
69
|
+
)
|
70
|
+
|
71
|
+
|
72
|
+
class TranslationDatasetListLink(BaseGoogleLink):
|
73
|
+
"""Helper class for constructing Translation Dataset List link."""
|
74
|
+
|
75
|
+
name = "Translation Dataset List"
|
76
|
+
key = "translation_dataset_list"
|
77
|
+
format_str = TRANSLATION_DATASET_LIST_LINK
|
78
|
+
|
79
|
+
@staticmethod
|
80
|
+
def persist(
|
81
|
+
context: Context,
|
82
|
+
task_instance,
|
83
|
+
project_id: str,
|
84
|
+
):
|
85
|
+
task_instance.xcom_push(
|
86
|
+
context,
|
87
|
+
key=TranslationDatasetListLink.key,
|
88
|
+
value={
|
89
|
+
"project_id": project_id,
|
90
|
+
},
|
91
|
+
)
|
92
|
+
|
93
|
+
|
94
|
+
class TranslationLegacyModelLink(BaseGoogleLink):
|
95
|
+
"""
|
96
|
+
Helper class for constructing Translation Legacy Model link.
|
97
|
+
|
98
|
+
Legacy Models are created and managed by AutoML API.
|
99
|
+
"""
|
100
|
+
|
101
|
+
name = "Translation Legacy Model"
|
102
|
+
key = "translation_legacy_model"
|
103
|
+
format_str = TRANSLATION_LEGACY_MODEL_LINK
|
104
|
+
|
105
|
+
@staticmethod
|
106
|
+
def persist(
|
107
|
+
context: Context,
|
108
|
+
task_instance,
|
109
|
+
dataset_id: str,
|
110
|
+
model_id: str,
|
111
|
+
project_id: str,
|
112
|
+
):
|
113
|
+
task_instance.xcom_push(
|
114
|
+
context,
|
115
|
+
key=TranslationLegacyModelLink.key,
|
116
|
+
value={
|
117
|
+
"location": task_instance.location,
|
118
|
+
"dataset_id": dataset_id,
|
119
|
+
"model_id": model_id,
|
120
|
+
"project_id": project_id,
|
121
|
+
},
|
122
|
+
)
|
123
|
+
|
124
|
+
|
125
|
+
class TranslationLegacyModelTrainLink(BaseGoogleLink):
|
126
|
+
"""
|
127
|
+
Helper class for constructing Translation Legacy Model Train link.
|
128
|
+
|
129
|
+
Legacy Models are created and managed by AutoML API.
|
130
|
+
"""
|
131
|
+
|
132
|
+
name = "Translation Legacy Model Train"
|
133
|
+
key = "translation_legacy_model_train"
|
134
|
+
format_str = TRANSLATION_LEGACY_MODEL_TRAIN_LINK
|
135
|
+
|
136
|
+
@staticmethod
|
137
|
+
def persist(
|
138
|
+
context: Context,
|
139
|
+
task_instance,
|
140
|
+
project_id: str,
|
141
|
+
):
|
142
|
+
task_instance.xcom_push(
|
143
|
+
context,
|
144
|
+
key=TranslationLegacyModelTrainLink.key,
|
145
|
+
value={
|
146
|
+
"location": task_instance.location,
|
147
|
+
"dataset_id": task_instance.model["dataset_id"],
|
148
|
+
"project_id": project_id,
|
149
|
+
},
|
150
|
+
)
|
151
|
+
|
152
|
+
|
153
|
+
class TranslationLegacyModelPredictLink(BaseGoogleLink):
|
154
|
+
"""
|
155
|
+
Helper class for constructing Translation Legacy Model Predict link.
|
156
|
+
|
157
|
+
Legacy Models are created and managed by AutoML API.
|
158
|
+
"""
|
159
|
+
|
160
|
+
name = "Translation Legacy Model Predict"
|
161
|
+
key = "translation_legacy_model_predict"
|
162
|
+
format_str = TRANSLATION_LEGACY_MODEL_PREDICT_LINK
|
163
|
+
|
164
|
+
@staticmethod
|
165
|
+
def persist(
|
166
|
+
context: Context,
|
167
|
+
task_instance,
|
168
|
+
model_id: str,
|
169
|
+
project_id: str,
|
170
|
+
):
|
171
|
+
task_instance.xcom_push(
|
172
|
+
context,
|
173
|
+
key=TranslationLegacyModelPredictLink.key,
|
174
|
+
value={
|
175
|
+
"location": task_instance.location,
|
176
|
+
"dataset_id": task_instance.model.dataset_id,
|
177
|
+
"model_id": model_id,
|
178
|
+
"project_id": project_id,
|
179
|
+
},
|
180
|
+
)
|
@@ -180,8 +180,7 @@ class StackdriverTaskHandler(logging.Handler):
|
|
180
180
|
"""
|
181
181
|
message = self.format(record)
|
182
182
|
ti = None
|
183
|
-
|
184
|
-
if ctx_indiv_trigger is not None and getattr(record, ctx_indiv_trigger.name, None):
|
183
|
+
if getattr(record, ctx_indiv_trigger.name, None):
|
185
184
|
ti = getattr(record, "task_instance", None) # trigger context
|
186
185
|
labels = self._get_labels(ti)
|
187
186
|
self._transport.send(record, message, resource=self.resource, labels=labels)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$defs": {
|
4
|
+
"BigQueryErrorRunFacet": {
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "https://openlineage.io/spec/2-0-2/OpenLineage.json#/$defs/RunFacet"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"type": "object",
|
11
|
+
"properties": {
|
12
|
+
"clientError": {
|
13
|
+
"type": "string"
|
14
|
+
},
|
15
|
+
"parserError": {
|
16
|
+
"type": "string"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"type": "object"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"type": "object",
|
25
|
+
"properties": {
|
26
|
+
"bigQuery_error": {
|
27
|
+
"$ref": "#/$defs/BigQueryErrorRunFacet"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
3
|
+
"$defs": {
|
4
|
+
"BigQueryJobRunFacet": {
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "https://openlineage.io/spec/2-0-2/OpenLineage.json#/$defs/RunFacet"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"type": "object",
|
11
|
+
"properties": {
|
12
|
+
"cached": {
|
13
|
+
"type": "boolean"
|
14
|
+
},
|
15
|
+
"billedBytes": {
|
16
|
+
"type": "int",
|
17
|
+
"example": 321
|
18
|
+
},
|
19
|
+
"properties": {
|
20
|
+
"type": "string"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"required": [
|
24
|
+
"cached"
|
25
|
+
]
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"type": "object"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"type": "object",
|
32
|
+
"properties": {
|
33
|
+
"bigQueryJob": {
|
34
|
+
"$ref": "#/$defs/BigQueryJobRunFacet"
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,16 @@
|
|
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.
|