MCPcopy
hub / github.com/feast-dev/feast / run_demo

Function run_demo

sdk/python/feast/templates/hbase/feature_repo/test_workflow.py:10–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9
10def 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
60def fetch_historical_features_entity_df(store: FeatureStore, for_batch_scoring: bool):

Callers 1

test_workflow.pyFile · 0.70

Calls 7

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

Tested by

no test coverage detected