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

fix: Adapt project_id_exists validator for updated pydantic version #4680

Open
wants to merge 3 commits into
base: v0.40-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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
26 changes: 26 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,29 @@ 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=[],
)
retrieval_job.to_df()
Loading