-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply_feast.py
51 lines (39 loc) · 1.34 KB
/
apply_feast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from datetime import timedelta
from utils.prepare_feast import create_fs
from feast import Entity, FeatureView, ValueType, Feature
from feast_azure_provider.mssqlserver_source import MsSqlServerSource
def main():
fs = create_fs()
payments_source = MsSqlServerSource(
table_ref="payments",
event_timestamp_column="ts",
)
stats_source = MsSqlServerSource(
table_ref="stats",
event_timestamp_column="ts",
)
player_id = Entity(name="player_id", value_type=ValueType.STRING, description="player id")
payments_view = FeatureView(
name="payments",
entities=["player_id"],
ttl=timedelta(hours=1),
features=[
Feature(name="amount", dtype=ValueType.FLOAT),
Feature(name="transactions", dtype=ValueType.INT32),
],
batch_source=payments_source,
)
stat_view = FeatureView(
name="stats",
entities=["player_id"],
ttl=timedelta(hours=1),
features=[
Feature(name="win_loss_ratio", dtype=ValueType.FLOAT),
Feature(name="games_played", dtype=ValueType.INT32),
Feature(name="time_in_game", dtype=ValueType.FLOAT),
],
batch_source=stats_source,
)
fs.apply([player_id, payments_view, stat_view], partial=False)
if __name__ == "__main__":
main()