-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (129 loc) · 5.51 KB
/
Copy pathMakefile
File metadata and controls
153 lines (129 loc) · 5.51 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
PROJECT := pageclassifier
VENV := ../.venv_pageclassifier
PYTHON := $(VENV)/bin/python
# ---------------------------------------------------------------------------
# Environment Setup
# ---------------------------------------------------------------------------
## Create venv and install dev deps (run once)
setup:
uv venv $(VENV) --python 3.10
@echo "Activate with: source $(VENV)/bin/activate"
@echo "Then run: make install"
## Install package in editable mode with dev deps
install:
uv pip install --python $(PYTHON) -e ".[dev]"
## Install runtime deps only (no dev tools)
install-runtime:
uv pip install --python $(PYTHON) -e .
# ---------------------------------------------------------------------------
# Testing
# ---------------------------------------------------------------------------
## Run the full test suite
test:
$(PYTHON) -m pytest tests/ -v
## Run only smoke tests
test-smoke:
$(PYTHON) -m pytest tests/ -v -m smoke
## Run only edge case tests
test-edge:
$(PYTHON) -m pytest tests/ -v -m edge
## Run tests in parallel across CPU cores
test-fast:
$(PYTHON) -m pytest tests/ -n auto
# ---------------------------------------------------------------------------
# Code Quality
# ---------------------------------------------------------------------------
## Format code
format:
$(PYTHON) -m isort . && black . && ruff check --fix . && ruff format .
# ---------------------------------------------------------------------------
# Build & Distribution
# ---------------------------------------------------------------------------
## Build the wheel and source distribution
build: clean-build
uv build
## Verify the built wheel installs cleanly into a throwaway venv
verify-wheel: build
rm -rf .verify_venv
uv venv .verify_venv --python 3.10
uv pip install --python .verify_venv/bin/python dist/$(PROJECT)-2.0.0-py3-none-any.whl
.verify_venv/bin/python -c "from pageclassifier import DocumentClassifier, classify_document, __version__; print(f'pageclassifier v{__version__} OK')"
rm -rf .verify_venv
@echo ""
@echo "Wheel verified: dist/$(PROJECT)-2.0.0-py3-none-any.whl"
# ---------------------------------------------------------------------------
# Experiments (Docker + Observability - NOT part of core module)
# ---------------------------------------------------------------------------
## Start Prometheus + Grafana + demo server
docker-up:
cd experiments && docker compose up -d --build
@echo ""
@echo "Demo server: http://localhost:8000"
@echo "Prometheus: http://localhost:9090"
@echo "Grafana: http://localhost:3000 (admin/admin)"
## Stop and clean up containers
docker-down:
cd experiments && docker compose down -v
## Run synthetic data generator (populates Grafana dashboards)
synthetic:
PYTHONPATH=. $(PYTHON) experiments/synthetic_generator.py --rate 10 --duration 300 --error-rate 0.05
# ---------------------------------------------------------------------------
# Cleanup
# ---------------------------------------------------------------------------
## Remove build artifacts
clean-build:
rm -rf dist/ build/ *.egg-info src/*.egg-info
## Remove all generated files (caches, build artifacts, verify venv)
clean: clean-build
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
find . -name "*.pyc" -type f -delete
find . -name "*.pyo" -type f -delete
find . -name ".DS_Store" -type f -delete
find . -type d -name ".vscode" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".idea" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".tox" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "dist" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "build" -exec rm -rf {} + 2>/dev/null || true
rm -rf .verify_venv
# ---------------------------------------------------------------------------
# Help
# ---------------------------------------------------------------------------
## Show this help
help:
@echo "Available targets:"
@echo ""
@echo " Setup:"
@echo " make setup Create venv with uv (python 3.10)"
@echo " make install Install package + dev deps in editable mode"
@echo " make install-runtime Install runtime deps only"
@echo ""
@echo " Testing:"
@echo " make test Run the full test suite"
@echo " make test-smoke Run smoke tests only"
@echo " make test-edge Run edge case tests only"
@echo " make test-fast Run tests in parallel across CPU cores"
@echo ""
@echo " Code Quality:"
@echo " make format Auto-format with isort + black + ruff"
@echo ""
@echo " Build:"
@echo " make build Build the wheel and sdist"
@echo " make verify-wheel Build then install wheel into a fresh venv"
@echo ""
@echo " Experiments:"
@echo " make docker-up Start Prometheus + Grafana + demo server"
@echo " make docker-down Stop and clean up containers"
@echo " make synthetic Run synthetic data generator"
@echo ""
@echo " Cleanup:"
@echo " make clean-build Remove dist/ and build artifacts"
@echo " make clean Remove all generated files and caches"
.PHONY: setup install install-runtime \
test test-smoke test-edge test-fast \
format \
build verify-wheel \
docker-up docker-down synthetic \
clean-build clean help