Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add location to BigQueryOfflineStoreConfig #1921

Merged
merged 2 commits into from
Oct 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class BigQueryOfflineStoreConfig(FeastConfigBaseModel):
project_id: Optional[StrictStr] = None
""" (optional) GCP project name used for the BigQuery offline store """

location: Optional[StrictStr] = None
""" (optional) GCP location name used for the BigQuery offline store """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be really useful to provide an example as part of this comment, like US or EU

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Added some additional documentation.



class BigQueryOfflineStore(OfflineStore):
@staticmethod
Expand Down Expand Up @@ -79,7 +82,10 @@ def pull_latest_from_table_or_query(
timestamp_desc_string = " DESC, ".join(timestamps) + " DESC"
field_string = ", ".join(join_key_columns + feature_name_columns + timestamps)

client = _get_bigquery_client(project=config.offline_store.project_id)
client = _get_bigquery_client(
project=config.offline_store.project_id,
location=config.offline_store.location,
)
query = f"""
SELECT
{field_string}
Expand Down Expand Up @@ -115,7 +121,10 @@ def get_historical_features(
# TODO: Add entity_df validation in order to fail before interacting with BigQuery
assert isinstance(config.offline_store, BigQueryOfflineStoreConfig)

client = _get_bigquery_client(project=config.offline_store.project_id)
client = _get_bigquery_client(
project=config.offline_store.project_id,
location=config.offline_store.location,
)

assert isinstance(config.offline_store, BigQueryOfflineStoreConfig)

Expand Down Expand Up @@ -367,9 +376,9 @@ def _upload_entity_df_and_get_entity_schema(
return entity_schema


def _get_bigquery_client(project: Optional[str] = None):
def _get_bigquery_client(project: Optional[str] = None, location: Optional[str] = None):
try:
client = bigquery.Client(project=project)
client = bigquery.Client(project=project, location=location)
except DefaultCredentialsError as e:
raise FeastProviderLoginError(
str(e)
Expand Down