MCPcopy Index your code
hub / github.com/feast-dev/feast / run_demo

Function run_demo

sdk/python/feast/templates/snowflake/test_workflow.py:12–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10
11
12def run_demo():
13 print("\n--- Run feast apply to setup feature store on Snowflake ---")
14 command = "cd feature_repo; feast apply"
15 subprocess.run(command, shell=True)
16
17 store = FeatureStore(repo_path="./feature_repo")
18
19 print("\n--- Historical features for training ---")
20 fetch_historical_features_entity_df(store, for_batch_scoring=False)
21
22 print("\n--- Historical features for batch scoring ---")
23 fetch_historical_features_entity_df(store, for_batch_scoring=True)
24
25 print(
26 "\n--- Historical features for training (all entities in a window using SQL entity dataframe) ---"
27 )
28 fetch_historical_features_entity_sql(store, for_batch_scoring=False)
29
30 print(
31 "\n--- Historical features for batch scoring (all entities in a window using SQL entity dataframe) ---"
32 )
33 fetch_historical_features_entity_sql(store, for_batch_scoring=True)
34
35 print("\n--- Load features into online store ---")
36 store.materialize_incremental(end_date=datetime.now())
37
38 print("\n--- Online features ---")
39 fetch_online_features(store)
40
41 print("\n--- Online features retrieved (instead) through a feature service---")
42 fetch_online_features(store, source="feature_service")
43
44 print(
45 "\n--- Online features retrieved (using feature service v3, which uses a feature view with a push source---"
46 )
47 fetch_online_features(store, source="push")
48
49 print("\n--- Simulate a stream event ingestion of the hourly stats df ---")
50 event_df = pd.DataFrame.from_dict(
51 {
52 "driver_id": [1001],
53 "event_timestamp": [
54 datetime.now(),
55 ],
56 "created": [
57 datetime.now(),
58 ],
59 "conv_rate": [1.0],
60 "acc_rate": [1.0 + random.random()],
61 "avg_daily_trips": [int(1000 * random.random())],
62 }
63 )
64 print(event_df)
65 store.push("driver_stats_push_source", event_df, to=PushMode.ONLINE_AND_OFFLINE)
66
67 print("\n--- Online features again with updated values from a stream push ---")
68 fetch_online_features(store, source="push")
69

Callers 1

test_workflow.pyFile · 0.70

Calls 8

pushMethod · 0.95
FeatureStoreClass · 0.90
fetch_online_featuresFunction · 0.70
runMethod · 0.45
from_dictMethod · 0.45

Tested by

no test coverage detected