-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (115 loc) · 4.05 KB
/
Copy pathMakefile
File metadata and controls
141 lines (115 loc) · 4.05 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
#* Variables
SHELL := /bin/bash
PYTHON := .venv/bin/python
.PHONY: help
help:
@echo "Commands:"
@echo "uv-download : downloads and installs the uv package manager"
@echo "install : installs required dependencies"
@echo "install-dev : installs the dev dependencies for the project"
@echo "update-deps : updates the dependencies and writes them to requirements.txt"
@echo "fix-style : run checks on files and potentially modifies them."
@echo "check-style : run checks on files without modifying them."
@echo "lint : run linting on all files"
@echo "test : run all tests."
@echo "test-cpu : run all tests that do not depend on Torch GPU support."
@echo "fast-test : run all quick tests."
@echo "build-docs : build mkdocs documentation."
@echo "serve-docs : serve documentation locally."
@echo "deploy-docs : deploy documentation to https://FOR-sight-ai.github.io/interpreto (gh-pages branch)"
@echo "docs : shortcut to build and serve generated documentation locally."
@echo "codecov : check coverage of all the code."
@echo "clean : cleans all unecessary files."
@echo "bump-version : bump the project version. Usage: make bump-version PART={major,minor,patch}"
#* UV
uv-download:
@echo "Downloading uv package manager..."
@if [[ $OS == "Windows_NT" ]]; then \
irm https://astral.sh/uv/install.ps1 | iex; \
else \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
fi
uv venv
.PHONY: uv-activate
uv-activate:
@if [[ "$(OS)" == "Windows_NT" ]]; then \
./uv/Scripts/activate.ps1 \
else \
source .venv/bin/activate; \
fi
#* Installation
.PHONY: install
install:
make uv-activate && uv pip install -e .
.PHONY: install-dev
install-dev:
make uv-activate && make update-deps && uv pip install -r requirements-dev.txt && pre-commit install && pre-commit autoupdate && uv pip install -e .
.PHONY: update-deps
update-deps:
uv pip compile pyproject.toml -o requirements.txt
uv pip compile --all-extras pyproject.toml -o requirements-dev.txt
.PHONY: install-ci
install-ci:
make uv-activate && make update-deps && uv pip install -r requirements-dev.txt
#* Linting
.PHONY: fix-style
fix-style:
$(PYTHON) -m ruff format --config pyproject.toml ./
$(PYTHON) -m ruff check --config pyproject.toml ./
.PHONY: check-style
check-style:
$(PYTHON) -m ruff format --check --config pyproject.toml ./
$(PYTHON) -m ruff check --no-fix --config pyproject.toml ./
.PHONY: lint
lint: fix-style
#* Testing
.PHONY: test
test:
$(PYTHON) -m pytest -n auto -c pyproject.toml -v
.PHONY: test-cpu
test-cpu:
$(PYTHON) -m pytest -n auto -c pyproject.toml -v -m "not require_cuda_gpu"
.PHONY: fast-test
fast-test:
$(PYTHON) -m pytest -n auto -c pyproject.toml -v -m "not slow"
# Limits the number of threads to 4 to avoid overloading the CI
.PHONY: fast-test-ci
fast-test-ci:
$(PYTHON) -m pytest -n 4 -c pyproject.toml -v -m "not slow"
.PHONY: codecov
codecov:
$(PYTHON) -m pytest -n auto --cov interpreto --cov-report html
#* Docs
.PHONY: build-docs
build-docs:
make uv-activate && mkdocs build
.PHONY: serve-docs
serve-docs:
make uv-activate && mkdocs serve
.PHONY: deploy-docs
deploy-docs:
make uv-activate && mkdocs gh-deploy
.PHONY: docs
docs: build-docs serve-docs
#* Cleaning
.PHONY: pycache-remove
pycache-remove:
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf
.PHONY: build-remove
build-remove:
rm -rf build/
.PHONY: clean
clean: pycache-remove build-remove # docker-remove
.PHONY: bump-version
bump-version:
@if [[ -z "$(PART)" ]]; then \
echo "PART is required. Usage: make bump-version PART={major,minor,patch}"; \
exit 1; \
fi
@.github/bump_version.sh $(PART)
# If you are a coding agent reading this file, like codex or cursor
# To run tests, you first need to install the dependencies
# If you want to run a single test, you can use the following command:
# make install-dev; python -m pytest -n auto -c pyproject.toml -v -m "not slow" $test_file_path
# If you want to run all tests, you can use the following command:
# make install-dev; make fast-test