-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
205 lines (163 loc) · 5.21 KB
/
Makefile
File metadata and controls
205 lines (163 loc) · 5.21 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
# OpenControl Development Makefile
# Author: Nik Jois <nikjois@llamasearch.ai>
.PHONY: help install install-dev test test-all test-unit test-integration test-benchmark
.PHONY: lint format type-check clean build publish docs serve-docs
.PHONY: docker-build docker-run setup-hooks pre-commit run-interactive
# Default target
help:
@echo "OpenControl Development Commands"
@echo "==============================="
@echo ""
@echo "Setup Commands:"
@echo " install - Install package in editable mode"
@echo " install-dev - Install with development dependencies"
@echo " setup-hooks - Install pre-commit hooks"
@echo ""
@echo "Testing Commands:"
@echo " test - Run basic test suite"
@echo " test-all - Run all tests with coverage"
@echo " test-unit - Run unit tests only"
@echo " test-integration - Run integration tests"
@echo " test-benchmark - Run performance benchmarks"
@echo ""
@echo "Code Quality Commands:"
@echo " lint - Run all linters (black, isort, flake8, mypy)"
@echo " format - Format code with black and isort"
@echo " type-check - Run mypy type checking"
@echo " pre-commit - Run pre-commit on all files"
@echo ""
@echo "Build Commands:"
@echo " clean - Clean build artifacts"
@echo " build - Build package"
@echo " publish - Publish to PyPI (requires credentials)"
@echo ""
@echo "Documentation Commands:"
@echo " docs - Build documentation"
@echo " serve-docs - Serve documentation locally"
@echo ""
@echo "Docker Commands:"
@echo " docker-build - Build Docker image"
@echo " docker-run - Run Docker container"
@echo ""
@echo "Application Commands:"
@echo " run-interactive - Start OpenControl interactive mode"
# Installation commands
install:
pip install -e .
install-dev:
pip install -e ".[dev,docs,monitoring,visualization]"
setup-hooks:
pre-commit install
pre-commit install --hook-type commit-msg
# Testing commands
test:
python test_system.py
test-all:
pytest -v --cov=opencontrol --cov-report=html --cov-report=term-missing --cov-report=xml
test-unit:
pytest tests/unit/ -v
test-integration:
pytest tests/integration/ -v
test-benchmark:
pytest -m benchmark --benchmark-only
# Code quality commands
lint: black-check isort-check flake8 mypy
format:
black opencontrol/ tests/ scripts/
isort opencontrol/ tests/ scripts/
black-check:
black --check opencontrol/ tests/ scripts/
isort-check:
isort --check-only opencontrol/ tests/ scripts/
flake8:
flake8 opencontrol/ tests/ scripts/
mypy:
mypy opencontrol/
ruff:
ruff check opencontrol/ tests/ scripts/
ruff-fix:
ruff check --fix opencontrol/ tests/ scripts/
pre-commit:
pre-commit run --all-files
# Build commands
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf .coverage
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
build: clean
python -m build
publish: build
python -m twine upload dist/*
# Documentation commands
docs:
cd docs && make html
serve-docs:
cd docs/_build/html && python -m http.server 8080
# Docker commands
docker-build:
docker build -t opencontrol:latest -f docker/Dockerfile.inference .
docker-run:
docker run --rm -it -p 8000:8000 opencontrol:latest
docker-dev:
docker build -t opencontrol:dev -f docker/Dockerfile.dev .
docker run --rm -it -v $(PWD):/workspace opencontrol:dev
# Application commands
run-interactive:
opencontrol interactive
run-train:
opencontrol train --config configs/models/development.yaml
run-evaluate:
opencontrol evaluate --config configs/models/development.yaml
run-serve:
opencontrol serve --config configs/models/development.yaml
# Development workflow shortcuts
dev-setup: install-dev setup-hooks
@echo "Development environment setup complete!"
dev-check: format lint test
@echo "Development checks passed!"
ci-check: lint test-all
@echo "CI checks passed!"
# System requirements check
check-requirements:
@echo "Checking system requirements..."
@python -c "import sys; print(f'Python version: {sys.version}')"
@python -c "import torch; print(f'PyTorch version: {torch.__version__}')"
@python -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')"
@python -c "import torch; print(f'CUDA devices: {torch.cuda.device_count()}')" 2>/dev/null || echo "CUDA not available"
# Performance profiling
profile:
python -m cProfile -o profile.prof scripts/profile_model.py
python -c "import pstats; p = pstats.Stats('profile.prof'); p.sort_stats('cumulative').print_stats(20)"
# Security check
security:
safety check
bandit -r opencontrol/
# Update dependencies
update-deps:
pip-compile requirements.in --upgrade
pip-compile requirements-dev.in --upgrade
# Database/cache cleanup
clean-cache:
rm -rf .cache/
rm -rf logs/
rm -rf checkpoints/
rm -rf data/cache/
rm -rf wandb/
# Full reset (use with caution)
reset: clean clean-cache
rm -rf .venv/
@echo "Full reset complete. Run 'make dev-setup' to reinstall."
# Quick development cycle
quick: format lint test
@echo "Quick development cycle complete!"
# Release preparation
prepare-release: clean dev-check docs
@echo "Release preparation complete!"
@echo "Ready to tag and publish!"