apache-airflow-providers-google 10.26.0rc1__py3-none-any.whl → 11.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/google/__init__.py +1 -1
- airflow/providers/google/ads/hooks/ads.py +2 -1
- airflow/providers/google/ads/operators/ads.py +2 -1
- airflow/providers/google/ads/transfers/ads_to_gcs.py +2 -1
- airflow/providers/google/assets/gcs.py +17 -1
- airflow/providers/google/cloud/hooks/automl.py +3 -6
- airflow/providers/google/cloud/hooks/bigquery.py +41 -1486
- airflow/providers/google/cloud/hooks/bigquery_dts.py +4 -11
- airflow/providers/google/cloud/hooks/bigtable.py +3 -6
- airflow/providers/google/cloud/hooks/cloud_batch.py +6 -3
- airflow/providers/google/cloud/hooks/cloud_build.py +3 -15
- airflow/providers/google/cloud/hooks/cloud_composer.py +2 -17
- airflow/providers/google/cloud/hooks/cloud_memorystore.py +5 -6
- airflow/providers/google/cloud/hooks/cloud_run.py +10 -5
- airflow/providers/google/cloud/hooks/cloud_sql.py +5 -7
- airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +3 -7
- airflow/providers/google/cloud/hooks/compute.py +3 -6
- airflow/providers/google/cloud/hooks/compute_ssh.py +0 -5
- airflow/providers/google/cloud/hooks/datacatalog.py +3 -6
- airflow/providers/google/cloud/hooks/dataflow.py +3 -14
- airflow/providers/google/cloud/hooks/dataform.py +2 -9
- airflow/providers/google/cloud/hooks/datafusion.py +4 -15
- airflow/providers/google/cloud/hooks/dataplex.py +4 -7
- airflow/providers/google/cloud/hooks/dataprep.py +2 -2
- airflow/providers/google/cloud/hooks/dataproc.py +77 -22
- airflow/providers/google/cloud/hooks/dataproc_metastore.py +2 -9
- airflow/providers/google/cloud/hooks/datastore.py +3 -6
- airflow/providers/google/cloud/hooks/dlp.py +3 -6
- airflow/providers/google/cloud/hooks/functions.py +2 -6
- airflow/providers/google/cloud/hooks/gcs.py +2 -18
- airflow/providers/google/cloud/hooks/gdm.py +1 -17
- airflow/providers/google/cloud/hooks/kms.py +3 -6
- airflow/providers/google/cloud/hooks/kubernetes_engine.py +7 -97
- airflow/providers/google/cloud/hooks/life_sciences.py +2 -6
- airflow/providers/google/cloud/hooks/looker.py +2 -1
- airflow/providers/google/cloud/hooks/mlengine.py +0 -8
- airflow/providers/google/cloud/hooks/natural_language.py +3 -6
- airflow/providers/google/cloud/hooks/os_login.py +3 -6
- airflow/providers/google/cloud/hooks/pubsub.py +3 -6
- airflow/providers/google/cloud/hooks/secret_manager.py +3 -73
- airflow/providers/google/cloud/hooks/spanner.py +3 -6
- airflow/providers/google/cloud/hooks/speech_to_text.py +3 -6
- airflow/providers/google/cloud/hooks/stackdriver.py +3 -6
- airflow/providers/google/cloud/hooks/tasks.py +3 -6
- airflow/providers/google/cloud/hooks/text_to_speech.py +3 -6
- airflow/providers/google/cloud/hooks/translate.py +455 -9
- airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +1 -14
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +3 -6
- airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +2 -9
- airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +3 -1
- airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +2 -1
- airflow/providers/google/cloud/hooks/video_intelligence.py +3 -6
- airflow/providers/google/cloud/hooks/vision.py +3 -6
- airflow/providers/google/cloud/hooks/workflows.py +2 -9
- airflow/providers/google/cloud/links/dataproc.py +0 -1
- airflow/providers/google/cloud/links/translate.py +91 -0
- airflow/providers/google/cloud/log/gcs_task_handler.py +2 -1
- airflow/providers/google/cloud/log/stackdriver_task_handler.py +11 -3
- airflow/providers/google/cloud/openlineage/utils.py +54 -21
- airflow/providers/google/cloud/operators/automl.py +5 -4
- airflow/providers/google/cloud/operators/bigquery.py +2 -341
- airflow/providers/google/cloud/operators/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/operators/bigtable.py +2 -1
- airflow/providers/google/cloud/operators/cloud_batch.py +2 -1
- airflow/providers/google/cloud/operators/cloud_build.py +2 -1
- airflow/providers/google/cloud/operators/cloud_composer.py +2 -1
- airflow/providers/google/cloud/operators/cloud_memorystore.py +2 -1
- airflow/providers/google/cloud/operators/cloud_run.py +2 -1
- airflow/providers/google/cloud/operators/cloud_sql.py +2 -1
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/operators/compute.py +2 -1
- airflow/providers/google/cloud/operators/datacatalog.py +2 -1
- airflow/providers/google/cloud/operators/dataflow.py +2 -517
- airflow/providers/google/cloud/operators/dataform.py +2 -1
- airflow/providers/google/cloud/operators/datafusion.py +2 -1
- airflow/providers/google/cloud/operators/dataplex.py +37 -31
- airflow/providers/google/cloud/operators/dataprep.py +2 -1
- airflow/providers/google/cloud/operators/dataproc.py +3 -633
- airflow/providers/google/cloud/operators/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/operators/datastore.py +2 -1
- airflow/providers/google/cloud/operators/dlp.py +2 -1
- airflow/providers/google/cloud/operators/functions.py +2 -1
- airflow/providers/google/cloud/operators/gcs.py +5 -4
- airflow/providers/google/cloud/operators/kubernetes_engine.py +2 -11
- airflow/providers/google/cloud/operators/life_sciences.py +2 -1
- airflow/providers/google/cloud/operators/mlengine.py +2 -1
- airflow/providers/google/cloud/operators/natural_language.py +3 -2
- airflow/providers/google/cloud/operators/pubsub.py +2 -1
- airflow/providers/google/cloud/operators/spanner.py +2 -1
- airflow/providers/google/cloud/operators/speech_to_text.py +2 -1
- airflow/providers/google/cloud/operators/stackdriver.py +2 -1
- airflow/providers/google/cloud/operators/tasks.py +3 -2
- airflow/providers/google/cloud/operators/text_to_speech.py +2 -1
- airflow/providers/google/cloud/operators/translate.py +622 -32
- airflow/providers/google/cloud/operators/translate_speech.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +2 -93
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +2 -17
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +3 -13
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +2 -1
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +2 -1
- airflow/providers/google/cloud/operators/video_intelligence.py +2 -1
- airflow/providers/google/cloud/operators/vision.py +3 -2
- airflow/providers/google/cloud/operators/workflows.py +3 -2
- airflow/providers/google/cloud/secrets/secret_manager.py +2 -19
- airflow/providers/google/cloud/sensors/bigquery.py +2 -81
- airflow/providers/google/cloud/sensors/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/sensors/bigtable.py +2 -1
- airflow/providers/google/cloud/sensors/cloud_composer.py +8 -94
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/sensors/dataflow.py +2 -1
- airflow/providers/google/cloud/sensors/dataform.py +2 -1
- airflow/providers/google/cloud/sensors/datafusion.py +2 -1
- airflow/providers/google/cloud/sensors/dataplex.py +2 -1
- airflow/providers/google/cloud/sensors/dataprep.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc.py +2 -1
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +2 -1
- airflow/providers/google/cloud/sensors/gcs.py +4 -36
- airflow/providers/google/cloud/sensors/pubsub.py +2 -1
- airflow/providers/google/cloud/sensors/tasks.py +2 -1
- airflow/providers/google/cloud/sensors/workflows.py +2 -1
- airflow/providers/google/cloud/transfers/adls_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +75 -18
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +9 -7
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +2 -1
- airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +1 -1
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +2 -1
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +13 -9
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/gdrive_to_local.py +2 -1
- airflow/providers/google/cloud/transfers/local_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/mssql_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/s3_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sheets_to_gcs.py +2 -1
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery.py +2 -1
- airflow/providers/google/cloud/triggers/bigquery_dts.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_batch.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_build.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_composer.py +3 -2
- airflow/providers/google/cloud/triggers/cloud_run.py +2 -1
- airflow/providers/google/cloud/triggers/cloud_sql.py +1 -1
- airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +2 -1
- airflow/providers/google/cloud/triggers/dataflow.py +2 -1
- airflow/providers/google/cloud/triggers/datafusion.py +2 -1
- airflow/providers/google/cloud/triggers/dataplex.py +1 -1
- airflow/providers/google/cloud/triggers/dataproc.py +2 -1
- airflow/providers/google/cloud/triggers/gcs.py +3 -2
- airflow/providers/google/cloud/triggers/kubernetes_engine.py +2 -1
- airflow/providers/google/cloud/triggers/mlengine.py +2 -1
- airflow/providers/google/cloud/triggers/pubsub.py +2 -1
- airflow/providers/google/cloud/triggers/vertex_ai.py +2 -1
- airflow/providers/google/cloud/utils/credentials_provider.py +1 -1
- airflow/providers/google/cloud/utils/dataform.py +1 -1
- airflow/providers/google/cloud/utils/field_validator.py +2 -1
- airflow/providers/google/cloud/utils/mlengine_operator_utils.py +2 -1
- airflow/providers/google/common/hooks/base_google.py +4 -11
- airflow/providers/google/common/hooks/discovery_api.py +1 -6
- airflow/providers/google/firebase/hooks/firestore.py +1 -1
- airflow/providers/google/firebase/operators/firestore.py +2 -1
- airflow/providers/google/get_provider_info.py +7 -22
- airflow/providers/google/marketing_platform/hooks/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/hooks/campaign_manager.py +2 -3
- airflow/providers/google/marketing_platform/hooks/display_video.py +4 -3
- airflow/providers/google/marketing_platform/hooks/search_ads.py +6 -6
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +2 -1
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +2 -42
- airflow/providers/google/marketing_platform/operators/display_video.py +2 -47
- airflow/providers/google/marketing_platform/operators/search_ads.py +2 -1
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +2 -7
- airflow/providers/google/marketing_platform/sensors/display_video.py +2 -13
- airflow/providers/google/suite/hooks/calendar.py +2 -8
- airflow/providers/google/suite/hooks/drive.py +2 -6
- airflow/providers/google/suite/hooks/sheets.py +2 -7
- airflow/providers/google/suite/operators/sheets.py +2 -7
- airflow/providers/google/suite/sensors/drive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +2 -7
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +2 -7
- airflow/providers/google/suite/transfers/local_to_drive.py +2 -7
- airflow/providers/google/suite/transfers/sql_to_sheets.py +2 -7
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/METADATA +17 -17
- apache_airflow_providers_google-11.0.0.dist-info/RECORD +315 -0
- airflow/providers/google/marketing_platform/hooks/analytics.py +0 -211
- airflow/providers/google/marketing_platform/operators/analytics.py +0 -551
- apache_airflow_providers_google-10.26.0rc1.dist-info/RECORD +0 -317
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-10.26.0rc1.dist-info → apache_airflow_providers_google-11.0.0.dist-info}/entry_points.txt +0 -0
@@ -19,12 +19,49 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from
|
22
|
+
from collections.abc import MutableMapping, MutableSequence, Sequence
|
23
|
+
from typing import (
|
24
|
+
TYPE_CHECKING,
|
25
|
+
cast,
|
26
|
+
)
|
23
27
|
|
28
|
+
from google.api_core.exceptions import GoogleAPICallError
|
29
|
+
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
30
|
+
from google.api_core.retry import Retry
|
24
31
|
from google.cloud.translate_v2 import Client
|
32
|
+
from google.cloud.translate_v3 import TranslationServiceClient
|
25
33
|
|
34
|
+
from airflow.exceptions import AirflowException
|
26
35
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
27
|
-
from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
|
36
|
+
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
37
|
+
|
38
|
+
if TYPE_CHECKING:
|
39
|
+
from google.api_core.operation import Operation
|
40
|
+
from google.cloud.translate_v3.services.translation_service import pagers
|
41
|
+
from google.cloud.translate_v3.types import (
|
42
|
+
DatasetInputConfig,
|
43
|
+
InputConfig,
|
44
|
+
OutputConfig,
|
45
|
+
TranslateTextGlossaryConfig,
|
46
|
+
TransliterationConfig,
|
47
|
+
automl_translation,
|
48
|
+
)
|
49
|
+
from proto import Message
|
50
|
+
|
51
|
+
|
52
|
+
class WaitOperationNotDoneYetError(Exception):
|
53
|
+
"""Wait operation not done yet error."""
|
54
|
+
|
55
|
+
pass
|
56
|
+
|
57
|
+
|
58
|
+
def _if_exc_is_wait_failed_error(exc: Exception):
|
59
|
+
return isinstance(exc, WaitOperationNotDoneYetError)
|
60
|
+
|
61
|
+
|
62
|
+
def _check_if_operation_done(operation: Operation):
|
63
|
+
if not operation.done():
|
64
|
+
raise WaitOperationNotDoneYetError("Operation is not done yet.")
|
28
65
|
|
29
66
|
|
30
67
|
class CloudTranslateHook(GoogleBaseHook):
|
@@ -41,14 +78,10 @@ class CloudTranslateHook(GoogleBaseHook):
|
|
41
78
|
impersonation_chain: str | Sequence[str] | None = None,
|
42
79
|
**kwargs,
|
43
80
|
) -> None:
|
44
|
-
if kwargs.get("delegate_to") is not None:
|
45
|
-
raise RuntimeError(
|
46
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
47
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
48
|
-
)
|
49
81
|
super().__init__(
|
50
82
|
gcp_conn_id=gcp_conn_id,
|
51
83
|
impersonation_chain=impersonation_chain,
|
84
|
+
**kwargs,
|
52
85
|
)
|
53
86
|
self._client: Client | None = None
|
54
87
|
|
@@ -85,7 +118,7 @@ class CloudTranslateHook(GoogleBaseHook):
|
|
85
118
|
:param source_language: (Optional) The language of the text to
|
86
119
|
be translated.
|
87
120
|
:param model: (Optional) The model used to translate the text, such
|
88
|
-
as ``'base'`` or ``'
|
121
|
+
as ``'base'`` or ``'NMT'``.
|
89
122
|
:returns: A list of dictionaries for each queried value. Each
|
90
123
|
dictionary typically contains three keys (though not
|
91
124
|
all will be present in all cases)
|
@@ -106,7 +139,6 @@ class CloudTranslateHook(GoogleBaseHook):
|
|
106
139
|
values and translations differ.
|
107
140
|
"""
|
108
141
|
client = self.get_conn()
|
109
|
-
|
110
142
|
return client.translate(
|
111
143
|
values=values,
|
112
144
|
target_language=target_language,
|
@@ -114,3 +146,417 @@ class CloudTranslateHook(GoogleBaseHook):
|
|
114
146
|
source_language=source_language,
|
115
147
|
model=model,
|
116
148
|
)
|
149
|
+
|
150
|
+
|
151
|
+
class TranslateHook(GoogleBaseHook):
|
152
|
+
"""
|
153
|
+
Hook for Google Cloud translation (Advanced) using client version V3.
|
154
|
+
|
155
|
+
See related docs https://cloud.google.com/translate/docs/editions#advanced.
|
156
|
+
"""
|
157
|
+
|
158
|
+
def __init__(
|
159
|
+
self,
|
160
|
+
gcp_conn_id: str = "google_cloud_default",
|
161
|
+
impersonation_chain: str | Sequence[str] | None = None,
|
162
|
+
**kwargs,
|
163
|
+
) -> None:
|
164
|
+
super().__init__(
|
165
|
+
gcp_conn_id=gcp_conn_id,
|
166
|
+
impersonation_chain=impersonation_chain,
|
167
|
+
)
|
168
|
+
self._client: TranslationServiceClient | None = None
|
169
|
+
|
170
|
+
def get_client(self) -> TranslationServiceClient:
|
171
|
+
"""
|
172
|
+
Retrieve TranslationService client.
|
173
|
+
|
174
|
+
:return: Google Cloud Translation Service client object.
|
175
|
+
"""
|
176
|
+
if self._client is None:
|
177
|
+
self._client = TranslationServiceClient(
|
178
|
+
credentials=self.get_credentials(), client_info=CLIENT_INFO
|
179
|
+
)
|
180
|
+
return self._client
|
181
|
+
|
182
|
+
@staticmethod
|
183
|
+
def wait_for_operation_done(
|
184
|
+
*,
|
185
|
+
operation: Operation,
|
186
|
+
timeout: float | None = None,
|
187
|
+
initial: float = 3,
|
188
|
+
multiplier: float = 2,
|
189
|
+
maximum: float = 3600,
|
190
|
+
) -> None:
|
191
|
+
"""
|
192
|
+
Wait for long-running operation to be done.
|
193
|
+
|
194
|
+
Calls operation.done() until success or timeout exhaustion, following the back-off retry strategy.
|
195
|
+
See `google.api_core.retry.Retry`.
|
196
|
+
It's intended use on `Operation` instances that have empty result
|
197
|
+
(:class `google.protobuf.empty_pb2.Empty`) by design.
|
198
|
+
Thus calling operation.result() for such operation triggers the exception
|
199
|
+
``GoogleAPICallError("Unexpected state: Long-running operation had neither response nor error set.")``
|
200
|
+
even though operation itself is totally fine.
|
201
|
+
"""
|
202
|
+
wait_op_for_done = Retry(
|
203
|
+
predicate=_if_exc_is_wait_failed_error,
|
204
|
+
initial=initial,
|
205
|
+
timeout=timeout,
|
206
|
+
multiplier=multiplier,
|
207
|
+
maximum=maximum,
|
208
|
+
)(_check_if_operation_done)
|
209
|
+
try:
|
210
|
+
wait_op_for_done(operation=operation)
|
211
|
+
except GoogleAPICallError:
|
212
|
+
if timeout:
|
213
|
+
timeout = int(timeout)
|
214
|
+
error = operation.exception(timeout=timeout)
|
215
|
+
raise AirflowException(error)
|
216
|
+
|
217
|
+
@staticmethod
|
218
|
+
def wait_for_operation_result(operation: Operation, timeout: int | None = None) -> Message:
|
219
|
+
"""Wait for long-lasting operation to complete."""
|
220
|
+
try:
|
221
|
+
return operation.result(timeout=timeout)
|
222
|
+
except GoogleAPICallError:
|
223
|
+
error = operation.exception(timeout=timeout)
|
224
|
+
raise AirflowException(error)
|
225
|
+
|
226
|
+
@staticmethod
|
227
|
+
def extract_object_id(obj: dict) -> str:
|
228
|
+
"""Return unique id of the object."""
|
229
|
+
return obj["name"].rpartition("/")[-1]
|
230
|
+
|
231
|
+
def translate_text(
|
232
|
+
self,
|
233
|
+
*,
|
234
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
235
|
+
contents: Sequence[str],
|
236
|
+
target_language_code: str,
|
237
|
+
source_language_code: str | None = None,
|
238
|
+
mime_type: str | None = None,
|
239
|
+
location: str | None = None,
|
240
|
+
model: str | None = None,
|
241
|
+
transliteration_config: TransliterationConfig | None = None,
|
242
|
+
glossary_config: TranslateTextGlossaryConfig | None = None,
|
243
|
+
labels: str | None = None,
|
244
|
+
timeout: float | _MethodDefault = DEFAULT,
|
245
|
+
metadata: Sequence[tuple[str, str]] = (),
|
246
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
247
|
+
) -> dict:
|
248
|
+
"""
|
249
|
+
Translate text content provided.
|
250
|
+
|
251
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
252
|
+
:param contents: Required. The content of the input in string
|
253
|
+
format. Max length 1024 items with 30_000 codepoints recommended.
|
254
|
+
:param mime_type: Optional. The format of the source text, If left
|
255
|
+
blank, the MIME type defaults to "text/html".
|
256
|
+
:param source_language_code: Optional. The ISO-639 language code of the
|
257
|
+
input text if known. If the source language
|
258
|
+
isn't specified, the API attempts to identify
|
259
|
+
the source language automatically and returns
|
260
|
+
the source language within the response.
|
261
|
+
:param target_language_code: Required. The ISO-639 language code to use
|
262
|
+
for translation of the input text
|
263
|
+
:param location: Optional. Project or location to make a call. Must refer to
|
264
|
+
a caller's project.
|
265
|
+
If not specified, 'global' is used.
|
266
|
+
Non-global location is required for requests using AutoML
|
267
|
+
models or custom glossaries.
|
268
|
+
Models and glossaries must be within the same region (have
|
269
|
+
the same location-id).
|
270
|
+
:param model: Optional. The ``model`` type requested for this translation.
|
271
|
+
If not provided, the default Google model (NMT) will be used.
|
272
|
+
The format depends on model type:
|
273
|
+
|
274
|
+
- AutoML Translation models:
|
275
|
+
``projects/{project-number-or-id}/locations/{location-id}/models/{model-id}``
|
276
|
+
- General (built-in) models:
|
277
|
+
``projects/{project-number-or-id}/locations/{location-id}/models/general/nmt``
|
278
|
+
- Translation LLM models:
|
279
|
+
``projects/{project-number-or-id}/locations/{location-id}/models/general/translation-llm``
|
280
|
+
|
281
|
+
For global (no region) requests, use ``location-id`` ``global``.
|
282
|
+
For example, ``projects/{project-number-or-id}/locations/global/models/general/nmt``.
|
283
|
+
:param glossary_config: Optional. Glossary to be applied. The glossary must be
|
284
|
+
within the same region (have the same location-id) as the
|
285
|
+
model.
|
286
|
+
:param transliteration_config: Optional. Transliteration to be applied.
|
287
|
+
:param labels: Optional. The labels with user-defined
|
288
|
+
metadata for the request.
|
289
|
+
See https://cloud.google.com/translate/docs/advanced/labels for more information.
|
290
|
+
:param retry: Designation of what errors, if any, should be retried.
|
291
|
+
:param timeout: The timeout for this request.
|
292
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
293
|
+
|
294
|
+
:return: Translate text result from the API response.
|
295
|
+
"""
|
296
|
+
client = self.get_client()
|
297
|
+
location_id = "global" if not location else location
|
298
|
+
parent = f"projects/{project_id or self.project_id}/locations/{location_id}"
|
299
|
+
|
300
|
+
result = client.translate_text(
|
301
|
+
request={
|
302
|
+
"parent": parent,
|
303
|
+
"source_language_code": source_language_code,
|
304
|
+
"target_language_code": target_language_code,
|
305
|
+
"contents": contents,
|
306
|
+
"mime_type": mime_type,
|
307
|
+
"glossary_config": glossary_config,
|
308
|
+
"transliteration_config": transliteration_config,
|
309
|
+
"model": model,
|
310
|
+
"labels": labels,
|
311
|
+
},
|
312
|
+
timeout=timeout,
|
313
|
+
retry=retry,
|
314
|
+
metadata=metadata,
|
315
|
+
)
|
316
|
+
return cast(dict, type(result).to_dict(result))
|
317
|
+
|
318
|
+
def batch_translate_text(
|
319
|
+
self,
|
320
|
+
*,
|
321
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
322
|
+
location: str,
|
323
|
+
source_language_code: str,
|
324
|
+
target_language_codes: MutableSequence[str],
|
325
|
+
input_configs: MutableSequence[InputConfig | dict],
|
326
|
+
output_config: OutputConfig | dict,
|
327
|
+
models: str | None = None,
|
328
|
+
glossaries: MutableMapping[str, TranslateTextGlossaryConfig] | None = None,
|
329
|
+
labels: MutableMapping[str, str] | None = None,
|
330
|
+
timeout: float | _MethodDefault = DEFAULT,
|
331
|
+
metadata: Sequence[tuple[str, str]] = (),
|
332
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
333
|
+
) -> Operation:
|
334
|
+
"""
|
335
|
+
Translate large volumes of text data.
|
336
|
+
|
337
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
338
|
+
:param location: Optional. Project or location to make a call. Must refer to
|
339
|
+
a caller's project. Must be non-global.
|
340
|
+
:param source_language_code: Required. Source language code.
|
341
|
+
:param target_language_codes: Required. Specify up to 10 language codes here.
|
342
|
+
:param models: Optional. The models to use for translation. Map's key is
|
343
|
+
target language code. Map's value is model name. Value can
|
344
|
+
be a built-in general model, or an AutoML Translation model.
|
345
|
+
The value format depends on model type:
|
346
|
+
|
347
|
+
- AutoML Translation models:
|
348
|
+
``projects/{project-number-or-id}/locations/{location-id}/models/{model-id}``
|
349
|
+
- General (built-in) models:
|
350
|
+
``projects/{project-number-or-id}/locations/{location-id}/models/general/nmt``
|
351
|
+
|
352
|
+
If the map is empty or a specific model is not requested for
|
353
|
+
a language pair, then the default Google model (NMT) is used.
|
354
|
+
:param input_configs: Required. Input configurations.
|
355
|
+
The total number of files matched should be <= 100. The total content size should be <= 100M
|
356
|
+
Unicode codepoints. The files must use UTF-8 encoding.
|
357
|
+
:param output_config: Required. Output configuration.
|
358
|
+
:param glossaries: Optional. Glossaries to be applied for
|
359
|
+
translation. It's keyed by target language code.
|
360
|
+
:param labels: Optional. The labels with user-defined metadata for the request.
|
361
|
+
See https://cloud.google.com/translate/docs/advanced/labels for more information.
|
362
|
+
:param retry: Designation of what errors, if any, should be retried.
|
363
|
+
:param timeout: The timeout for this request.
|
364
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
365
|
+
|
366
|
+
:return: Operation object with the batch text translate results,
|
367
|
+
that are returned by batches as they are ready.
|
368
|
+
"""
|
369
|
+
client = self.get_client()
|
370
|
+
if location == "global":
|
371
|
+
raise AirflowException(
|
372
|
+
"Global location is not allowed for the batch text translation, "
|
373
|
+
"please provide the correct value!"
|
374
|
+
)
|
375
|
+
parent = f"projects/{project_id or self.project_id}/locations/{location}"
|
376
|
+
result = client.batch_translate_text(
|
377
|
+
request={
|
378
|
+
"parent": parent,
|
379
|
+
"source_language_code": source_language_code,
|
380
|
+
"target_language_codes": target_language_codes,
|
381
|
+
"input_configs": input_configs,
|
382
|
+
"output_config": output_config,
|
383
|
+
"glossaries": glossaries,
|
384
|
+
"models": models,
|
385
|
+
"labels": labels,
|
386
|
+
},
|
387
|
+
timeout=timeout,
|
388
|
+
retry=retry,
|
389
|
+
metadata=metadata,
|
390
|
+
)
|
391
|
+
return result
|
392
|
+
|
393
|
+
def create_dataset(
|
394
|
+
self,
|
395
|
+
*,
|
396
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
397
|
+
location: str,
|
398
|
+
dataset: dict | automl_translation.Dataset,
|
399
|
+
timeout: float | _MethodDefault = DEFAULT,
|
400
|
+
metadata: Sequence[tuple[str, str]] = (),
|
401
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
402
|
+
) -> Operation:
|
403
|
+
"""
|
404
|
+
Create the translation dataset.
|
405
|
+
|
406
|
+
:param dataset: The dataset to create. If a dict is provided, it must correspond to
|
407
|
+
the automl_translation.Dataset type.
|
408
|
+
:param project_id: ID of the Google Cloud project where dataset is located. If not provided
|
409
|
+
default project_id is used.
|
410
|
+
:param location: The location of the project.
|
411
|
+
:param retry: A retry object used to retry requests. If `None` is specified, requests will not be
|
412
|
+
retried.
|
413
|
+
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
|
414
|
+
`retry` is specified, the timeout applies to each individual attempt.
|
415
|
+
:param metadata: Additional metadata that is provided to the method.
|
416
|
+
|
417
|
+
:return: `Operation` object for the dataset to be created.
|
418
|
+
"""
|
419
|
+
client = self.get_client()
|
420
|
+
parent = f"projects/{project_id or self.project_id}/locations/{location}"
|
421
|
+
return client.create_dataset(
|
422
|
+
request={"parent": parent, "dataset": dataset},
|
423
|
+
retry=retry,
|
424
|
+
timeout=timeout,
|
425
|
+
metadata=metadata,
|
426
|
+
)
|
427
|
+
|
428
|
+
def get_dataset(
|
429
|
+
self,
|
430
|
+
dataset_id: str,
|
431
|
+
project_id: str,
|
432
|
+
location: str,
|
433
|
+
retry: Retry | _MethodDefault = DEFAULT,
|
434
|
+
timeout: float | _MethodDefault = DEFAULT,
|
435
|
+
metadata: Sequence[tuple[str, str]] = (),
|
436
|
+
) -> automl_translation.Dataset:
|
437
|
+
"""
|
438
|
+
Retrieve the dataset for the given dataset_id.
|
439
|
+
|
440
|
+
:param dataset_id: ID of translation dataset to be retrieved.
|
441
|
+
:param project_id: ID of the Google Cloud project where dataset is located. If not provided
|
442
|
+
default project_id is used.
|
443
|
+
:param location: The location of the project.
|
444
|
+
:param retry: A retry object used to retry requests. If `None` is specified, requests will not be
|
445
|
+
retried.
|
446
|
+
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
|
447
|
+
`retry` is specified, the timeout applies to each individual attempt.
|
448
|
+
:param metadata: Additional metadata that is provided to the method.
|
449
|
+
|
450
|
+
:return: `automl_translation.Dataset` instance.
|
451
|
+
"""
|
452
|
+
client = self.get_client()
|
453
|
+
name = f"projects/{project_id}/locations/{location}/datasets/{dataset_id}"
|
454
|
+
return client.get_dataset(
|
455
|
+
request={"name": name},
|
456
|
+
retry=retry,
|
457
|
+
timeout=timeout,
|
458
|
+
metadata=metadata,
|
459
|
+
)
|
460
|
+
|
461
|
+
def import_dataset_data(
|
462
|
+
self,
|
463
|
+
dataset_id: str,
|
464
|
+
location: str,
|
465
|
+
input_config: dict | DatasetInputConfig,
|
466
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
467
|
+
retry: Retry | _MethodDefault = DEFAULT,
|
468
|
+
timeout: float | None = None,
|
469
|
+
metadata: Sequence[tuple[str, str]] = (),
|
470
|
+
) -> Operation:
|
471
|
+
"""
|
472
|
+
Import data into the translation dataset.
|
473
|
+
|
474
|
+
:param dataset_id: ID of the translation dataset.
|
475
|
+
:param input_config: The desired input location and its domain specific semantics, if any.
|
476
|
+
If a dict is provided, it must be of the same form as the protobuf message InputConfig.
|
477
|
+
:param project_id: ID of the Google Cloud project where dataset is located if None then
|
478
|
+
default project_id is used.
|
479
|
+
:param location: The location of the project.
|
480
|
+
:param retry: A retry object used to retry requests. If `None` is specified, requests will not be
|
481
|
+
retried.
|
482
|
+
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
|
483
|
+
`retry` is specified, the timeout applies to each individual attempt.
|
484
|
+
:param metadata: Additional metadata that is provided to the method.
|
485
|
+
|
486
|
+
:return: `Operation` object for the import data.
|
487
|
+
"""
|
488
|
+
client = self.get_client()
|
489
|
+
name = f"projects/{project_id}/locations/{location}/datasets/{dataset_id}"
|
490
|
+
result = client.import_data(
|
491
|
+
request={"dataset": name, "input_config": input_config},
|
492
|
+
retry=retry,
|
493
|
+
timeout=timeout,
|
494
|
+
metadata=metadata,
|
495
|
+
)
|
496
|
+
return result
|
497
|
+
|
498
|
+
def list_datasets(
|
499
|
+
self,
|
500
|
+
project_id: str,
|
501
|
+
location: str,
|
502
|
+
retry: Retry | _MethodDefault = DEFAULT,
|
503
|
+
timeout: float | _MethodDefault = DEFAULT,
|
504
|
+
metadata: Sequence[tuple[str, str]] = (),
|
505
|
+
) -> pagers.ListDatasetsPager:
|
506
|
+
"""
|
507
|
+
List translation datasets in a project.
|
508
|
+
|
509
|
+
:param project_id: ID of the Google Cloud project where dataset is located. If not provided
|
510
|
+
default project_id is used.
|
511
|
+
:param location: The location of the project.
|
512
|
+
:param retry: A retry object used to retry requests. If `None` is specified, requests will not be
|
513
|
+
retried.
|
514
|
+
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
|
515
|
+
`retry` is specified, the timeout applies to each individual attempt.
|
516
|
+
:param metadata: Additional metadata that is provided to the method.
|
517
|
+
|
518
|
+
:return: ``pagers.ListDatasetsPager`` instance, iterable object to retrieve the datasets list.
|
519
|
+
"""
|
520
|
+
client = self.get_client()
|
521
|
+
parent = f"projects/{project_id}/locations/{location}"
|
522
|
+
result = client.list_datasets(
|
523
|
+
request={"parent": parent},
|
524
|
+
retry=retry,
|
525
|
+
timeout=timeout,
|
526
|
+
metadata=metadata,
|
527
|
+
)
|
528
|
+
return result
|
529
|
+
|
530
|
+
def delete_dataset(
|
531
|
+
self,
|
532
|
+
dataset_id: str,
|
533
|
+
project_id: str,
|
534
|
+
location: str,
|
535
|
+
retry: Retry | _MethodDefault = DEFAULT,
|
536
|
+
timeout: float | None = None,
|
537
|
+
metadata: Sequence[tuple[str, str]] = (),
|
538
|
+
) -> Operation:
|
539
|
+
"""
|
540
|
+
Delete the translation dataset and all of its contents.
|
541
|
+
|
542
|
+
:param dataset_id: ID of dataset to be deleted.
|
543
|
+
:param project_id: ID of the Google Cloud project where dataset is located. If not provided
|
544
|
+
default project_id is used.
|
545
|
+
:param location: The location of the project.
|
546
|
+
:param retry: A retry object used to retry requests. If `None` is specified, requests will not be
|
547
|
+
retried.
|
548
|
+
:param timeout: The amount of time, in seconds, to wait for the request to complete. Note that if
|
549
|
+
`retry` is specified, the timeout applies to each individual attempt.
|
550
|
+
:param metadata: Additional metadata that is provided to the method.
|
551
|
+
|
552
|
+
:return: `Operation` object with dataset deletion results, when finished.
|
553
|
+
"""
|
554
|
+
client = self.get_client()
|
555
|
+
name = f"projects/{project_id}/locations/{location}/datasets/{dataset_id}"
|
556
|
+
result = client.delete_dataset(
|
557
|
+
request={"name": name},
|
558
|
+
retry=retry,
|
559
|
+
timeout=timeout,
|
560
|
+
metadata=metadata,
|
561
|
+
)
|
562
|
+
return result
|
@@ -20,7 +20,8 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import warnings
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import TYPE_CHECKING
|
24
25
|
|
25
26
|
from google.api_core.client_options import ClientOptions
|
26
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -55,14 +56,10 @@ class AutoMLHook(GoogleBaseHook):
|
|
55
56
|
impersonation_chain: str | Sequence[str] | None = None,
|
56
57
|
**kwargs,
|
57
58
|
) -> None:
|
58
|
-
if kwargs.get("delegate_to") is not None:
|
59
|
-
raise RuntimeError(
|
60
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
61
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
62
|
-
)
|
63
59
|
super().__init__(
|
64
60
|
gcp_conn_id=gcp_conn_id,
|
65
61
|
impersonation_chain=impersonation_chain,
|
62
|
+
**kwargs,
|
66
63
|
)
|
67
64
|
self._job: None | (
|
68
65
|
AutoMLForecastingTrainingJob
|
@@ -20,7 +20,8 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import asyncio
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import TYPE_CHECKING
|
24
25
|
|
25
26
|
from google.api_core.client_options import ClientOptions
|
26
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -46,14 +47,10 @@ class BatchPredictionJobHook(GoogleBaseHook):
|
|
46
47
|
impersonation_chain: str | Sequence[str] | None = None,
|
47
48
|
**kwargs,
|
48
49
|
) -> None:
|
49
|
-
if kwargs.get("delegate_to") is not None:
|
50
|
-
raise RuntimeError(
|
51
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
52
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
53
|
-
)
|
54
50
|
super().__init__(
|
55
51
|
gcp_conn_id=gcp_conn_id,
|
56
52
|
impersonation_chain=impersonation_chain,
|
53
|
+
**kwargs,
|
57
54
|
)
|
58
55
|
self._batch_prediction_job: BatchPredictionJob | None = None
|
59
56
|
|
@@ -20,7 +20,8 @@
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
22
|
import asyncio
|
23
|
-
from
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import TYPE_CHECKING, Any
|
24
25
|
|
25
26
|
from google.api_core.client_options import ClientOptions
|
26
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -67,14 +68,10 @@ class CustomJobHook(GoogleBaseHook):
|
|
67
68
|
impersonation_chain: str | Sequence[str] | None = None,
|
68
69
|
**kwargs,
|
69
70
|
) -> None:
|
70
|
-
if kwargs.get("delegate_to") is not None:
|
71
|
-
raise RuntimeError(
|
72
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
73
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
74
|
-
)
|
75
71
|
super().__init__(
|
76
72
|
gcp_conn_id=gcp_conn_id,
|
77
73
|
impersonation_chain=impersonation_chain,
|
74
|
+
**kwargs,
|
78
75
|
)
|
79
76
|
self._job: None | (
|
80
77
|
CustomContainerTrainingJob | CustomPythonPackageTrainingJob | CustomTrainingJob
|
@@ -19,7 +19,8 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from
|
22
|
+
from collections.abc import Sequence
|
23
|
+
from typing import TYPE_CHECKING
|
23
24
|
|
24
25
|
from google.api_core.client_options import ClientOptions
|
25
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -44,14 +45,6 @@ if TYPE_CHECKING:
|
|
44
45
|
class DatasetHook(GoogleBaseHook):
|
45
46
|
"""Hook for Google Cloud Vertex AI Dataset APIs."""
|
46
47
|
|
47
|
-
def __init__(self, **kwargs):
|
48
|
-
if kwargs.get("delegate_to") is not None:
|
49
|
-
raise RuntimeError(
|
50
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
51
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
52
|
-
)
|
53
|
-
super().__init__(**kwargs)
|
54
|
-
|
55
48
|
def get_dataset_service_client(self, region: str | None = None) -> DatasetServiceClient:
|
56
49
|
"""Return DatasetServiceClient."""
|
57
50
|
if region and region != "global":
|
@@ -19,7 +19,8 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from
|
22
|
+
from collections.abc import Sequence
|
23
|
+
from typing import TYPE_CHECKING
|
23
24
|
|
24
25
|
from google.api_core.client_options import ClientOptions
|
25
26
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -39,14 +40,6 @@ if TYPE_CHECKING:
|
|
39
40
|
class EndpointServiceHook(GoogleBaseHook):
|
40
41
|
"""Hook for Google Cloud Vertex AI Endpoint Service APIs."""
|
41
42
|
|
42
|
-
def __init__(self, **kwargs):
|
43
|
-
if kwargs.get("delegate_to") is not None:
|
44
|
-
raise RuntimeError(
|
45
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
46
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
47
|
-
)
|
48
|
-
super().__init__(**kwargs)
|
49
|
-
|
50
43
|
def get_endpoint_service_client(self, region: str | None = None) -> EndpointServiceClient:
|
51
44
|
"""Return EndpointServiceClient."""
|
52
45
|
if region and region != "global":
|
@@ -21,7 +21,7 @@ from __future__ import annotations
|
|
21
21
|
|
22
22
|
import time
|
23
23
|
from datetime import timedelta
|
24
|
-
from typing import TYPE_CHECKING
|
24
|
+
from typing import TYPE_CHECKING
|
25
25
|
|
26
26
|
import vertexai
|
27
27
|
from vertexai.generative_models import GenerativeModel, Part
|
@@ -43,19 +43,6 @@ if TYPE_CHECKING:
|
|
43
43
|
class GenerativeModelHook(GoogleBaseHook):
|
44
44
|
"""Hook for Google Cloud Vertex AI Generative Model APIs."""
|
45
45
|
|
46
|
-
def __init__(
|
47
|
-
self,
|
48
|
-
gcp_conn_id: str = "google_cloud_default",
|
49
|
-
impersonation_chain: str | Sequence[str] | None = None,
|
50
|
-
**kwargs,
|
51
|
-
):
|
52
|
-
if kwargs.get("delegate_to") is not None:
|
53
|
-
raise RuntimeError(
|
54
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
55
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
56
|
-
)
|
57
|
-
super().__init__(gcp_conn_id=gcp_conn_id, impersonation_chain=impersonation_chain, **kwargs)
|
58
|
-
|
59
46
|
def get_text_generation_model(self, pretrained_model: str):
|
60
47
|
"""Return a Model Garden Model object based on Text Generation."""
|
61
48
|
model = TextGenerationModel.from_pretrained(pretrained_model)
|
@@ -26,7 +26,8 @@ This module contains a Google Cloud Vertex AI hook.
|
|
26
26
|
from __future__ import annotations
|
27
27
|
|
28
28
|
import asyncio
|
29
|
-
from
|
29
|
+
from collections.abc import Sequence
|
30
|
+
from typing import TYPE_CHECKING
|
30
31
|
|
31
32
|
from google.api_core.client_options import ClientOptions
|
32
33
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
@@ -52,14 +53,10 @@ class HyperparameterTuningJobHook(GoogleBaseHook):
|
|
52
53
|
impersonation_chain: str | Sequence[str] | None = None,
|
53
54
|
**kwargs,
|
54
55
|
) -> None:
|
55
|
-
if kwargs.get("delegate_to") is not None:
|
56
|
-
raise RuntimeError(
|
57
|
-
"The `delegate_to` parameter has been deprecated before and finally removed in this version"
|
58
|
-
" of Google Provider. You MUST convert it to `impersonate_chain`"
|
59
|
-
)
|
60
56
|
super().__init__(
|
61
57
|
gcp_conn_id=gcp_conn_id,
|
62
58
|
impersonation_chain=impersonation_chain,
|
59
|
+
**kwargs,
|
63
60
|
)
|
64
61
|
self._hyperparameter_tuning_job: HyperparameterTuningJob | None = None
|
65
62
|
|