Skip to content

Commit d3868c5

Browse files
chore: Upgrade GCP dependencies (feast-dev#2945)
* Upgrade GCP dependencies. Signed-off-by: Abhin Chhabra <abhin.chhabra@shopify.com> * `entity_df` in `get_historical_features` should be tzaware Signed-off-by: Abhin Chhabra <abhin.chhabra@shopify.com> * Linting fixes Signed-off-by: Abhin Chhabra <abhin.chhabra@shopify.com> * Update 3.9 reqs Signed-off-by: Kevin Zhang <kzhang@tecton.ai> * Fix Signed-off-by: Kevin Zhang <kzhang@tecton.ai> * Remove unnecessary code coverage Signed-off-by: Kevin Zhang <kzhang@tecton.ai> * Fix Signed-off-by: Kevin Zhang <kzhang@tecton.ai> Co-authored-by: Kevin Zhang <kzhang@tecton.ai>
1 parent d593351 commit d3868c5

11 files changed

Lines changed: 203 additions & 159 deletions

File tree

sdk/python/feast/feature_store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,17 +1057,17 @@ def get_historical_features(
10571057

10581058
# Check that the right request data is present in the entity_df
10591059
if type(entity_df) == pd.DataFrame:
1060-
entity_pd_df = cast(pd.DataFrame, entity_df)
1060+
entity_df = utils.make_df_tzaware(cast(pd.DataFrame, entity_df))
10611061
for fv in request_feature_views:
10621062
for feature in fv.features:
1063-
if feature.name not in entity_pd_df.columns:
1063+
if feature.name not in entity_df.columns:
10641064
raise RequestDataNotFoundInEntityDfException(
10651065
feature_name=feature.name, feature_view_name=fv.name
10661066
)
10671067
for odfv in on_demand_feature_views:
10681068
odfv_request_data_schema = odfv.get_request_data_schema()
10691069
for feature_name in odfv_request_data_schema.keys():
1070-
if feature_name not in entity_pd_df.columns:
1070+
if feature_name not in entity_df.columns:
10711071
raise RequestDataNotFoundInEntityDfException(
10721072
feature_name=feature_name, feature_view_name=odfv.name,
10731073
)
@@ -2273,7 +2273,7 @@ def _teardown_go_server(self):
22732273

22742274
@log_exceptions_and_usage
22752275
def write_logged_features(
2276-
self, logs: Union[pa.Table, Path], source: Union[FeatureService]
2276+
self, logs: Union[pa.Table, Path], source: FeatureService
22772277
):
22782278
"""
22792279
Write logs produced by a source (currently only feature service is supported as a source)
@@ -2302,7 +2302,7 @@ def write_logged_features(
23022302
@log_exceptions_and_usage
23032303
def validate_logged_features(
23042304
self,
2305-
source: Union[FeatureService],
2305+
source: FeatureService,
23062306
start: datetime,
23072307
end: datetime,
23082308
reference: ValidationReference,

sdk/python/feast/infra/offline_stores/bigquery.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def to_bigquery(
424424
job_config: bigquery.QueryJobConfig = None,
425425
timeout: int = 1800,
426426
retry_cadence: int = 10,
427-
) -> Optional[str]:
427+
) -> str:
428428
"""
429429
Triggers the execution of a historical feature retrieval query and exports the results to a BigQuery table.
430430
Runs for a maximum amount of time specified by the timeout parameter (defaulting to 30 minutes).
@@ -567,7 +567,7 @@ def _wait_until_done(bq_job):
567567

568568
finally:
569569
if client.get_job(bq_job).state in ["PENDING", "RUNNING"]:
570-
client.cancel_job(bq_job)
570+
client.cancel_job(bq_job.job_id)
571571
raise BigQueryJobCancelled(job_id=bq_job.job_id)
572572

573573
if bq_job.exception():
@@ -601,6 +601,7 @@ def _upload_entity_df(
601601
client: Client, table_name: str, entity_df: Union[pd.DataFrame, str],
602602
) -> Table:
603603
"""Uploads a Pandas entity dataframe into a BigQuery table and returns the resulting table"""
604+
job: Union[bigquery.job.query.QueryJob, bigquery.job.load.LoadJob]
604605

605606
if isinstance(entity_df, str):
606607
job = client.query(f"CREATE TABLE {table_name} AS ({entity_df})")

sdk/python/feast/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ def make_tzaware(t: datetime) -> datetime:
2828
return t
2929

3030

31+
def make_df_tzaware(t: pd.DataFrame) -> pd.DataFrame:
32+
"""Make all datetime type columns tzaware; leave everything else intact."""
33+
df = t.copy() # don't modify incoming dataframe inplace
34+
for column in df.columns:
35+
if pd.api.types.is_datetime64_any_dtype(df[column]):
36+
df[column] = pd.to_datetime(df[column], utc=True)
37+
return df
38+
39+
3140
def to_naive_utc(ts: datetime) -> datetime:
3241
if ts.tzinfo is None:
3342
return ts

0 commit comments

Comments
 (0)