-
Notifications
You must be signed in to change notification settings - Fork 232
/
Makefile
91 lines (67 loc) · 2.16 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
.DEFAULT_GOAL := help
PYTORCH_DOCKER_IMAGE = pytorch/pytorch:1.8.1-cuda11.1-cudnn8
PYTHON_DOCKER_IMAGE = python:3.8-buster
GIT_DESCRIBE = $(shell git describe --first-parent)
ARCHIVE = compressai.tar.gz
src_dirs := compressai tests examples docs
.PHONY: help
help: ## Show this message
@echo "Usage: make COMMAND\n\nCommands:"
@grep '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' | cat
# Check style and linting
.PHONY: check-black check-isort check-flake8 check-mypy static-analysis
check-black: ## Run black checks
@echo "--> Running black checks"
@black --check --verbose --diff $(src_dirs)
check-isort: ## Run isort checks
@echo "--> Running isort checks"
@isort --check-only $(src_dirs)
check-flake8: ## Run flake8 checks
@echo "--> Running flake8 checks"
@flake8 $(src_dirs)
check-mypy: ## Run mypy checks
@echo "--> Running mypy checks"
@mypy
static-analysis: check-black check-isort check-flake8 # check-mypy ## Run all static checks
# Apply styling
.PHONY: style
style: ## Apply style formating
@echo "--> Running black"
@black $(src_dirs)
@echo "--> Running isort"
@isort $(src_dirs)
# Run tests
.PHONY: tests coverage
tests: ## Run tests
@echo "--> Running Python tests"
@pytest -x -m "not slow" --cov compressai --cov-append --cov-report= ./tests/
coverage: ## Run coverage
@echo "--> Running Python coverage"
@coverage report
@coverage html
# Build docs
.PHONY: docs
docs: ## Build docs
@echo "--> Building docs"
@cd docs && SPHINXOPTS="-W" make html
# Docker images
.PHONY: docker docker-cpu
docker: ## Build docker image
@git archive --format=tar.gz HEAD > docker/${ARCHIVE}
@cd docker && \
docker build \
--build-arg PYTORCH_IMAGE=${PYTORCH_DOCKER_IMAGE} \
--build-arg WITH_JUPYTER=0 \
--progress=auto \
-t compressai:${GIT_DESCRIBE} .
@rm docker/${ARCHIVE}
docker-cpu: ## Build docker image (cpu only)
@git archive --format=tar.gz HEAD > docker/${ARCHIVE}
@cd docker && \
docker build \
-f Dockerfile.cpu \
--build-arg BASE_IMAGE=${PYTHON_DOCKER_IMAGE} \
--build-arg WITH_JUPYTER=0 \
--progress=auto \
-t compressai:${GIT_DESCRIBE}-cpu .
@rm docker/${ARCHIVE}