-
Notifications
You must be signed in to change notification settings - Fork 149
/
Makefile
104 lines (93 loc) · 4 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
.PHONY: build docs test
BUILDDIR := $(PWD)
CHECKDIRS := integrations src tests utils status examples setup.py
CHECKGLOBS := 'integrations/**/*.py' 'src/**/*.py' 'tests/**/*.py' 'utils/**/*.py' 'status/**/*.py' setup.py
DOCDIR := docs
MDCHECKGLOBS := 'docs/**/*.md' 'docs/**/*.rst' 'integrations/**/*.md'
MDCHECKFILES := CODE_OF_CONDUCT.md CONTRIBUTING.md DEVELOPING.md README.md
SPARSEZOO_TEST_MODE := "true"
BUILD_ARGS := # set nightly to build nightly release
TARGETS := "" # targets for running pytests: deepsparse,keras,onnx,pytorch,pytorch_models,export,pytorch_datasets,tensorflow_v1,tensorflow_v1_models,tensorflow_v1_datasets
PYTEST_ARGS ?= ""
PYTEST_INTEG_ARGS ?= ""
ifneq ($(findstring deepsparse,$(TARGETS)),deepsparse)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/deepsparse
endif
ifneq ($(findstring transformers,$(TARGETS)),transformers)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/transformers
endif
ifneq ($(findstring export,$(TARGETS)),export)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/export
endif
ifneq ($(findstring keras,$(TARGETS)),keras)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/keras
endif
ifneq ($(findstring onnx,$(TARGETS)),onnx)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/onnx
endif
ifneq ($(findstring pytorch,$(TARGETS)),pytorch)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/pytorch
endif
ifneq ($(findstring pytorch_models,$(TARGETS)),pytorch_models)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/pytorch/models
endif
ifneq ($(findstring pytorch_datasets,$(TARGETS)),pytorch_datasets)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/pytorch/datasets
endif
ifneq ($(findstring tensorflow_v1,$(TARGETS)),tensorflow_v1)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/tensorflow_v1
endif
ifneq ($(findstring tensorflow_v1_models,$(TARGETS)),tensorflow_v1_models)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/tensorflow_v1/models
endif
ifneq ($(findstring tensorflow_v1_datasets,$(TARGETS)),tensorflow_v1_datasets)
PYTEST_ARGS := $(PYTEST_ARGS) --ignore tests/sparseml/tensorflow_v1/datasets
endif
ifneq ($(findstring image_classification,$(TARGETS)),image_classification)
PYTEST_INTEGRATION_ARGS := $(PYTEST_INTEGRATION_ARGS) --ignore tests/integrations/image_classification
endif
ifneq ($(findstring transformers,$(TARGETS)),transformers)
PYTEST_INTEGRATION_ARGS := $(PYTEST_INTEGRATION_ARGS) --ignore tests/integrations/transformers
endif
ifneq ($(findstring yolov5,$(TARGETS)),yolov5)
PYTEST_INTEGRATION_ARGS := $(PYTEST_INTEGRATION_ARGS) --ignore tests/integrations/yolov5
endif
# run checks on all files for the repo
quality:
@echo "Running copyright checks";
python utils/copyright.py quality $(CHECKGLOBS) $(MDCHECKGLOBS) $(MDCHECKFILES)
@echo "Running python quality checks";
black --check $(CHECKDIRS);
isort --check-only $(CHECKDIRS);
flake8 $(CHECKDIRS);
# style the code according to accepted standards for the repo
style:
@echo "Running copyrighting";
python utils/copyright.py style $(CHECKGLOBS) $(MDCHECKGLOBS) $(MDCHECKFILES)
@echo "Running python styling";
black $(CHECKDIRS);
isort $(CHECKDIRS);
# run tests for the repo
test:
@echo "Running python tests";
SPARSEZOO_TEST_MODE="true" pytest tests $(PYTEST_ARGS) --ignore tests/integrations
# run integration tests
testinteg:
@echo "Running integration tests";
SPARSEZOO_TEST_MODE="true" pytest -x -ls tests/integrations $(PYTEST_INTEGRATION_ARGS)
# create docs
docs:
@echo "Running docs creation";
export SPARSEML_IGNORE_TFV1="True"; python utils/docs_builder.py --src $(DOCDIR) --dest $(DOCDIR)/build/html;
docsupdate:
@echo "Runnning update to api docs";
find $(DOCDIR)/api | grep .rst | xargs rm -rf;
export SPARSEML_IGNORE_TFV1="True"; sphinx-apidoc -o "$(DOCDIR)/api" src/sparseml;
# creates wheel file
build:
python3 setup.py sdist bdist_wheel $(BUILD_ARGS)
# clean package
clean:
rm -fr .pytest_cache;
rm -fr docs/_build docs/build;
find $(CHECKDIRS) | grep -E "(__pycache__|\.pyc|\.pyo)" | xargs rm -fr;