()
| 8 | |
| 9 | |
| 10 | def run_demo(): |
| 11 | store = FeatureStore(repo_path=".") |
| 12 | print("\n--- Run feast apply ---") |
| 13 | subprocess.run(["feast", "apply"]) |
| 14 | |
| 15 | print("\n--- Historical features for training ---") |
| 16 | fetch_historical_features_entity_df(store, for_batch_scoring=False) |
| 17 | |
| 18 | print("\n--- Historical features for batch scoring ---") |
| 19 | fetch_historical_features_entity_df(store, for_batch_scoring=True) |
| 20 | |
| 21 | print("\n--- Load features into online store ---") |
| 22 | store.materialize_incremental(end_date=datetime.now()) |
| 23 | |
| 24 | print("\n--- Online features ---") |
| 25 | fetch_online_features(store) |
| 26 | |
| 27 | print("\n--- Online features retrieved (instead) through a feature service---") |
| 28 | fetch_online_features(store, source="feature_service") |
| 29 | |
| 30 | print( |
| 31 | "\n--- Online features retrieved (using feature service v3, which uses a feature view with a push source---" |
| 32 | ) |
| 33 | fetch_online_features(store, source="push") |
| 34 | |
| 35 | print("\n--- Simulate a stream event ingestion of the hourly stats df ---") |
| 36 | event_df = pd.DataFrame.from_dict( |
| 37 | { |
| 38 | "driver_id": [1001], |
| 39 | "event_timestamp": [ |
| 40 | datetime.now(), |
| 41 | ], |
| 42 | "created": [ |
| 43 | datetime.now(), |
| 44 | ], |
| 45 | "conv_rate": [1.0], |
| 46 | "acc_rate": [1.0], |
| 47 | "avg_daily_trips": [1000], |
| 48 | } |
| 49 | ) |
| 50 | print(event_df) |
| 51 | store.push("driver_stats_push_source", event_df, to=PushMode.ONLINE_AND_OFFLINE) |
| 52 | |
| 53 | print("\n--- Online features again with updated values from a stream push---") |
| 54 | fetch_online_features(store, source="push") |
| 55 | |
| 56 | print("\n--- Run feast teardown ---") |
| 57 | subprocess.run(["feast", "teardown"]) |
| 58 | |
| 59 | |
| 60 | def fetch_historical_features_entity_df(store: FeatureStore, for_batch_scoring: bool): |
no test coverage detected