-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (62 loc) · 3.13 KB
/
Copy pathMakefile
File metadata and controls
81 lines (62 loc) · 3.13 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
# Railway Wagon Inspection System
#
# make help list every target
# make up run the whole stack in Docker
# make test run every test suite
#
# `make setup` builds one virtualenv per Python component. They are separate on
# purpose: the backend and the edge pipeline have genuinely conflicting pins
# (numpy<2 for OpenCV, and a torch build the backend must never pull in).
PYTHON ?= python3
COMPOSE ?= docker compose
BACKEND_VENV := backend/.venv
EDGE_PIPELINE_VENV := edge-pipeline/.venv
EDGE_DEVICE_VENV := edge-device/.venv
OCR_VENV := ocr-service/.venv
.DEFAULT_GOAL := help
.PHONY: help setup test test-backend test-edge-pipeline test-edge-device \
up down logs migrate demo dashboard clean
help: ## Show this help
@grep -hE '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ----------------------------------------------------------------- setup --
setup: $(BACKEND_VENV) $(EDGE_PIPELINE_VENV) $(EDGE_DEVICE_VENV) ## Create all virtualenvs
@echo "Environments ready. Next: make migrate"
$(BACKEND_VENV):
$(PYTHON) -m venv $@ && $@/bin/pip install -q --upgrade pip \
&& $@/bin/pip install -q -r backend/requirements.txt
$(EDGE_PIPELINE_VENV):
$(PYTHON) -m venv $@ && $@/bin/pip install -q --upgrade pip \
&& $@/bin/pip install -q -r edge-pipeline/requirements.txt
$(EDGE_DEVICE_VENV):
$(PYTHON) -m venv $@ && $@/bin/pip install -q --upgrade pip \
&& $@/bin/pip install -q -r edge-device/requirements.txt \
&& $@/bin/python edge-device/scripts/generate_protos.py
# ------------------------------------------------------------------ test --
test: test-backend test-edge-pipeline test-edge-device ## Run every test suite
@echo "All suites passed."
test-backend: ## Backend: ingest, analytics, REST API, WebSockets
cd backend && .venv/bin/python manage.py test
test-edge-pipeline: ## Edge pipeline: health scoring, OCR voting, asset resolution
cd edge-pipeline && .venv/bin/python -m unittest discover -s tests -t . -v
test-edge-device: ## Edge device: decision policy, enhancement, capture pipeline
cd edge-device && .venv/bin/python -m unittest discover -s tests -t . -v
# ----------------------------------------------------------------- docker --
up: ## Build and start the whole stack
$(COMPOSE) up --build
down: ## Stop the stack and remove containers
$(COMPOSE) down
logs: ## Tail logs from every service
$(COMPOSE) logs -f
# ------------------------------------------------------------------ local --
migrate: ## Apply database migrations locally
cd backend && .venv/bin/python manage.py migrate
demo: ## Run the edge pipeline over the bundled sample video
cd edge-pipeline && .venv/bin/python simulation_pipeline.py --input sample_wagon.mp4
dashboard: ## Serve the dashboard at http://localhost:8080
cd dashboard && $(PYTHON) -m http.server 8080
clean: ## Remove venvs, caches and generated output
rm -rf $(BACKEND_VENV) $(EDGE_PIPELINE_VENV) $(EDGE_DEVICE_VENV) $(OCR_VENV)
rm -rf edge-device/generated edge-pipeline/verified_output
find . -name '__pycache__' -type d -prune -exec rm -rf {} +
find . -name '*.pyc' -delete