apache-airflow-providers-google 16.0.0rc1__py3-none-any.whl → 16.1.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 +9 -5
- airflow/providers/google/ads/operators/ads.py +1 -1
- airflow/providers/google/ads/transfers/ads_to_gcs.py +1 -1
- airflow/providers/google/cloud/hooks/bigquery.py +2 -3
- airflow/providers/google/cloud/hooks/cloud_sql.py +8 -4
- airflow/providers/google/cloud/hooks/datacatalog.py +9 -1
- airflow/providers/google/cloud/hooks/dataflow.py +2 -2
- airflow/providers/google/cloud/hooks/dataplex.py +1 -1
- airflow/providers/google/cloud/hooks/dataprep.py +4 -1
- airflow/providers/google/cloud/hooks/gcs.py +2 -2
- airflow/providers/google/cloud/hooks/looker.py +5 -1
- airflow/providers/google/cloud/hooks/mlengine.py +2 -1
- airflow/providers/google/cloud/hooks/secret_manager.py +102 -10
- airflow/providers/google/cloud/hooks/spanner.py +2 -2
- airflow/providers/google/cloud/hooks/translate.py +1 -1
- airflow/providers/google/cloud/hooks/vertex_ai/feature_store.py +307 -7
- airflow/providers/google/cloud/hooks/vertex_ai/generative_model.py +43 -14
- airflow/providers/google/cloud/hooks/vertex_ai/ray.py +11 -2
- airflow/providers/google/cloud/hooks/vision.py +2 -2
- airflow/providers/google/cloud/links/alloy_db.py +0 -46
- airflow/providers/google/cloud/links/base.py +75 -11
- airflow/providers/google/cloud/links/bigquery.py +0 -47
- airflow/providers/google/cloud/links/bigquery_dts.py +0 -20
- airflow/providers/google/cloud/links/bigtable.py +0 -48
- airflow/providers/google/cloud/links/cloud_build.py +0 -73
- airflow/providers/google/cloud/links/cloud_functions.py +0 -33
- airflow/providers/google/cloud/links/cloud_memorystore.py +0 -58
- airflow/providers/google/cloud/links/cloud_run.py +1 -33
- airflow/providers/google/cloud/links/cloud_sql.py +0 -33
- airflow/providers/google/cloud/links/cloud_storage_transfer.py +16 -43
- airflow/providers/google/cloud/links/cloud_tasks.py +6 -25
- airflow/providers/google/cloud/links/compute.py +0 -58
- airflow/providers/google/cloud/links/data_loss_prevention.py +0 -169
- airflow/providers/google/cloud/links/datacatalog.py +23 -54
- airflow/providers/google/cloud/links/dataflow.py +0 -34
- airflow/providers/google/cloud/links/dataform.py +0 -64
- airflow/providers/google/cloud/links/datafusion.py +1 -96
- airflow/providers/google/cloud/links/dataplex.py +0 -154
- airflow/providers/google/cloud/links/dataprep.py +0 -24
- airflow/providers/google/cloud/links/dataproc.py +14 -90
- airflow/providers/google/cloud/links/datastore.py +0 -31
- airflow/providers/google/cloud/links/kubernetes_engine.py +5 -59
- airflow/providers/google/cloud/links/life_sciences.py +0 -19
- airflow/providers/google/cloud/links/managed_kafka.py +0 -70
- airflow/providers/google/cloud/links/mlengine.py +0 -70
- airflow/providers/google/cloud/links/pubsub.py +0 -32
- airflow/providers/google/cloud/links/spanner.py +0 -33
- airflow/providers/google/cloud/links/stackdriver.py +0 -30
- airflow/providers/google/cloud/links/translate.py +16 -186
- airflow/providers/google/cloud/links/vertex_ai.py +8 -224
- airflow/providers/google/cloud/links/workflows.py +0 -52
- airflow/providers/google/cloud/operators/alloy_db.py +69 -54
- airflow/providers/google/cloud/operators/automl.py +16 -14
- airflow/providers/google/cloud/operators/bigquery.py +0 -15
- airflow/providers/google/cloud/operators/bigquery_dts.py +2 -4
- airflow/providers/google/cloud/operators/bigtable.py +35 -6
- airflow/providers/google/cloud/operators/cloud_base.py +21 -1
- airflow/providers/google/cloud/operators/cloud_build.py +74 -31
- airflow/providers/google/cloud/operators/cloud_composer.py +34 -35
- airflow/providers/google/cloud/operators/cloud_memorystore.py +68 -42
- airflow/providers/google/cloud/operators/cloud_run.py +0 -1
- airflow/providers/google/cloud/operators/cloud_sql.py +11 -15
- airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +0 -2
- airflow/providers/google/cloud/operators/compute.py +7 -39
- airflow/providers/google/cloud/operators/datacatalog.py +156 -20
- airflow/providers/google/cloud/operators/dataflow.py +37 -14
- airflow/providers/google/cloud/operators/dataform.py +14 -4
- airflow/providers/google/cloud/operators/datafusion.py +4 -12
- airflow/providers/google/cloud/operators/dataplex.py +180 -96
- airflow/providers/google/cloud/operators/dataprep.py +0 -4
- airflow/providers/google/cloud/operators/dataproc.py +10 -16
- airflow/providers/google/cloud/operators/dataproc_metastore.py +95 -87
- airflow/providers/google/cloud/operators/datastore.py +21 -5
- airflow/providers/google/cloud/operators/dlp.py +3 -26
- airflow/providers/google/cloud/operators/functions.py +15 -6
- airflow/providers/google/cloud/operators/gcs.py +0 -7
- airflow/providers/google/cloud/operators/kubernetes_engine.py +50 -7
- airflow/providers/google/cloud/operators/life_sciences.py +0 -1
- airflow/providers/google/cloud/operators/managed_kafka.py +106 -51
- airflow/providers/google/cloud/operators/mlengine.py +0 -1
- airflow/providers/google/cloud/operators/pubsub.py +2 -4
- airflow/providers/google/cloud/operators/spanner.py +0 -4
- airflow/providers/google/cloud/operators/speech_to_text.py +0 -1
- airflow/providers/google/cloud/operators/stackdriver.py +0 -8
- airflow/providers/google/cloud/operators/tasks.py +0 -11
- airflow/providers/google/cloud/operators/text_to_speech.py +0 -1
- airflow/providers/google/cloud/operators/translate.py +37 -13
- airflow/providers/google/cloud/operators/translate_speech.py +0 -1
- airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +31 -18
- airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +28 -8
- airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +38 -25
- airflow/providers/google/cloud/operators/vertex_ai/dataset.py +69 -7
- airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +42 -8
- airflow/providers/google/cloud/operators/vertex_ai/feature_store.py +531 -0
- airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +93 -25
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +10 -8
- airflow/providers/google/cloud/operators/vertex_ai/model_service.py +56 -10
- airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +25 -6
- airflow/providers/google/cloud/operators/vertex_ai/ray.py +9 -6
- airflow/providers/google/cloud/operators/workflows.py +1 -9
- airflow/providers/google/cloud/sensors/bigquery.py +1 -1
- airflow/providers/google/cloud/sensors/bigquery_dts.py +6 -1
- airflow/providers/google/cloud/sensors/bigtable.py +15 -3
- airflow/providers/google/cloud/sensors/cloud_composer.py +6 -1
- airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +6 -1
- airflow/providers/google/cloud/sensors/dataflow.py +3 -3
- airflow/providers/google/cloud/sensors/dataform.py +6 -1
- airflow/providers/google/cloud/sensors/datafusion.py +6 -1
- airflow/providers/google/cloud/sensors/dataplex.py +6 -1
- airflow/providers/google/cloud/sensors/dataprep.py +6 -1
- airflow/providers/google/cloud/sensors/dataproc.py +6 -1
- airflow/providers/google/cloud/sensors/dataproc_metastore.py +6 -1
- airflow/providers/google/cloud/sensors/gcs.py +9 -3
- airflow/providers/google/cloud/sensors/looker.py +6 -1
- airflow/providers/google/cloud/sensors/pubsub.py +8 -3
- airflow/providers/google/cloud/sensors/tasks.py +6 -1
- airflow/providers/google/cloud/sensors/vertex_ai/feature_store.py +6 -1
- airflow/providers/google/cloud/sensors/workflows.py +6 -1
- airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +1 -2
- airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +1 -2
- airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +0 -1
- airflow/providers/google/cloud/transfers/bigquery_to_sql.py +1 -1
- airflow/providers/google/cloud/transfers/calendar_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +1 -2
- airflow/providers/google/cloud/transfers/gcs_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/gcs_to_local.py +1 -1
- airflow/providers/google/cloud/transfers/gcs_to_sftp.py +1 -1
- airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +5 -1
- airflow/providers/google/cloud/transfers/gdrive_to_local.py +1 -1
- airflow/providers/google/cloud/transfers/http_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/local_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/sftp_to_gcs.py +1 -1
- airflow/providers/google/cloud/transfers/sheets_to_gcs.py +2 -2
- airflow/providers/google/cloud/transfers/sql_to_gcs.py +1 -1
- airflow/providers/google/cloud/utils/field_validator.py +1 -2
- airflow/providers/google/common/auth_backend/google_openid.py +2 -1
- airflow/providers/google/common/deprecated.py +2 -1
- airflow/providers/google/common/hooks/base_google.py +7 -3
- airflow/providers/google/common/links/storage.py +0 -22
- airflow/providers/google/firebase/operators/firestore.py +1 -1
- airflow/providers/google/get_provider_info.py +0 -11
- airflow/providers/google/leveldb/hooks/leveldb.py +5 -1
- airflow/providers/google/leveldb/operators/leveldb.py +1 -1
- airflow/providers/google/marketing_platform/links/analytics_admin.py +3 -6
- airflow/providers/google/marketing_platform/operators/analytics_admin.py +0 -1
- airflow/providers/google/marketing_platform/operators/campaign_manager.py +4 -4
- airflow/providers/google/marketing_platform/operators/display_video.py +6 -6
- airflow/providers/google/marketing_platform/operators/search_ads.py +1 -1
- airflow/providers/google/marketing_platform/sensors/campaign_manager.py +6 -1
- airflow/providers/google/marketing_platform/sensors/display_video.py +6 -1
- airflow/providers/google/suite/operators/sheets.py +3 -3
- airflow/providers/google/suite/sensors/drive.py +6 -1
- airflow/providers/google/suite/transfers/gcs_to_gdrive.py +1 -1
- airflow/providers/google/suite/transfers/gcs_to_sheets.py +1 -1
- airflow/providers/google/suite/transfers/local_to_drive.py +1 -1
- airflow/providers/google/version_compat.py +28 -0
- {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/METADATA +27 -28
- {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/RECORD +166 -166
- {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_google-16.0.0rc1.dist-info → apache_airflow_providers_google-16.1.0.dist-info}/entry_points.txt +0 -0
@@ -18,15 +18,32 @@
|
|
18
18
|
|
19
19
|
from __future__ import annotations
|
20
20
|
|
21
|
+
from collections.abc import Sequence
|
22
|
+
from typing import (
|
23
|
+
TYPE_CHECKING,
|
24
|
+
)
|
25
|
+
|
21
26
|
from google.api_core.client_options import ClientOptions
|
27
|
+
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
22
28
|
from google.cloud.aiplatform_v1beta1 import (
|
23
29
|
FeatureOnlineStoreAdminServiceClient,
|
30
|
+
FeatureOnlineStoreServiceClient,
|
24
31
|
)
|
25
32
|
|
26
33
|
from airflow.exceptions import AirflowException
|
27
34
|
from airflow.providers.google.common.consts import CLIENT_INFO
|
28
35
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
29
36
|
|
37
|
+
if TYPE_CHECKING:
|
38
|
+
from google.api_core.operation import Operation
|
39
|
+
from google.api_core.retry import Retry
|
40
|
+
from google.cloud.aiplatform_v1beta1.types import (
|
41
|
+
FeatureOnlineStore,
|
42
|
+
FeatureView,
|
43
|
+
FeatureViewDataKey,
|
44
|
+
FetchFeatureValuesResponse,
|
45
|
+
)
|
46
|
+
|
30
47
|
|
31
48
|
class FeatureStoreHook(GoogleBaseHook):
|
32
49
|
"""
|
@@ -48,6 +65,19 @@ class FeatureStoreHook(GoogleBaseHook):
|
|
48
65
|
originating account.
|
49
66
|
"""
|
50
67
|
|
68
|
+
@staticmethod
|
69
|
+
def _get_client_options(
|
70
|
+
location: str | None = None,
|
71
|
+
custom_endpoint: str | None = None,
|
72
|
+
) -> ClientOptions:
|
73
|
+
if custom_endpoint:
|
74
|
+
client_options = ClientOptions(api_endpoint=custom_endpoint)
|
75
|
+
elif location and location != "global":
|
76
|
+
client_options = ClientOptions(api_endpoint=f"{location}-aiplatform.googleapis.com:443")
|
77
|
+
else:
|
78
|
+
client_options = ClientOptions()
|
79
|
+
return client_options
|
80
|
+
|
51
81
|
def get_feature_online_store_admin_service_client(
|
52
82
|
self,
|
53
83
|
location: str | None = None,
|
@@ -62,12 +92,153 @@ class FeatureStoreHook(GoogleBaseHook):
|
|
62
92
|
If provided and not 'global', the client will be configured to use the
|
63
93
|
region-specific API endpoint.
|
64
94
|
"""
|
65
|
-
if location and location != "global":
|
66
|
-
client_options = ClientOptions(api_endpoint=f"{location}-aiplatform.googleapis.com:443")
|
67
|
-
else:
|
68
|
-
client_options = ClientOptions()
|
69
95
|
return FeatureOnlineStoreAdminServiceClient(
|
70
|
-
credentials=self.get_credentials(),
|
96
|
+
credentials=self.get_credentials(),
|
97
|
+
client_info=CLIENT_INFO,
|
98
|
+
client_options=self._get_client_options(location),
|
99
|
+
)
|
100
|
+
|
101
|
+
def get_feature_online_store_service_client(
|
102
|
+
self,
|
103
|
+
location: str | None = None,
|
104
|
+
custom_endpoint: str | None = None,
|
105
|
+
) -> FeatureOnlineStoreServiceClient:
|
106
|
+
return FeatureOnlineStoreServiceClient(
|
107
|
+
credentials=self.get_credentials(),
|
108
|
+
client_info=CLIENT_INFO,
|
109
|
+
client_options=self._get_client_options(location, custom_endpoint),
|
110
|
+
)
|
111
|
+
|
112
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
113
|
+
def create_feature_online_store(
|
114
|
+
self,
|
115
|
+
feature_online_store_id: str,
|
116
|
+
feature_online_store: FeatureOnlineStore,
|
117
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
118
|
+
location: str | None = None,
|
119
|
+
timeout: float | _MethodDefault = DEFAULT,
|
120
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
121
|
+
metadata: Sequence[tuple[str, str]] = (),
|
122
|
+
) -> Operation:
|
123
|
+
"""
|
124
|
+
Create and sends request for Feature Online store.
|
125
|
+
|
126
|
+
This method initiates VertexAI Feature Online Store creation request.
|
127
|
+
Feature Online Store aims to serve and manage features data as a part of VertexAI MLOps.
|
128
|
+
|
129
|
+
:param feature_online_store_id: The ID of the online feature store.
|
130
|
+
:param feature_online_store: The configuration of the online repository.
|
131
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
132
|
+
feature store. If not provided, will attempt to determine from the environment.
|
133
|
+
:param location: The Google Cloud region where the feature store is located
|
134
|
+
(e.g., 'us-central1', 'us-east1').
|
135
|
+
:param retry: Designation of what errors, if any, should be retried.
|
136
|
+
:param timeout: The timeout for this request.
|
137
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
138
|
+
"""
|
139
|
+
client = self.get_feature_online_store_admin_service_client(location)
|
140
|
+
return client.create_feature_online_store(
|
141
|
+
request={
|
142
|
+
"parent": f"projects/{project_id}/locations/{location}",
|
143
|
+
"feature_online_store_id": feature_online_store_id,
|
144
|
+
"feature_online_store": feature_online_store,
|
145
|
+
},
|
146
|
+
timeout=timeout,
|
147
|
+
retry=retry,
|
148
|
+
metadata=metadata,
|
149
|
+
)
|
150
|
+
|
151
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
152
|
+
def get_feature_online_store(
|
153
|
+
self,
|
154
|
+
feature_online_store_id: str,
|
155
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
156
|
+
location: str | None = None,
|
157
|
+
timeout: float | _MethodDefault = DEFAULT,
|
158
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
159
|
+
metadata: Sequence[tuple[str, str]] = (),
|
160
|
+
) -> FeatureOnlineStore:
|
161
|
+
"""
|
162
|
+
Get Feature Online store data.
|
163
|
+
|
164
|
+
Get the FeatureOnlineStore details.
|
165
|
+
Vertex AI Feature Online Store provides a centralized repository for serving ML features
|
166
|
+
and embedding indexes at low latency.
|
167
|
+
|
168
|
+
:param feature_online_store_id: The ID of the online feature store.
|
169
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
170
|
+
feature store. If not provided, will attempt to determine from the environment.
|
171
|
+
:param location: The Google Cloud region where the feature store is located
|
172
|
+
(e.g., 'us-central1', 'us-east1').
|
173
|
+
:param retry: Designation of what errors, if any, should be retried.
|
174
|
+
:param timeout: The timeout for this request.
|
175
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
176
|
+
"""
|
177
|
+
client = self.get_feature_online_store_admin_service_client(location)
|
178
|
+
return client.get_feature_online_store(
|
179
|
+
name=f"projects/{project_id}/locations/{location}/featureOnlineStores/{feature_online_store_id}",
|
180
|
+
timeout=timeout,
|
181
|
+
retry=retry,
|
182
|
+
metadata=metadata,
|
183
|
+
)
|
184
|
+
|
185
|
+
@staticmethod
|
186
|
+
def _get_featurestore_public_endpoint(feature_online_store: FeatureOnlineStore):
|
187
|
+
public_endpoint = None
|
188
|
+
featurestore_data = type(feature_online_store).to_dict(feature_online_store)
|
189
|
+
if "dedicated_serving_endpoint" in featurestore_data:
|
190
|
+
public_endpoint = featurestore_data["dedicated_serving_endpoint"].get(
|
191
|
+
"public_endpoint_domain_name"
|
192
|
+
)
|
193
|
+
return public_endpoint
|
194
|
+
|
195
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
196
|
+
def create_feature_view(
|
197
|
+
self,
|
198
|
+
feature_view_id: str,
|
199
|
+
feature_view: FeatureView,
|
200
|
+
feature_online_store_id: str,
|
201
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
202
|
+
run_sync_immediately: bool = False,
|
203
|
+
location: str | None = None,
|
204
|
+
timeout: float | _MethodDefault = DEFAULT,
|
205
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
206
|
+
metadata: Sequence[tuple[str, str]] = (),
|
207
|
+
) -> Operation:
|
208
|
+
"""
|
209
|
+
Create request for Feature View creation.
|
210
|
+
|
211
|
+
This method initiates VertexAI Feature View request for the existing Feature Online Store.
|
212
|
+
Feature View represents features and data according to the source provided.
|
213
|
+
|
214
|
+
:param feature_view_id: The ID to use for the FeatureView, which will
|
215
|
+
become the final component of the FeatureView's resource name.
|
216
|
+
This value may be up to 60 characters, and valid characters are ``[a-z0-9_]``.
|
217
|
+
The first character cannot be a number. The value must be unique within a FeatureOnlineStore.
|
218
|
+
:param feature_view: The configuration of the FeatureView to create.
|
219
|
+
:param feature_online_store_id: The ID of the online feature store.
|
220
|
+
:param run_sync_immediately: If set to true, one on demand sync will be run
|
221
|
+
immediately, regardless the FeatureView.sync_config.
|
222
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
223
|
+
feature store. If not provided, will attempt to determine from the environment.
|
224
|
+
:param location: The Google Cloud region where the feature store is located
|
225
|
+
(e.g., 'us-central1', 'us-east1').
|
226
|
+
:param retry: Designation of what errors, if any, should be retried.
|
227
|
+
:param timeout: The timeout for this request.
|
228
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
229
|
+
"""
|
230
|
+
client = self.get_feature_online_store_admin_service_client(location)
|
231
|
+
return client.create_feature_view(
|
232
|
+
request={
|
233
|
+
"parent": f"projects/{project_id}/locations/"
|
234
|
+
f"{location}/featureOnlineStores/{feature_online_store_id}",
|
235
|
+
"feature_view_id": feature_view_id,
|
236
|
+
"feature_view": feature_view,
|
237
|
+
"run_sync_immediately": run_sync_immediately,
|
238
|
+
},
|
239
|
+
timeout=timeout,
|
240
|
+
retry=retry,
|
241
|
+
metadata=metadata,
|
71
242
|
)
|
72
243
|
|
73
244
|
def get_feature_view_sync(
|
@@ -135,13 +306,142 @@ class FeatureStoreHook(GoogleBaseHook):
|
|
135
306
|
environment.
|
136
307
|
"""
|
137
308
|
client = self.get_feature_online_store_admin_service_client(location)
|
138
|
-
feature_view =
|
309
|
+
feature_view = (
|
310
|
+
f"projects/{project_id}/locations/{location}/featureOnlineStores/"
|
311
|
+
f"{feature_online_store_id}/featureViews/{feature_view_id}"
|
312
|
+
)
|
139
313
|
|
140
314
|
try:
|
141
315
|
response = client.sync_feature_view(feature_view=feature_view)
|
142
|
-
|
143
316
|
return str(response.feature_view_sync)
|
144
317
|
|
145
318
|
except Exception as e:
|
146
319
|
self.log.error("Failed to sync feature view: %s", str(e))
|
147
320
|
raise AirflowException(str(e))
|
321
|
+
|
322
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
323
|
+
def fetch_feature_values(
|
324
|
+
self,
|
325
|
+
feature_view_id: str,
|
326
|
+
feature_online_store_id: str,
|
327
|
+
entity_id: str | None = None,
|
328
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
329
|
+
endpoint_domain_name: str | None = None,
|
330
|
+
data_key: FeatureViewDataKey | None = None,
|
331
|
+
data_format: int | None = None,
|
332
|
+
location: str | None = None,
|
333
|
+
timeout: float | _MethodDefault = DEFAULT,
|
334
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
335
|
+
metadata: Sequence[tuple[str, str]] = (),
|
336
|
+
) -> FetchFeatureValuesResponse:
|
337
|
+
"""
|
338
|
+
Fetch data from the Feature View provided.
|
339
|
+
|
340
|
+
This method fetches data from existing Feature view, filtered by provided (or default) data_key.
|
341
|
+
Helps to retrieve actual features data hosted in the VertexAI Feature Store.
|
342
|
+
|
343
|
+
:param entity_id: Simple ID to identify Entity to fetch feature values for.
|
344
|
+
:param endpoint_domain_name: Optional. Public domain name, hosting the content of Optimized
|
345
|
+
Feature Online store. Should be omitted, if bigtable configuration provided for the FeatureStore,
|
346
|
+
and default feature store endpoint will be used, based on location provided.
|
347
|
+
:param feature_view_id: The FeatureView ID to fetch data from.
|
348
|
+
:param feature_online_store_id: The ID of the online feature store.
|
349
|
+
:param data_key: Optional. The request key to fetch feature values for.
|
350
|
+
:param data_format: Optional. Response data format. If not set, FeatureViewDataFormat.KEY_VALUE
|
351
|
+
will be used.
|
352
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
353
|
+
feature store. If not provided, will attempt to determine from the
|
354
|
+
environment.
|
355
|
+
:param location: The Google Cloud region where the feature store is located
|
356
|
+
(e.g., 'us-central1', 'us-east1').
|
357
|
+
:param retry: Designation of what errors, if any, should be retried.
|
358
|
+
:param timeout: The timeout for this request.
|
359
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
360
|
+
"""
|
361
|
+
data_client = self.get_feature_online_store_service_client(location, endpoint_domain_name)
|
362
|
+
return data_client.fetch_feature_values(
|
363
|
+
request={
|
364
|
+
"id": entity_id,
|
365
|
+
"feature_view": f"projects/{project_id}/locations/{location}/featureOnlineStores/"
|
366
|
+
f"{feature_online_store_id}/featureViews/{feature_view_id}",
|
367
|
+
"data_key": data_key,
|
368
|
+
"data_format": data_format,
|
369
|
+
},
|
370
|
+
timeout=timeout,
|
371
|
+
retry=retry,
|
372
|
+
metadata=metadata,
|
373
|
+
)
|
374
|
+
|
375
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
376
|
+
def delete_feature_view(
|
377
|
+
self,
|
378
|
+
feature_view_id: str,
|
379
|
+
feature_online_store_id: str,
|
380
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
381
|
+
location: str | None = None,
|
382
|
+
timeout: float | _MethodDefault = DEFAULT,
|
383
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
384
|
+
metadata: Sequence[tuple[str, str]] = (),
|
385
|
+
) -> Operation:
|
386
|
+
"""
|
387
|
+
Delete the Feature View.
|
388
|
+
|
389
|
+
This method deletes the Feature View from the Feature Online Store.
|
390
|
+
|
391
|
+
:param feature_view_id: The ID to use for the FeatureView, to be deleted.
|
392
|
+
:param feature_online_store_id: The ID of the online feature store.
|
393
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
394
|
+
feature store. If not provided, will attempt to determine from the
|
395
|
+
environment.
|
396
|
+
:param location: The Google Cloud region where the feature store is located
|
397
|
+
(e.g., 'us-central1', 'us-east1').
|
398
|
+
:param retry: Designation of what errors, if any, should be retried.
|
399
|
+
:param timeout: The timeout for this request.
|
400
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
401
|
+
"""
|
402
|
+
client = self.get_feature_online_store_admin_service_client(location)
|
403
|
+
return client.delete_feature_view(
|
404
|
+
name=f"projects/{project_id}/locations/{location}/featureOnlineStores/{feature_online_store_id}"
|
405
|
+
f"/featureViews/{feature_view_id}",
|
406
|
+
timeout=timeout,
|
407
|
+
retry=retry,
|
408
|
+
metadata=metadata,
|
409
|
+
)
|
410
|
+
|
411
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
412
|
+
def delete_feature_online_store(
|
413
|
+
self,
|
414
|
+
feature_online_store_id: str,
|
415
|
+
force: bool = False,
|
416
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
417
|
+
location: str | None = None,
|
418
|
+
timeout: float | _MethodDefault = DEFAULT,
|
419
|
+
retry: Retry | _MethodDefault | None = DEFAULT,
|
420
|
+
metadata: Sequence[tuple[str, str]] = (),
|
421
|
+
) -> Operation:
|
422
|
+
"""
|
423
|
+
Delete the FeatureOnlineStore.
|
424
|
+
|
425
|
+
This method deletes the Feature Online Store and all features data.
|
426
|
+
The FeatureOnlineStore must not contain any FeatureViews.
|
427
|
+
|
428
|
+
:param feature_online_store_id: The ID of the online feature store.
|
429
|
+
:param force: If set to true, any FeatureViews and Features for this FeatureOnlineStore
|
430
|
+
will also be deleted.
|
431
|
+
:param project_id: The ID of the Google Cloud project that contains the
|
432
|
+
feature store. If not provided, will attempt to determine from the
|
433
|
+
environment.
|
434
|
+
:param location: The Google Cloud region where the feature store is located
|
435
|
+
(e.g., 'us-central1', 'us-east1').
|
436
|
+
:param retry: Designation of what errors, if any, should be retried.
|
437
|
+
:param timeout: The timeout for this request.
|
438
|
+
:param metadata: Strings which should be sent along with the request as metadata.
|
439
|
+
"""
|
440
|
+
client = self.get_feature_online_store_admin_service_client(location)
|
441
|
+
return client.delete_feature_online_store(
|
442
|
+
name=f"projects/{project_id}/locations/{location}/featureOnlineStores/{feature_online_store_id}",
|
443
|
+
force=force,
|
444
|
+
timeout=timeout,
|
445
|
+
retry=retry,
|
446
|
+
metadata=metadata,
|
447
|
+
)
|
@@ -21,20 +21,20 @@ 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, Any, Literal
|
25
25
|
|
26
26
|
import vertexai
|
27
|
+
from google.cloud import aiplatform
|
27
28
|
from vertexai.generative_models import GenerativeModel
|
28
29
|
from vertexai.language_models import TextEmbeddingModel
|
30
|
+
from vertexai.preview import generative_models as preview_generative_model
|
29
31
|
from vertexai.preview.caching import CachedContent
|
30
32
|
from vertexai.preview.evaluation import EvalResult, EvalTask
|
31
|
-
from vertexai.preview.generative_models import GenerativeModel as preview_generative_model
|
32
33
|
from vertexai.preview.tuning import sft
|
33
34
|
|
34
35
|
from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID, GoogleBaseHook
|
35
36
|
|
36
37
|
if TYPE_CHECKING:
|
37
|
-
from google.cloud.aiplatform_v1 import types as types_v1
|
38
38
|
from google.cloud.aiplatform_v1beta1 import types as types_v1beta1
|
39
39
|
|
40
40
|
|
@@ -49,7 +49,7 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
49
49
|
def get_generative_model(
|
50
50
|
self,
|
51
51
|
pretrained_model: str,
|
52
|
-
system_instruction:
|
52
|
+
system_instruction: Any | None = None,
|
53
53
|
generation_config: dict | None = None,
|
54
54
|
safety_settings: dict | None = None,
|
55
55
|
tools: list | None = None,
|
@@ -81,11 +81,11 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
81
81
|
def get_cached_context_model(
|
82
82
|
self,
|
83
83
|
cached_content_name: str,
|
84
|
-
) ->
|
84
|
+
) -> Any:
|
85
85
|
"""Return a Generative Model with Cached Context."""
|
86
86
|
cached_content = CachedContent(cached_content_name=cached_content_name)
|
87
87
|
|
88
|
-
cached_context_model = preview_generative_model.from_cached_content(cached_content)
|
88
|
+
cached_context_model = preview_generative_model.GenerativeModel.from_cached_content(cached_content)
|
89
89
|
return cached_context_model
|
90
90
|
|
91
91
|
@GoogleBaseHook.fallback_to_default_project_id
|
@@ -117,11 +117,11 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
117
117
|
self,
|
118
118
|
contents: list,
|
119
119
|
location: str,
|
120
|
+
pretrained_model: str,
|
120
121
|
tools: list | None = None,
|
121
122
|
generation_config: dict | None = None,
|
122
123
|
safety_settings: dict | None = None,
|
123
124
|
system_instruction: str | None = None,
|
124
|
-
pretrained_model: str = "gemini-pro",
|
125
125
|
project_id: str = PROVIDE_PROJECT_ID,
|
126
126
|
) -> str:
|
127
127
|
"""
|
@@ -135,7 +135,7 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
135
135
|
:param safety_settings: Optional. Per request settings for blocking unsafe content.
|
136
136
|
:param tools: Optional. A list of tools available to the model during evaluation, such as a data store.
|
137
137
|
:param system_instruction: Optional. An instruction given to the model to guide its behavior.
|
138
|
-
:param pretrained_model:
|
138
|
+
:param pretrained_model: Required. Model,
|
139
139
|
supporting prompts with text-only input, including natural language
|
140
140
|
tasks, multi-turn text and code chat, and code generation. It can
|
141
141
|
output text and code.
|
@@ -163,10 +163,10 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
163
163
|
tuned_model_display_name: str | None = None,
|
164
164
|
validation_dataset: str | None = None,
|
165
165
|
epochs: int | None = None,
|
166
|
-
adapter_size:
|
166
|
+
adapter_size: Literal[1, 4, 8, 16] | None = None,
|
167
167
|
learning_rate_multiplier: float | None = None,
|
168
168
|
project_id: str = PROVIDE_PROJECT_ID,
|
169
|
-
) ->
|
169
|
+
) -> Any:
|
170
170
|
"""
|
171
171
|
Use the Supervised Fine Tuning API to create a tuning job.
|
172
172
|
|
@@ -212,7 +212,7 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
212
212
|
self,
|
213
213
|
contents: list,
|
214
214
|
location: str,
|
215
|
-
pretrained_model: str
|
215
|
+
pretrained_model: str,
|
216
216
|
project_id: str = PROVIDE_PROJECT_ID,
|
217
217
|
) -> types_v1beta1.CountTokensResponse:
|
218
218
|
"""
|
@@ -222,7 +222,7 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
222
222
|
:param location: Required. The ID of the Google Cloud location that the service belongs to.
|
223
223
|
:param contents: Required. The multi-part content of a message that a user or a program
|
224
224
|
gives to the generative model, in order to elicit a specific response.
|
225
|
-
:param pretrained_model:
|
225
|
+
:param pretrained_model: Required. Model,
|
226
226
|
supporting prompts with text-only input, including natural language
|
227
227
|
tasks, multi-turn text and code chat, and code generation. It can
|
228
228
|
output text and code.
|
@@ -299,8 +299,8 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
299
299
|
model_name: str,
|
300
300
|
location: str,
|
301
301
|
ttl_hours: float = 1,
|
302
|
-
system_instruction:
|
303
|
-
contents: list | None = None,
|
302
|
+
system_instruction: Any | None = None,
|
303
|
+
contents: list[Any] | None = None,
|
304
304
|
display_name: str | None = None,
|
305
305
|
project_id: str = PROVIDE_PROJECT_ID,
|
306
306
|
) -> str:
|
@@ -359,3 +359,32 @@ class GenerativeModelHook(GoogleBaseHook):
|
|
359
359
|
)
|
360
360
|
|
361
361
|
return response.text
|
362
|
+
|
363
|
+
|
364
|
+
class ExperimentRunHook(GoogleBaseHook):
|
365
|
+
"""Use the Vertex AI SDK for Python to create and manage your experiment runs."""
|
366
|
+
|
367
|
+
@GoogleBaseHook.fallback_to_default_project_id
|
368
|
+
def delete_experiment_run(
|
369
|
+
self,
|
370
|
+
experiment_run_name: str,
|
371
|
+
experiment_name: str,
|
372
|
+
location: str,
|
373
|
+
project_id: str = PROVIDE_PROJECT_ID,
|
374
|
+
delete_backing_tensorboard_run: bool = False,
|
375
|
+
) -> None:
|
376
|
+
"""
|
377
|
+
Delete experiment run from the experiment.
|
378
|
+
|
379
|
+
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
|
380
|
+
:param location: Required. The ID of the Google Cloud location that the service belongs to.
|
381
|
+
:param experiment_name: Required. The name of the evaluation experiment.
|
382
|
+
:param experiment_run_name: Required. The specific run name or ID for this experiment.
|
383
|
+
:param delete_backing_tensorboard_run: Whether to delete the backing Vertex AI TensorBoard run
|
384
|
+
that stores time series metrics for this run.
|
385
|
+
"""
|
386
|
+
self.log.info("Next experiment run will be deleted: %s", experiment_run_name)
|
387
|
+
experiment_run = aiplatform.ExperimentRun(
|
388
|
+
run_name=experiment_run_name, experiment=experiment_name, project=project_id, location=location
|
389
|
+
)
|
390
|
+
experiment_run.delete(delete_backing_tensorboard_run=delete_backing_tensorboard_run)
|
@@ -22,8 +22,17 @@ from __future__ import annotations
|
|
22
22
|
import dataclasses
|
23
23
|
from typing import Any
|
24
24
|
|
25
|
-
import
|
26
|
-
|
25
|
+
from airflow.exceptions import AirflowOptionalProviderFeatureException
|
26
|
+
|
27
|
+
try:
|
28
|
+
import vertex_ray
|
29
|
+
from google._upb._message import ScalarMapContainer # type: ignore[attr-defined]
|
30
|
+
except ImportError:
|
31
|
+
# Fallback for environments where the upb module is not available.
|
32
|
+
raise AirflowOptionalProviderFeatureException(
|
33
|
+
"google._upb._message.ScalarMapContainer is not available. "
|
34
|
+
"Please install the ray package to use this feature."
|
35
|
+
)
|
27
36
|
from google.cloud import aiplatform
|
28
37
|
from google.cloud.aiplatform.vertex_ray.util import resources
|
29
38
|
from google.cloud.aiplatform_v1 import (
|
@@ -19,10 +19,10 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from collections.abc import Sequence
|
22
|
+
from collections.abc import Callable, Sequence
|
23
23
|
from copy import deepcopy
|
24
24
|
from functools import cached_property
|
25
|
-
from typing import TYPE_CHECKING, Any
|
25
|
+
from typing import TYPE_CHECKING, Any
|
26
26
|
|
27
27
|
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
|
28
28
|
from google.cloud.vision_v1 import (
|
@@ -19,14 +19,8 @@
|
|
19
19
|
|
20
20
|
from __future__ import annotations
|
21
21
|
|
22
|
-
from typing import TYPE_CHECKING
|
23
|
-
|
24
22
|
from airflow.providers.google.cloud.links.base import BaseGoogleLink
|
25
23
|
|
26
|
-
if TYPE_CHECKING:
|
27
|
-
from airflow.models import BaseOperator
|
28
|
-
from airflow.utils.context import Context
|
29
|
-
|
30
24
|
ALLOY_DB_BASE_LINK = "/alloydb"
|
31
25
|
ALLOY_DB_CLUSTER_LINK = (
|
32
26
|
ALLOY_DB_BASE_LINK + "/locations/{location_id}/clusters/{cluster_id}?project={project_id}"
|
@@ -44,20 +38,6 @@ class AlloyDBClusterLink(BaseGoogleLink):
|
|
44
38
|
key = "alloy_db_cluster"
|
45
39
|
format_str = ALLOY_DB_CLUSTER_LINK
|
46
40
|
|
47
|
-
@staticmethod
|
48
|
-
def persist(
|
49
|
-
context: Context,
|
50
|
-
task_instance: BaseOperator,
|
51
|
-
location_id: str,
|
52
|
-
cluster_id: str,
|
53
|
-
project_id: str | None,
|
54
|
-
):
|
55
|
-
task_instance.xcom_push(
|
56
|
-
context,
|
57
|
-
key=AlloyDBClusterLink.key,
|
58
|
-
value={"location_id": location_id, "cluster_id": cluster_id, "project_id": project_id},
|
59
|
-
)
|
60
|
-
|
61
41
|
|
62
42
|
class AlloyDBUsersLink(BaseGoogleLink):
|
63
43
|
"""Helper class for constructing AlloyDB users Link."""
|
@@ -66,20 +46,6 @@ class AlloyDBUsersLink(BaseGoogleLink):
|
|
66
46
|
key = "alloy_db_users"
|
67
47
|
format_str = ALLOY_DB_USERS_LINK
|
68
48
|
|
69
|
-
@staticmethod
|
70
|
-
def persist(
|
71
|
-
context: Context,
|
72
|
-
task_instance: BaseOperator,
|
73
|
-
location_id: str,
|
74
|
-
cluster_id: str,
|
75
|
-
project_id: str | None,
|
76
|
-
):
|
77
|
-
task_instance.xcom_push(
|
78
|
-
context,
|
79
|
-
key=AlloyDBUsersLink.key,
|
80
|
-
value={"location_id": location_id, "cluster_id": cluster_id, "project_id": project_id},
|
81
|
-
)
|
82
|
-
|
83
49
|
|
84
50
|
class AlloyDBBackupsLink(BaseGoogleLink):
|
85
51
|
"""Helper class for constructing AlloyDB backups Link."""
|
@@ -87,15 +53,3 @@ class AlloyDBBackupsLink(BaseGoogleLink):
|
|
87
53
|
name = "AlloyDB Backups"
|
88
54
|
key = "alloy_db_backups"
|
89
55
|
format_str = ALLOY_DB_BACKUPS_LINK
|
90
|
-
|
91
|
-
@staticmethod
|
92
|
-
def persist(
|
93
|
-
context: Context,
|
94
|
-
task_instance: BaseOperator,
|
95
|
-
project_id: str | None,
|
96
|
-
):
|
97
|
-
task_instance.xcom_push(
|
98
|
-
context,
|
99
|
-
key=AlloyDBBackupsLink.key,
|
100
|
-
value={"project_id": project_id},
|
101
|
-
)
|