-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (71 loc) · 2.69 KB
/
Makefile
File metadata and controls
89 lines (71 loc) · 2.69 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
.PHONY: help install install-dev format lint test test-cov clean lock pre-commit-install pre-commit-run build-container run-container
# Default target
help:
@echo "Available commands:"
@echo " make install - Install production dependencies"
@echo " make install-dev - Install development dependencies"
@echo " make lock - Update lock file"
@echo " make format - Format code with ruff"
@echo " make lint - Lint code with ruff"
@echo " make test - Run tests"
@echo " make test-cov - Run tests with coverage report"
@echo " make pre-commit-install - Install pre-commit hooks"
@echo " make pre-commit-run - Run pre-commit on all files"
@echo " make clean - Clean cache and build artifacts"
@echo " make build-container - Build Apptainer container"
@echo " make run-container - Run command in container (usage: make run-container CMD='python -m src.train')"
# Installation
install:
uv sync
install-dev:
uv sync --all-extras --dev
lock:
uv lock
# Code quality
format:
uv run ruff format .
lint:
uv run ruff check .
format-check:
uv run ruff format --check .
lint-fix:
uv run ruff check --fix .
# Testing
test:
uv run pytest
test-cov:
uv run pytest --cov=ml_project_template --cov-report=html --cov-report=term-missing
# Pre-commit
pre-commit-install:
uv run pre-commit install
pre-commit-run:
uv run pre-commit run --all-files
# Containerization
build-container:
apptainer build --fakeroot image.sif Apptainer.def
run-container:
@if [ -z "$(CMD)" ]; then \
echo "Usage: make run-container CMD='python -m src.train'"; \
echo " Or multiple commands: make run-container CMD='uv run ruff format . && uv run pytest'"; \
exit 1; \
fi
apptainer exec --nv --cleanenv --bind "$(CURDIR)":/work --pwd /work image.sif bash -lc "set -euo pipefail; $(CMD)"
# Cleanup
clean:
find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name "*.egg-info" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -r {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -r {} + 2>/dev/null || true
find . -type d -name "htmlcov" -exec rm -r {} + 2>/dev/null || true
find . -type f -name ".coverage" -delete
find . -type f -name "coverage.xml" -delete
rm -f image.sif 2>/dev/null || true
@echo "Cleaned cache and build artifacts"
# Combined quality check (useful for CI)
check: format-check lint test
@echo "All checks passed!"
# Setup for new contributors
setup: install-dev pre-commit-install
@echo "Setup complete! Run 'make test' to verify installation."