Skip to content

Commit ce529d8

Browse files
committed
Add 3rd step in module 1
Signed-off-by: Danny Chiao <danny@tecton.ai>
1 parent 8127142 commit ce529d8

7 files changed

Lines changed: 32 additions & 51 deletions

File tree

‎README.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Since we'll be learning how to leverage Feast in CI/CD, you'll also need to fork
2121

2222
These are meant mostly to be done in order, with examples building on previous concepts.
2323

24-
| Time (min) | Description | Module&nbsp;&nbsp;&nbsp; |
25-
| :--------- | :------------------------------------------------------------- | ------------------------------ |
26-
| 30 | Setting up Feast projects & CI/CD + powering batch predictions | [Module 0](module_0/README.md) |
27-
| 10 | Online feature retrieval with Kafka, Spark, Redis | [Module 1](module_1/README.md) |
28-
| 10 | On demand feature views | [Module 2](module_2/README.md) |
29-
| TBD | Feature server deployment (embed, as a service, AWS Lambda) | TBD |
30-
| TBD | Versioning features / models in Feast | TBD |
31-
| TBD | Data quality monitoring in Feast | TBD |
24+
| Time (min) | Description | Module&nbsp;&nbsp;&nbsp; |
25+
| :--------- | :---------------------------------------------------------------------- | ------------------------------ |
26+
| 30-45 | Setting up Feast projects & CI/CD + powering batch predictions | [Module 0](module_0/README.md) |
27+
| 10-15 | Streaming ingestion & online feature retrieval with Kafka, Spark, Redis | [Module 1](module_1/README.md) |
28+
| 10 | On demand feature views | [Module 2](module_2/README.md) |
29+
| TBD | Feature server deployment (embed, as a service, AWS Lambda) | TBD |
30+
| TBD | Versioning features / models in Feast | TBD |
31+
| TBD | Data quality monitoring in Feast | TBD |
3232

‎module_1/README.md‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# Module 1: Serving fresh online features with Feast, Kafka, Redis
1+
# Module 1: Streaming ingestion & online feature retrieval with Kafka, Spark, Redis
22

3-
In module 1, we focus on building features for online serving, and keeping them fresh with a combination of batch feature materialization and stream feature ingestion.
3+
In this module, we focus on building features for online serving, and keeping them fresh with a combination of batch feature materialization and stream feature ingestion. We'll be roughly working towards the following:
44

55
- **Data sources**: Kafka + File source
66
- **Online store**: Redis
77
- **Use case**: Predicting churn for drivers in real time.
88

9+
![](module_1_architecture.png)
10+
911
## Setup
1012

1113
### Setting up Feast
@@ -17,7 +19,7 @@ pip install "feast[spark, redis]"
1719

1820
We have already set up a feature repository in [feature_repo/](feature_repo/).
1921

20-
### Docker + Kafka + Redis
22+
### Step 1: Docker + Kafka + Redis
2123

2224
We then use Docker Compose to spin up a local Kafka cluster and automatically publish events to it.
2325
- This leverages a script (in `kafka_demo/`) that creates a topic, reads from `feature_repo/data/driver_stats.parquet`, generates newer timestamps, and emits them to the topic.
@@ -35,6 +37,21 @@ Attaching to zookeeper, redis, broker, kafka_events
3537
...
3638
```
3739

38-
## Continue with the workshop
40+
## Step 2: Materialize batch features & ingest streaming features
41+
42+
Run the Jupyter notebook ([feature_repo/workshop.ipynb](feature_repo/module_1.ipynb)).
43+
44+
This will guide you through:
45+
- Registering a `FeatureView` that has a single schema across both a batch source (`FileSource`) with aggregate features and a stream source (`PushSource`).
46+
- Materializing feature view values from batch sources to the online store (e.g. Redis).
47+
- Ingesting feature view values from streaming sources (e.g. window aggregate features from Spark + Kafka)
48+
- Retrieve features at low latency from Redis through Feast.
49+
50+
{% note %}
51+
Feast will, in the future, also support directly authoring a `StreamFeatureView` that contains stream transformations / aggregations (e.g. via Spark, Flink, or Bytewax) {% endnote %}
3952

40-
Now run the Jupyter notebook ([feature_repo/workshop.ipynb](feature_repo/module_1.ipynb))
53+
## Step 3: Setting up push servers + feature servers
54+
TODO
55+
- Have some feature servers be read-only (for `/get_online_features`)
56+
- (pre-alpha): with `go_feature_retrieval=True` and a `LoggingConfig`, the feature server will also log served features to the offline store.
57+
- Have some feature servers be write-only (for `/push`)
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from feast import (
2-
Field,
32
FileSource,
43
PushSource,
5-
RequestSource,
64
)
7-
from feast.types import Int64
85

96
# Feast also supports pulling data from data warehouses like BigQuery, Snowflake, Redshift and data lakes (e.g. via Redshift Spectrum, Trino, Spark)
107
driver_stats = FileSource(
@@ -20,13 +17,3 @@
2017
driver_stats_push_source = PushSource(
2118
name="driver_stats_push_source", batch_source=driver_stats,
2219
)
23-
24-
# Define a request data source which encodes features / information only
25-
# available at request time (e.g. part of the user initiated HTTP request)
26-
input_request = RequestSource(
27-
name="vals_to_add",
28-
schema=[
29-
Field(name="val_to_add", dtype=Int64),
30-
Field(name="val_to_add_2", dtype=Int64),
31-
],
32-
)

‎module_1/feature_repo/feature_services.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
)
1010

1111
feature_service = FeatureService(
12-
name="model_v2",
13-
features=[driver_hourly_stats_view, transformed_conv_rate,],
14-
owner="test3@gmail.com",
12+
name="model_v2", features=[driver_hourly_stats_view], owner="test3@gmail.com",
1513
)

‎module_1/feature_repo/feature_store.yaml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ online_store:
55
connection_string: localhost:6379
66
offline_store:
77
type: file
8-
flags:
9-
alpha_features: true
10-
on_demand_transforms: true

‎module_1/feature_repo/features.py‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from datetime import timedelta
22

3-
import pandas as pd
43
from feast import (
54
FeatureView,
65
Field,
76
)
8-
from feast.on_demand_feature_view import on_demand_feature_view
9-
from feast.types import Float32, Float64
7+
from feast.types import Float32
108

119
from data_sources import *
1210
from entities import *
@@ -37,19 +35,3 @@
3735
tags={"production": "True"},
3836
owner="test2@gmail.com",
3937
)
40-
41-
42-
# Define an on demand feature view which can generate new features based on
43-
# existing feature views and RequestSource features
44-
@on_demand_feature_view(
45-
sources=[driver_hourly_stats_view, input_request,],
46-
schema=[
47-
Field(name="conv_rate_plus_val1", dtype=Float64),
48-
Field(name="conv_rate_plus_val2", dtype=Float64),
49-
],
50-
)
51-
def transformed_conv_rate(inputs: pd.DataFrame) -> pd.DataFrame:
52-
df = pd.DataFrame()
53-
df["conv_rate_plus_val1"] = inputs["conv_rate"] + inputs["val_to_add"]
54-
df["conv_rate_plus_val2"] = inputs["conv_rate"] + inputs["val_to_add_2"]
55-
return df

‎module_1/module_1_architecture.png‎

101 KB
Loading

0 commit comments

Comments
 (0)