forked from inseq-team/inseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (127 loc) · 4.26 KB
/
Makefile
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
#* Variables
SHELL := /usr/bin/env bash
PYTHON := python3
#* Docker variables
IMAGE := inseq
VERSION := latest
.PHONY: help
help:
@echo "Commands:"
@echo "poetry-download : downloads and installs the poetry package manager"
@echo "poetry-remove : removes the poetry package manager"
@echo "install : installs required dependencies"
@echo "install-gpu : installs required dependencies, plus Torch GPU support"
@echo "install-dev : installs the dev dependencies for the project"
@echo "install-dev-gpu : installs the dev dependencies for the project, plus Torch GPU support"
@echo "update-deps : updates the dependencies and writes them to requirements.txt"
@echo "check-style : run checks on all files without fixing them."
@echo "fix-style : run checks on files and potentially modifies them."
@echo "check-safety : run safety checks on all tests."
@echo "lint : run linting on all files (check-style + check-safety)"
@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 "codecov : check coverage of all the code."
@echo "build-docs : build sphinx documentation."
@echo "serve-docs : serve documentation locally."
@echo "docs : build and serve generated documentation locally."
@echo "docker-build : builds docker image for the package."
@echo "docker-remove : removes built docker image."
@echo "clean : cleans all unecessary files."
#* Poetry
.PHONY: poetry-download
poetry-download:
curl -sSL https://install.python-poetry.org | $(PYTHON) -
.PHONY: poetry-remove
poetry-remove:
curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall
#* Installation
.PHONY: add-torch-gpu
add-torch-gpu:
poetry run poe upgrade-pip
poetry run pip uninstall torch -y
poetry run poe torch-cuda
.PHONY: install
install:
poetry install
.PHONY: install-dev
install-dev:
poetry install --all-extras --with lint,docs --sync
# -poetry run mypy --install-types --non-interactive ./
poetry run pre-commit install
poetry run pre-commit autoupdate
.PHONY: install-gpu
install-gpu: install add-torch-gpu
.PHONY: install-dev-gpu
install-dev-gpu: install-dev add-torch-gpu
.PHONY: install-ci
install-ci:
poetry install --with lint
.PHONY: update-deps
update-deps:
poetry lock
poetry export --without-hashes > requirements.txt
poetry export --without-hashes -E sklearn -E datasets -E notebook --with lint,docs > requirements-dev.txt
#* Linting
.PHONY: check-style
check-style:
poetry run ruff format --check --config pyproject.toml ./
poetry run ruff check --no-fix --config pyproject.toml ./
# poetry run darglint --verbosity 2 inseq tests
# poetry run mypy --config-file pyproject.toml ./
.PHONY: fix-style
fix-style:
poetry run ruff format --config pyproject.toml ./
poetry run ruff check --config pyproject.toml ./
.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report -i 53048
.PHONY: lint
lint: fix-style check-safety
#* Linting
.PHONY: test
test:
poetry run pytest -c pyproject.toml -v
.PHONY: test-cpu
test-cpu:
poetry run pytest -c pyproject.toml -v -m "not require_cuda_gpu"
.PHONY: fast-test
fast-test:
poetry run pytest -c pyproject.toml -v -m "not slow"
.PHONY: codecov
codecov:
poetry run pytest --cov inseq --cov-report html
#* Docs
.PHONY: build-docs
build-docs:
cd docs && make html SPHINXOPTS="-W -j 4"
.PHONY: serve-docs
serve-docs:
cd docs/_build/html && python3 -m http.server 8080
.PHONY: docs
docs: build-docs serve-docs
#* Docker
# Example: make docker VERSION=latest
# Example: make docker IMAGE=some_name VERSION=0.1.0
.PHONY: docker-build
docker-build:
@echo Building docker $(IMAGE):$(VERSION) ...
docker build \
-t $(IMAGE):$(VERSION) . \
-f ./docker/Dockerfile --no-cache
# Example: make clean_docker VERSION=latest
# Example: make clean_docker IMAGE=some_name VERSION=0.1.0
.PHONY: docker-remove
docker-remove:
@echo Removing docker $(IMAGE):$(VERSION) ...
# docker rmi -f $(IMAGE):$(VERSION)
#* 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