@@ -528,9 +528,27 @@ def pandas_view(features_df: pd.DataFrame) -> pd.DataFrame:
528528 batch_sample ["val_to_add_2" ] = 1
529529 batch_sample ["event_timestamp" ] = start_date
530530 batch_sample ["created" ] = start_date
531+ fv_only_cols = ["driver_id" , "event_timestamp" , "created" ]
531532
533+ resp_base_fv = self .store .get_historical_features (
534+ entity_df = batch_sample [fv_only_cols ],
535+ features = [
536+ "driver_hourly_stats:conv_rate" ,
537+ "driver_hourly_stats:acc_rate" ,
538+ "driver_hourly_stats:avg_daily_trips" ,
539+ ],
540+ ).to_df ()
541+ assert resp_base_fv is not None
542+ assert sorted (resp_base_fv .columns ) == [
543+ "acc_rate" ,
544+ "avg_daily_trips" ,
545+ "conv_rate" ,
546+ "created__" ,
547+ "driver_id" ,
548+ "event_timestamp" ,
549+ ]
532550 resp = self .store .get_historical_features (
533- entity_df = pd . DataFrame ( batch_sample ) ,
551+ entity_df = batch_sample ,
534552 features = [
535553 "driver_hourly_stats:conv_rate" ,
536554 "driver_hourly_stats:acc_rate" ,
@@ -549,7 +567,7 @@ def pandas_view(features_df: pd.DataFrame) -> pd.DataFrame:
549567 missing_batch_sample ["event_timestamp" ] = start_date
550568 missing_batch_sample ["created" ] = start_date
551569 resp_offline = self .store .get_historical_features (
552- entity_df = pd . DataFrame ( missing_batch_sample ) ,
570+ entity_df = missing_batch_sample ,
553571 features = [
554572 "driver_hourly_stats:conv_rate" ,
555573 "driver_hourly_stats:acc_rate" ,
@@ -566,12 +584,11 @@ def pandas_view(features_df: pd.DataFrame) -> pd.DataFrame:
566584 "conv_rate" ,
567585 "conv_rate_plus_val1" ,
568586 "conv_rate_plus_val2" ,
569- # It should not have the items below
570- # "created__",
571- # "driver_id",
572- # "event_timestamp",
573- # "val_to_add",
574- # "val_to_add_2",
587+ "created__" ,
588+ "driver_id" ,
589+ "event_timestamp" ,
590+ "val_to_add" ,
591+ "val_to_add_2" ,
575592 ]
576593 with pytest .raises (TypeError ):
577594 _ = self .store .get_online_features (
@@ -610,7 +627,13 @@ def pandas_view(features_df: pd.DataFrame) -> pd.DataFrame:
610627 # "val_to_add",
611628 # "val_to_add_2",
612629 ]
613- assert sorted (resp_online .columns ) == sorted (resp_offline .columns )
630+ # Note online and offline columns will not match because:
631+ # you want to be space efficient online when considering the impact of network latency so you want to send
632+ # and receive the minimally required set of data, which means after transformation you only need to send the
633+ # output in the response.
634+ # Offline, you will probably prioritize reproducibility and being able to iterate, which means you will want
635+ # the underlying inputs into your transformation, so the extra data is tolerable.
636+ assert sorted (resp_online .columns ) != sorted (resp_offline .columns )
614637
615638 def test_setup (self ):
616639 pass
0 commit comments