-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (70 loc) · 2.4 KB
/
Makefile
File metadata and controls
84 lines (70 loc) · 2.4 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
.PHONY: install install-dev format check test run dummy-run db-up db-down migrate _ensure-env _ensure-frontend-env
UV_EXTRA ?=
PG_CONTAINER := serving-api-pg
PG_PORT := 5433
PG_USER := serving
PG_PASS := serving
PG_DB := serving
DATABASE_URL := postgresql://$(PG_USER):$(PG_PASS)@localhost:$(PG_PORT)/$(PG_DB)
install:
uv pip install $(UV_EXTRA) -r backend/requirements.txt
install-dev:
uv pip install $(UV_EXTRA) -r backend/requirements-dev.txt
format:
ruff check --fix backend/
ruff format backend/
check:
ruff check backend/
ruff format --check backend/
test:
pytest backend/tests/ -v
_ensure-env:
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo "copied .env.example -> .env"; \
fi
_ensure-frontend-env:
@if [ ! -f frontend/.env ]; then \
cp frontend/.env.example frontend/.env; \
echo "copied frontend/.env.example -> frontend/.env (fill in AUTH0_* to enable login)"; \
fi
db-up:
@if [ -z "$$(docker ps -q -f name=^/$(PG_CONTAINER)$$)" ]; then \
if [ -n "$$(docker ps -aq -f name=^/$(PG_CONTAINER)$$)" ]; then \
echo "starting existing $(PG_CONTAINER) container"; \
docker start $(PG_CONTAINER) > /dev/null; \
else \
echo "creating $(PG_CONTAINER) container on :$(PG_PORT)"; \
docker run -d --name $(PG_CONTAINER) \
-e POSTGRES_USER=$(PG_USER) \
-e POSTGRES_PASSWORD=$(PG_PASS) \
-e POSTGRES_DB=$(PG_DB) \
-p $(PG_PORT):5432 \
postgres:16 > /dev/null; \
fi; \
fi
@printf "waiting for postgres"; \
for i in $$(seq 1 30); do \
if docker exec $(PG_CONTAINER) pg_isready -U $(PG_USER) -d $(PG_DB) > /dev/null 2>&1; then \
echo " ready"; exit 0; \
fi; \
printf "."; sleep 1; \
done; \
echo " timed out"; exit 1
db-down:
-docker stop $(PG_CONTAINER) > /dev/null 2>&1
-docker rm $(PG_CONTAINER) > /dev/null 2>&1
migrate: _ensure-env db-up
alembic upgrade head
run: _ensure-env _ensure-frontend-env db-up migrate
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8080 & \
cd frontend && npm run dev & \
wait
# Same as `run` but forces the model list to come from the synthesised
# upgraded fixture instead of the live OpenTela endpoint. Useful for
# iterating on the model-card UI without depending on prod state.
dummy-run: _ensure-env _ensure-frontend-env db-up migrate
OTELA_FIXTURE_PATH=$(PWD)/backend/tests/fixtures/dnt_table_upgraded.json \
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8080 & \
cd frontend && npm run dev & \
wait