Skip to content

Commit 659cb6a

Browse files
committed
Use SQL Registry in module 1
Signed-off-by: Danny Chiao <danny@tecton.ai>
1 parent ce6b085 commit 659cb6a

File tree

6 files changed

+50
-20
lines changed

6 files changed

+50
-20
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
terraform.tfstate
66
terraform.tfstate.backup
77
.terraform*
8-
*.iml
8+
*.iml
9+
**/feast-postgres-data/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feast solves several common challenges teams face:
2020
### Pre-requisites
2121
This workshop assumes you have the following installed:
2222
- A local development environment that supports running Jupyter notebooks (e.g. VSCode with Jupyter plugin)
23-
- Python 3.7+
23+
- Python 3.8+
2424
- pip
2525
- Docker & Docker Compose (e.g. `brew install docker docker-compose`)
2626
- **Module 0 pre-requisites**:

module_1/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,32 @@ The key thing to note is that there are now a `miles_driven` field and a `daily_
5454
```yaml
5555
project: feast_demo_local
5656
provider: local
57-
registry:
58-
path: data/local_registry.db
59-
cache_ttl_seconds: 5
57+
registry:
58+
registry_type: sql
59+
path: postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast
6060
online_store:
6161
type: redis
6262
connection_string: localhost:6379
6363
offline_store:
6464
type: file
65+
entity_key_serialization_version: 2
6566
```
6667
67-
The key thing to note for now is the online store has been configured to be Redis. This is specifically for a single Redis node. If you want to use a Redis cluster, then you'd change this to something like:
68+
The key thing to note for now is the registry is now swapped for a SQL backed registry (Postgres) and the online store has been configured to be Redis. This is specifically for a single Redis node. If you want to use a Redis cluster, then you'd change this to something like:
6869
6970
```yaml
7071
project: feast_demo_local
7172
provider: local
72-
registry:
73-
path: data/local_registry.db
74-
cache_ttl_seconds: 5
73+
registry:
74+
registry_type: sql
75+
path: postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast
7576
online_store:
7677
type: redis
7778
redis_type: redis_cluster
7879
connection_string: "redis1:6379,redis2:6379,ssl=true,password=my_password"
7980
offline_store:
8081
type: file
82+
entity_key_serialization_version: 2
8183
```
8284
8385
Because we use `redis-py` under the hood, this means Feast also works well with hosted Redis instances like AWS Elasticache ([docs](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/ElastiCache-Getting-Started-Tutorials-Connecting.html)).
@@ -90,14 +92,15 @@ We then use Docker Compose to spin up the services we need.
9092
- This also deploys a Feast push server (on port 6567) + a Feast feature server (on port 6566).
9193
- These servers embed a `feature_store.yaml` file that enables them to connect to a remote registry. The Dockerfile mostly delegates to calling the `feast serve` CLI command, which instantiates a Feast python server ([docs](https://docs.feast.dev/reference/feature-servers/python-feature-server)):
9294
```yaml
93-
FROM python:3.7
95+
FROM python:3.8
9496
95-
RUN pip install "feast[redis]"
97+
RUN pip install "feast[redis,postgres]"
9698
9799
COPY feature_repo/feature_store.yaml feature_store.yaml
98100
99-
# Needed to reach online store within Docker network.
101+
# Needed to reach online store and registry within Docker network.
100102
RUN sed -i 's/localhost:6379/redis:6379/g' feature_store.yaml
103+
RUN sed -i 's/127.0.0.1:55001/registry:5432/g' feature_store.yaml
101104
ENV FEAST_USAGE=False
102105
103106
CMD ["feast", "serve", "-h", "0.0.0.0"]
@@ -115,7 +118,8 @@ Creating broker ... done
115118
Creating feast_feature_server ... done
116119
Creating feast_push_server ... done
117120
Creating kafka_events ... done
118-
Attaching to zookeeper, redis, broker, feast_push_server, feast_feature_server, kafka_events
121+
Creating registry ... done
122+
Attaching to zookeeper, redis, broker, feast_push_server, feast_feature_server, kafka_events, registry
119123
...
120124
```
121125
## Step 5: Why register streaming features in Feast?
@@ -179,7 +183,9 @@ Run the Jupyter notebook ([feature_repo/workshop.ipynb](feature_repo/module_1.ip
179183
### Scheduling materialization
180184
To ensure fresh features, you'll want to schedule materialization jobs regularly. This can be as simple as having a cron job that calls `feast materialize-incremental`.
181185

182-
Users may also be interested in integrating with Airflow, in which case you can build a custom Airflow image with the Feast SDK installed, and then use a `BashOperator` (with `feast materialize-incremental`) or `PythonOperator` (with `store.materialize_incremental(datetime.datetime.now())`):
186+
Users may also be interested in integrating with Airflow, in which case you can build a custom Airflow image with the Feast SDK installed, and then use a `BashOperator` (with `feast materialize-incremental`) or `PythonOperator` (with `store.materialize_incremental(datetime.datetime.now())`).
187+
188+
We setup a standalone version of Airflow to
183189

184190
#### Airflow PythonOperator
185191

module_1/docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ services:
4444
build:
4545
context: .
4646
dockerfile: feature_repo/Dockerfile
47+
depends_on:
48+
registry:
49+
condition: service_healthy
4750
ports:
4851
- "6567:6566"
4952
volumes:
@@ -58,6 +61,9 @@ services:
5861
build:
5962
context: .
6063
dockerfile: feature_repo/Dockerfile
64+
depends_on:
65+
registry:
66+
condition: service_healthy
6167
ports:
6268
- "6566:6566"
6369
volumes:
@@ -66,3 +72,19 @@ services:
6672
target: /data/local_registry.db
6773
links:
6874
- redis
75+
76+
registry:
77+
container_name: registry
78+
image: postgres:10.5
79+
environment:
80+
- POSTGRES_USER=postgres
81+
- POSTGRES_PASSWORD=mysecretpassword
82+
- POSTGRES_DB=feast
83+
ports:
84+
- "55001:5432"
85+
volumes:
86+
- ./feast-postgres-data:/var/lib/postgresql/data
87+
healthcheck:
88+
test: ["CMD", "pg_isready", "-U", "postgres"]
89+
interval: 5s
90+
retries: 5

module_1/feature_repo/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
FROM python:3.7
1+
FROM python:3.8
22

3-
RUN pip install "feast[redis]"
3+
RUN pip install "feast[redis,postgres]"
44

55
COPY feature_repo/feature_store.yaml feature_store.yaml
66

7-
# Needed to reach online store within Docker network.
7+
# Needed to reach online store and registry within Docker network.
88
RUN sed -i 's/localhost:6379/redis:6379/g' feature_store.yaml
9+
RUN sed -i 's/127.0.0.1:55001/registry:5432/g' feature_store.yaml
910
ENV FEAST_USAGE=False
1011

1112
CMD ["feast", "serve", "-h", "0.0.0.0"]

module_1/feature_repo/feature_store.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
project: feast_demo_local
22
provider: local
3-
registry:
4-
path: data/local_registry.db
5-
cache_ttl_seconds: 5
3+
registry:
4+
registry_type: sql
5+
path: postgresql://postgres:mysecretpassword@127.0.0.1:55001/feast
66
online_store:
77
type: redis
88
connection_string: localhost:6379

0 commit comments

Comments
 (0)