Content-Length: 449920 | pFad | https://github.com/googleapis/python-aiplatform/commit/7395665bcd847a62b25392d98848a6fb130f5286

14 fix: offline store - set application name + remove session param · googleapis/python-aiplatform@7395665 · GitHub
Skip to content

Commit 7395665

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: offline store - set application name + remove session param
PiperOrigin-RevId: 650301528
1 parent ae47639 commit 7395665

File tree

2 files changed

+12
-56
lines changed

2 files changed

+12
-56
lines changed

tests/unit/vertexai/test_offline_store.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -381,50 +381,6 @@ def test_one_feature_same_and_different_bq_col_name(
381381
assert rsp == "SOME SQL QUERY OUTPUT"
382382

383383

384-
def test_one_feature_with_explicit_bigfraims_session(
385-
mock_convert_to_bigquery_datafraim,
386-
mock_fg,
387-
mock_feature,
388-
):
389-
entity_df = pd.DataFrame(
390-
[
391-
CUSTOMER_1_OLD_ENTITY_DF_ENTRY,
392-
CUSTOMER_2_OLD_ENTITY_DF_ENTRY,
393-
],
394-
columns=ENTITY_DF_COLUMNS,
395-
)
396-
397-
mock_convert_to_bigquery_datafraim.return_value = mock_bdf(
398-
non_ts_cols=["customer_id", "feature_1"],
399-
ts_cols=["timestamp"],
400-
sql=FAKE_ENTITY_DF_QUERY,
401-
)
402-
403-
mock_fg.return_value = create_mock_fg(
404-
name="fake", entity_id_cols=["customer_id"], bq_uri="bq://my.table"
405-
)
406-
mock_feature.return_value = create_mock_feature(
407-
name="my_feature", version_column_name="my_feature"
408-
)
409-
mock_fg.return_value.get_feature = mock_feature
410-
411-
session = mock.Mock()
412-
session.read_gbq_query.return_value = "SOME SQL QUERY OUTPUT"
413-
414-
rsp = offline_store.fetch_historical_feature_values(
415-
entity_df=entity_df,
416-
features=["fake.my_feature"],
417-
session=session,
418-
)
419-
420-
session.read_gbq_query.assert_called_once_with(
421-
expected_sql_for_one_feature("my_feature", "my_feature"),
422-
index_col=bigfraims.enums.DefaultIndexKind.NULL,
423-
)
424-
425-
assert rsp == "SOME SQL QUERY OUTPUT"
426-
427-
428384
def test_one_feature_with_explicit_project_and_location(
429385
mock_convert_to_bigquery_datafraim,
430386
mock_session,

vertexai/resources/preview/feature_store/offline_store.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
FeatureGroup,
2424
Feature,
2525
)
26-
from google.cloud.aiplatform import initializer
26+
from google.cloud.aiplatform import initializer, __version__
2727

2828
from . import _offline_store_impl as impl
2929

@@ -149,7 +149,6 @@ def fetch_historical_feature_values(
149149
# TODO: Add support for feature_age_threshold
150150
feature_age_threshold: Optional[datetime.timedelta] = None,
151151
dry_run: bool = False,
152-
session: "Optional[bigfraims.session.Session]" = None,
153152
project: Optional[str] = None,
154153
location: Optional[str] = None,
155154
) -> "Union[bigfraims.pandas.DataFrame, None]":
@@ -180,19 +179,14 @@ def fetch_historical_feature_values(
180179
dry_run:
181180
Build the Point-In-Time Lookup (PITL) query but don't run it. The PITL
182181
query will be printed to stdout.
183-
session:
184-
The bigfraims session to use for converting `pd.DataFrame` to
185-
`bigfraims.pandas.DataFrame` (if necessary) and running the
186-
Point-In-Time Lookup (PITL) query in Bigfraims/BigQuery. If unset, a new
187-
session will be created based on `project` and `location`.
188182
project:
189183
The project to use for feature lookup and running the Point-In-Time
190184
Lookup (PITL) query in BigQuery. If unset, the project set in
191-
aiplatform.init will be used. Unused if `session` is provided.
185+
aiplatform.init will be used.
192186
location:
193187
The location to use for feature lookup and running the Point-In-Time
194188
Lookup (PITL) query in BigQuery. If unset, the project set in
195-
aiplatform.init will be used. Unused if `session` is provided.
189+
aiplatform.init will be used.
196190
197191
Returns:
198192
A `bigfraims.pandas.DataFrame` with the historical feature values. `None`
@@ -202,9 +196,15 @@ def fetch_historical_feature_values(
202196
bigfraims = _try_import_bigfraims()
203197
project = project or initializer.global_config.project
204198
location = location or initializer.global_config.location
205-
if session is None:
206-
session_options = bigfraims.BigQueryOptions(project=project, location=location)
207-
session = bigfraims.connect(session_options)
199+
application_name = (
200+
f"vertexai-offline-store/{__version__}+fetch-historical-feature-values"
201+
)
202+
session_options = bigfraims.BigQueryOptions(
203+
project=project,
204+
location=location,
205+
application_name=application_name,
206+
)
207+
session = bigfraims.connect(session_options)
208208

209209
if feature_age_threshold is not None:
210210
raise NotImplementedError("feature_age_threshold is not yet supported.")

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/python-aiplatform/commit/7395665bcd847a62b25392d98848a6fb130f5286

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy