Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (149 loc) Β· 5.9 KB
/
Copy pathMakefile
File metadata and controls
175 lines (149 loc) Β· 5.9 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
# NNPID Project Makefile
# Code quality, testing, and automation
.PHONY: help lint format check security test clean install dev
# Default target
help:
@echo "NNPID Development Commands"
@echo "=========================="
@echo ""
@echo "Code Quality:"
@echo " make lint - Run all linters (ruff, mypy)"
@echo " make format - Format code (ruff format)"
@echo " make check - Full code review (lint + security + complexity)"
@echo " make security - Security scan (bandit)"
@echo " make complexity - Code complexity analysis (radon)"
@echo " make deadcode - Find unused code (vulture)"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests"
@echo " make test-cov - Run tests with coverage"
@echo " make test-fast - Run fast tests only"
@echo ""
@echo "Development:"
@echo " make install - Install project dependencies"
@echo " make dev - Install dev dependencies"
@echo " make clean - Clean build artifacts"
@echo " make pre-commit - Install pre-commit hooks"
@echo ""
@echo "Training:"
@echo " make train - Start yaw tracker training"
@echo " make train-mega - Start mega training (20M steps)"
@echo " make status - Check training status"
@echo ""
# =============================================================================
# Code Quality
# =============================================================================
lint:
@echo "π Running ruff linter..."
ruff check src/ scripts/ tests/
@echo "π Running ruff format check..."
ruff format --check src/ scripts/ tests/
@echo "β
Lint passed!"
format:
@echo "π¨ Formatting code with ruff..."
ruff format src/ scripts/ tests/
@echo "π§ Auto-fixing issues..."
ruff check --fix src/ scripts/ tests/
@echo "β
Formatting complete!"
mypy:
@echo "π Running mypy type checker..."
mypy src/ --ignore-missing-imports
@echo "β
Type check passed!"
security:
@echo "π Running bandit security scan..."
bandit -r src/ -ll -q
@echo "β
Security check passed!"
complexity:
@echo "π Analyzing code complexity..."
@echo ""
@echo "=== Cyclomatic Complexity (C+ = needs attention) ==="
radon cc src/ scripts/ -a -s --min C
@echo ""
@echo "=== Maintainability Index (B- = needs attention) ==="
radon mi src/ -s --min B
@echo "β
Complexity analysis complete!"
deadcode:
@echo "π Finding dead code..."
vulture src/ scripts/ --min-confidence 80
@echo "β
Dead code analysis complete!"
# Full code review
check: lint security complexity
@echo ""
@echo "================================================"
@echo "β
ALL CODE QUALITY CHECKS PASSED!"
@echo "================================================"
# Quick check (fast, for pre-commit)
quick-check:
@ruff check src/ scripts/ --quiet
@ruff format --check src/ scripts/ --quiet
# =============================================================================
# Testing
# =============================================================================
test:
@echo "π§ͺ Running tests..."
pytest tests/ -v
test-cov:
@echo "π§ͺ Running tests with coverage..."
pytest tests/ -v --cov=src --cov-report=html --cov-report=term
test-fast:
@echo "π§ͺ Running fast tests..."
pytest tests/ -v -m "not slow"
# =============================================================================
# Development Setup
# =============================================================================
install:
@echo "π¦ Installing dependencies..."
pip install -e .
dev:
@echo "π¦ Installing dev dependencies..."
pip install -e ".[dev,full]"
pip install ruff mypy bandit vulture radon pyright
@echo "π Installing pre-commit hooks..."
pre-commit install
pre-commit:
@echo "π Installing pre-commit hooks..."
pre-commit install
@echo "β
Pre-commit hooks installed!"
clean:
@echo "π§Ή Cleaning build artifacts..."
rm -rf build/ dist/ *.egg-info
rm -rf .pytest_cache .mypy_cache .ruff_cache
rm -rf htmlcov/ .coverage
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@echo "β
Clean complete!"
# =============================================================================
# Training
# =============================================================================
train:
@echo "π Starting yaw tracker training..."
python scripts/train_yaw_tracker.py --config config/yaw_tracking.yaml
train-mega:
@echo "π Starting MEGA training (20M steps)..."
nohup python scripts/train_yaw_tracker.py --config config/yaw_tracking_mega.yaml > /tmp/training_mega.log 2>&1 &
@echo "Training started in background. Check with: make status"
status:
@echo "π Training Status"
@echo "=================="
@python3 -c "\
import numpy as np; \
from pathlib import Path; \
import glob; \
runs = sorted(glob.glob('runs/yaw_tracking_*/eval_logs/evaluations.npz'), key=lambda x: Path(x).stat().st_mtime, reverse=True); \
f = runs[0] if runs else None; \
print(f'Run: {Path(f).parent.parent.name}') if f else print('No runs found'); \
d = np.load(f) if f else None; \
print(f'Steps: {int(d[\"timesteps\"][-1]):,}') if d is not None and len(d['timesteps']) > 0 else None; \
print(f'Reward: {np.mean(d[\"results\"][-1]):.2f}') if d is not None and len(d['results']) > 0 else None; \
" 2>/dev/null || echo "No training data found"
@ps aux | grep "train_yaw_tracker" | grep -v grep | head -1 || echo "No training process running"
# =============================================================================
# Visualization
# =============================================================================
viz:
@echo "π¬ Starting visualization..."
@LATEST=$$(ls -t runs/*/checkpoints/*.zip 2>/dev/null | head -1); \
if [ -z "$$LATEST" ]; then echo "No models found"; exit 1; fi; \
echo "Using model: $$LATEST"; \
python scripts/run_mega_viz.py --model "$$LATEST" --viz-mode full --episodes 1 --max-steps 500 --record /tmp/viz_output.mp4
@echo "Video saved to /tmp/viz_output.mp4"
@open /tmp/viz_output.mp4 2>/dev/null || echo "Open: /tmp/viz_output.mp4"