forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
66 lines (59 loc) · 1.89 KB
/
Copy pathexample.py
File metadata and controls
66 lines (59 loc) · 1.89 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# # # # # # # # # # # # # # # # # # # # # # # #
# This is an example feature definition file #
# # # # # # # # # # # # # # # # # # # # # # # #
from datetime import timedelta
from pathlib import Path
from feast import Entity, FeatureView, Field, ValueType
from feast.infra.offline_stores.contrib.spark_offline_store.spark_source import (
SparkSource,
)
from feast.types import Float32, Int64
# Constants related to the generated data sets
CURRENT_DIR = Path(__file__).parent
# Entity definitions
driver = Entity(name="driver", value_type=ValueType.INT64, description="driver id",)
customer = Entity(
name="customer", value_type=ValueType.INT64, description="customer id",
)
# Sources
driver_hourly_stats = SparkSource(
name="driver_hourly_stats",
path=f"{CURRENT_DIR}/data/driver_hourly_stats.parquet",
file_format="parquet",
timestamp_field="event_timestamp",
created_timestamp_column="created",
)
customer_daily_profile = SparkSource(
name="customer_daily_profile",
path=f"{CURRENT_DIR}/data/customer_daily_profile.parquet",
file_format="parquet",
timestamp_field="event_timestamp",
created_timestamp_column="created",
)
# Feature Views
driver_hourly_stats_view = FeatureView(
name="driver_hourly_stats",
entities=["driver"],
ttl=timedelta(days=7),
schema=[
Field(name="conv_rate", dtype=Float32),
Field(name="acc_rate", dtype=Float32),
Field(name="avg_daily_trips", dtype=Int64),
],
online=True,
source=driver_hourly_stats,
tags={},
)
customer_daily_profile_view = FeatureView(
name="customer_daily_profile",
entities=["customer"],
ttl=timedelta(days=7),
schema=[
Field(name="current_balance", dtype=Float32),
Field(name="avg_passenger_count", dtype=Float32),
Field(name="lifetime_trip_count", dtype=Int64),
],
online=True,
source=customer_daily_profile,
tags={},
)