-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
248 lines (201 loc) · 6.47 KB
/
Makefile
File metadata and controls
248 lines (201 loc) · 6.47 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# VideoAnnotator - Modern Development Workflow
# Uses uv for fast, reliable package management
PY := uv run
UV := export PATH="$$HOME/.local/bin:$$PATH" && uv
# Default target
.PHONY: help
help:
@echo "VideoAnnotator - Development Commands"
@echo ""
@echo "Setup:"
@echo " install Install dependencies with uv"
@echo " install-dev Install dev dependencies and setup pre-commit"
@echo " install-torch-cuda Install PyTorch with CUDA support"
@echo ""
@echo "Code Quality:"
@echo " lint Run ruff linter"
@echo " format Format code with ruff"
@echo " typecheck Run mypy type checking"
@echo " quality-check Run all quality checks"
@echo ""
@echo "Testing:"
@echo " test Run pytest test suite"
@echo " test-fast Run fast unit tests (~30s)"
@echo " test-integration Run integration tests (~5min)"
@echo " test-all Run complete test suite"
@echo " test-cov Run tests with coverage report"
@echo ""
@echo "Development:"
@echo " server Start API server"
@echo " server-dev Start API server with auto-reload"
@echo " demo Run basic demo"
@echo " demo-batch Run batch processing demo"
@echo ""
@echo "Docker:"
@echo " docker-build Build CPU Docker image"
@echo " docker-build-gpu Build GPU Docker image"
@echo ""
@echo "Utilities:"
@echo " clean Clean build artifacts and cache"
@echo " check-env Check environment status"
@echo " lock Update lockfile"
@echo " sync Sync environment with lockfile"
@echo " help Show this help message"
# Installation and environment
.PHONY: install
install:
$(UV) sync
.PHONY: install-dev
install-dev: install
$(UV) add --dev ruff mypy pytest pre-commit
$(PY) pre-commit install
# Testing commands
.PHONY: test
test:
$(PY) pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=html
.PHONY: test-unit
test-unit:
$(PY) pytest tests/ -v -m "unit" --cov=src --cov-report=term-missing
.PHONY: test-integration
test-integration:
$(PY) pytest tests/ -v -m "integration" --cov=src --cov-report=term-missing
.PHONY: test-performance
test-performance:
$(PY) pytest tests/ -v -m "performance" --benchmark-only
.PHONY: test-fast
test-fast:
$(PY) python scripts/test_fast.py
.PHONY: test-all
test-all:
$(PY) python scripts/test_all.py
# Code quality commands (now using Ruff)
.PHONY: lint
lint:
$(PY) ruff check .
.PHONY: format
format:
$(PY) ruff format .
.PHONY: format-check
format-check:
$(PY) ruff format --check .
.PHONY: type-check
type-check:
$(PY) mypy src
.PHONY: quality-check
quality-check: lint format-check type-check
@echo "All quality checks passed!"
# Build commands
.PHONY: clean
clean:
rm -rf build/ dist/ *.egg-info/
rm -rf .pytest_cache/ .mypy_cache/ .ruff_cache/ htmlcov/
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
.PHONY: build
build: clean
$(UV) build
# API server commands
.PHONY: server
server:
$(PY) videoannotator server --host 0.0.0.0 --port 18011
.PHONY: server-dev
server-dev:
$(PY) videoannotator server --host 0.0.0.0 --port 18011 --reload --dev
# PyTorch CUDA installation helper
.PHONY: install-torch-cuda
install-torch-cuda:
@echo "Installing PyTorch with CUDA support..."
@echo "Check https://pytorch.org/get-started/locally/ for latest versions"
$(UV) add "torch>=2.4.0" "torchvision>=0.19.0" "torchaudio>=2.4.0" --index-url https://download.pytorch.org/whl/cu124
# Environment helpers
.PHONY: check-env
check-env:
@echo "UV Version: $$($(UV) --version || echo 'uv not found')"
@echo "Python Version: $$($(PY) python --version || echo 'Python not available')"
.PHONY: lock
lock:
$(UV) lock
.PHONY: sync
sync:
$(UV) sync
# Docker commands
docker-build:
docker build -f Dockerfile.cpu -t videoannotator:cpu .
docker-build-gpu:
docker build -f Dockerfile.gpu -t videoannotator:gpu .
docker-run:
docker run --rm -p 18011:18011 -v $(PWD)/data:/app/data -v $(PWD)/output:/app/output -v $(PWD)/database:/app/database -v $(PWD)/logs:/app/logs videoannotator:cpu
docker-run-gpu:
docker run --gpus all --rm -p 18011:18011 -v $(PWD)/data:/app/data -v $(PWD)/output:/app/output -v $(PWD)/database:/app/database -v $(PWD)/logs:/app/logs videoannotator:gpu
docker-dev:
docker compose up --build
docker-jupyter:
@echo "No Jupyter Compose service is defined in docker-compose.yml."
# Documentation commands
docs:
@echo "Building documentation..."
@mkdir -p docs/build
@echo "Documentation build completed!"
serve-docs:
@echo "Serving documentation on http://localhost:18011"
@cd docs && python -m http.server 18011
# Analysis commands
benchmark:
pytest tests/ -v -m "performance" --benchmark-only --benchmark-json=benchmark.json
@echo "Benchmark results saved to benchmark.json"
security-scan:
bandit -r src/
safety check
pip-audit
# Pre-commit setup
setup-pre-commit:
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit:
pre-commit run --all-files
# Example usage commands
example-basic:
python examples/basic_video_processing.py
example-batch:
python examples/batch_processing.py
example-pipelines:
python examples/test_individual_pipelines.py
example-config:
python examples/custom_pipeline_config.py
# CLI examples
demo-default:
uv run python -m src.cli --help
demo-server:
uv run python -m src.cli server --help
demo-version:
uv run python -m src.cli version
# Development environment setup
dev-setup: install-dev setup-pre-commit
@echo "Development environment setup complete!"
@echo "Run 'make test' to verify everything is working."
# Production environment setup
prod-setup: install
@echo "Production environment setup complete!"
# Full development cycle
dev-cycle: quality-check test
@echo "Development cycle complete - ready for commit!"
# Release preparation
release-prep: clean quality-check test build
@echo "Release preparation complete!"
@echo "Review the build artifacts in dist/ before publishing."
# Quick start for new developers
quickstart:
@echo "VideoAnnotator Quick Start"
@echo "=========================="
@echo ""
@echo "1. Setting up development environment..."
$(MAKE) dev-setup
@echo ""
@echo "2. Running tests to verify installation..."
$(MAKE) test-unit
@echo ""
@echo "3. Quick start complete! Try these commands:"
@echo " make demo-default # Show CLI help"
@echo " make example-basic # Run basic example"
@echo " make test # Run full test suite"
@echo " make quality-check # Check code quality"