|
1 | | -# Feast Spark + Kafka workshop |
| 1 | +# Feast Spark + Kafka + Redis workshop |
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
5 | | -This workshop focuses on how to achieve a common architecture: |
| 5 | +This workshop aims to teach basic Feast concepts and walk you through focuses on how to achieve a common architecture: |
6 | 6 |
|
7 | 7 | TODO: add architecture diagram |
8 | 8 |
|
9 | 9 | - **Data sources**: Kafka + File source |
10 | 10 | - **Online store**: Redis |
11 | | -- **Use cases**: Predicting churn for drivers |
| 11 | +- **Use case**: Predicting churn for drivers |
12 | 12 | - Batch scoring via offline store |
13 | 13 | - Real time scoring via online store |
14 | 14 |
|
15 | | -We will generate a model that will predict whether a driver will churn |
| 15 | +We will generate a model that will predict whether a driver will churn. |
| 16 | + |
| 17 | +## Pre-requisites |
| 18 | +This workshop assumes you have the following installed: |
| 19 | +- A local development environment that supports running Jupyter notebooks (e.g. VSCode with Jupyter plugin) |
| 20 | +- Python 3.7+ |
| 21 | +- pip |
| 22 | +- Docker & Docker Compose (e.g. `brew install docker docker-compose`) |
16 | 23 |
|
17 | 24 | ## Setup |
18 | 25 |
|
19 | 26 | ### Docker + Kafka + Redis |
20 | | -First, we need Docker and Docker Compose |
| 27 | +First, we install Feast with Redis support: |
21 | 28 | ``` |
22 | | -brew install docker docker-compose |
| 29 | +pip install "feast[redis]" |
23 | 30 | ``` |
24 | 31 |
|
25 | | -We then install the requirements: |
26 | | -``` |
27 | | -pip install -r requirements.txt |
28 | | -``` |
29 | | - |
30 | | -We then spin up a local Kafka cluster that generates events into a topic. |
| 32 | +We then use Docker Compose to spin up a local Kafka cluster and automatically publish events to it. |
| 33 | +- 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. |
31 | 34 |
|
32 | 35 | ``` |
33 | 36 | docker-compose up |
34 | 37 | ``` |
35 | 38 |
|
36 | | -### Generate a topic |
37 | | -If you run `python kafka_demo.py`, we now start generating streaming events from the parquet file continously (with sleeps to slow down event writes). We hard-code events to be a year fresher than what is available in the file. |
38 | | - |
39 | | -### Register a push source |
40 | | -This push source reflects the transformed features you're generating in Spark Structured Streaming. Here, we have a push source that will materialize the transformed features from the batch file source as well as push transformed features into the online store from a Push API. |
41 | | - |
42 | | -```python |
43 | | -driver_stats = FileSource( |
44 | | - path="data/driver_stats.parquet", |
45 | | - timestamp_field="event_timestamp", |
46 | | - created_timestamp_column="created", |
47 | | - description="A table describing the stats of a driver based on hourly logs", |
48 | | - owner="test@gmail.com", |
49 | | -) |
50 | | - |
51 | | -driver_stats_push_source = PushSource( |
52 | | - name="driver_stats_push_source", batch_source=driver_stats, |
53 | | -) |
54 | | - |
55 | | -driver_daily_features_view = FeatureView( |
56 | | - name="driver_daily_features", |
57 | | - entities=["driver"], |
58 | | - ttl=timedelta(seconds=8640000000), |
59 | | - schema=[Field(name="daily_miles_driven", dtype=Float32),], |
60 | | - online=True, |
61 | | - source=driver_stats_push_source, |
62 | | - tags={"production": "True"}, |
63 | | - owner="test2@gmail.com", |
64 | | -) |
65 | | -``` |
66 | 39 | ### Setting up Feast |
67 | 40 |
|
68 | 41 | Install Feast using pip |
|
0 commit comments