Skip to content

Commit abae10e

Browse files
Add index to constraint cookbook recipe & use local Spice instance
1 parent 450379d commit abae10e

4 files changed

Lines changed: 22 additions & 45 deletions

File tree

acceleration/constraints/Dockerfile.spiceai

Lines changed: 0 additions & 16 deletions
This file was deleted.

acceleration/constraints/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,24 @@ Start the Docker Compose stack:
2727

2828
`make`
2929

30-
Then observe the logs of the Spice runtime and the worker service.
31-
32-
`docker logs -f spiceai-constraint-demo`
30+
Then observe the logs of the worker service.
3331

3432
`docker logs -f spiceai-constraint-demo-worker`
3533

34+
## Spice Runtime
35+
36+
Start the Spice runtime in the same directory as the `spicepod.yaml` file:
37+
38+
```bash
39+
cd cookbook/acceleration/constraints
40+
spice run
41+
```
42+
3643
## Spice SQL REPL
3744

38-
In addition to viewing the logs, run queries using the Spice SQL REPL to explore the data and ensure the constraints are being kept.
45+
Run queries using the Spice SQL REPL to explore the data and ensure the constraints are being kept.
3946

40-
`docker exec -it spiceai-constraint-demo spiced --repl`
47+
`spice sql`
4148

4249
```bash
4350
Welcome to the interactive Spice.ai SQL Query Utility! Type 'help' for help.
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
services:
22
postgres:
3-
image: "postgres:alpine"
3+
image: 'postgres:alpine'
44
environment:
55
- POSTGRES_USER=postgres
66
- POSTGRES_PASSWORD=postgres
77
- POSTGRES_DB=postgres
88
expose:
9-
- "5432"
9+
- '5432'
10+
ports:
11+
- 15432:5432
1012
volumes:
1113
- ./init:/docker-entrypoint-initdb.d
1214
deploy:
@@ -18,33 +20,14 @@ services:
1820
cpus: '2'
1921
memory: 2G
2022
healthcheck:
21-
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres -h localhost"]
23+
test: ['CMD-SHELL', 'pg_isready -U postgres -d postgres -h localhost']
2224
interval: 10s
2325
timeout: 5s
2426
retries: 5
25-
spiceai-constraint-demo:
26-
build:
27-
dockerfile: Dockerfile.spiceai
28-
depends_on:
29-
- postgres
30-
container_name: spiceai-constraint-demo
31-
volumes:
32-
- ./spicepod.yaml:/root/spicepod.yaml
33-
expose:
34-
- "50051"
35-
deploy:
36-
resources:
37-
limits:
38-
cpus: '2'
39-
memory: 2G
40-
reservations:
41-
cpus: '2'
42-
memory: 2G
4327
worker:
4428
build: .
4529
depends_on:
4630
- postgres
47-
- spiceai-constraint-demo
4831
container_name: spiceai-constraint-demo-worker
4932
environment:
50-
- POSTGRES_CONN=host=postgres port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
33+
- POSTGRES_CONN=host=postgres port=5432 dbname=postgres user=postgres password=postgres sslmode=disable

acceleration/constraints/spicepod.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ datasets:
77
name: users
88
time_column: updated_at
99
params:
10-
pg_host: postgres
10+
pg_host: localhost
11+
pg_port: 15432
1112
pg_db: postgres
1213
pg_user: postgres
1314
pg_pass: postgres
@@ -18,5 +19,7 @@ datasets:
1819
refresh_mode: append
1920
refresh_check_interval: 5s
2021
primary_key: email
22+
indexes:
23+
username: enabled
2124
on_conflict:
2225
email: upsert

0 commit comments

Comments
 (0)