Skip to content

Commit

Permalink
adapt project_id_exists validator for updated pydantic version
Browse files Browse the repository at this point in the history
Signed-off-by: Prathap P <[email protected]>
  • Loading branch information
Prathap P authored and Prathap P committed Oct 24, 2024
1 parent 00be7b0 commit f7658f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class BigQueryOfflineStoreConfig(FeastConfigBaseModel):

@field_validator("billing_project_id")
def project_id_exists(cls, v, values, **kwargs):
if v and not values["project_id"]:
if v and not (values.data and values.data["project_id"]):
raise ValueError(
"please specify project_id if billing_project_id is specified"
)
Expand Down
25 changes: 25 additions & 0 deletions sdk/python/tests/unit/infra/offline_stores/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,28 @@ def test_to_arrow_timeout(self, big_query_result):
self.retrieval_job._execute_query.assert_called_once_with(
query=self.query, timeout=30
)


class TestBigQueryRetrievalJobWithBillingProject:
query = "SELECT * FROM bigquery"
client = Mock()

def test_project_id_exists(self):
with pytest.raises(ValueError):
retrieval_job = BigQueryRetrievalJob(
query=self.query,
client=self.client,
config=RepoConfig(
registry="gs://ml-test/repo/registry.db",
project="test",
provider="gcp",
online_store=SqliteOnlineStoreConfig(type="sqlite"),
offline_store=BigQueryOfflineStoreConfig(
type="bigquery",
dataset="feast",
billing_project_id="test-billing-project"
),
),
full_feature_names=True,
on_demand_feature_views=[],
)

0 comments on commit f7658f5

Please sign in to comment.