-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (47 loc) · 2.37 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
.PHONY: docs protos
PKG_NAME:=mira
# Select specific Python tests to run using pytest selectors
# e.g., make test TEST_SCOPE='-m "not_integration" tests/api/'
TEST_SCOPE?=tests/
# Prefix for running commands on the host vs in Docker (e.g., dev vs CI)
EXEC:=poetry run
SPHINX_AUTO_EXTRA:=
help:
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo
@echo "Tips"
@echo "----"
@echo '- Run `make shell` to activate the project virtualenv in your shell'
@echo ' e.g., make test TEST_SCOPE="-m not_integration tests/api/"'
protos: ## Build protobufs.
protoc --python_out=mira/core protos/scene.proto
patch-thirdparty: ## Patch thirdparty module import structure.
find mira/thirdparty/albumentations -name '*.py' -exec sed -i'.bak' -e 's/from albumentations/from mira.thirdparty.albumentations.albumentations/g' {} +
find mira/thirdparty/albumentations -name '*.py' -exec sed -i'.bak' -e 's/from .domain_adaptation import \*//g' {} +
find mira/thirdparty/smp -name '*.py' -exec sed -i'.bak' -e 's/from segmentation_models_pytorch/from mira.thirdparty.smp.segmentation_models_pytorch/g' {} +
find mira/thirdparty -name '*.py.bak' -exec rm {} +
init: patch-thirdparty ## Initialize the development environment.
pip install poetry-dynamic-versioning poetry
poetry install --all-extras --sync
format-check: ## Make black check source formatting
@$(EXEC) black --diff --check $(PKG_NAME) tests
format: ## Make black unabashedly format source code
@$(EXEC) black --exclude mira/thirdparty $(PKG_NAME) tests
package: patch-thirdparty ## Make a local build of the Python package, source dist and wheel
@rm -rf dist
@mkdir -p dist
@$(EXEC) poetry build
test: ## Make pytest run tests
@$(EXEC) pytest -vxrs $(TEST_SCOPE)
type-check: ## Make mypy check types
@$(EXEC) mypy $(PKG_NAME) tests
lint-check: ## Make pylint lint the package
@$(EXEC) pylint --rcfile pyproject.toml --jobs 0 $(PKG_NAME)
lab: ## Start a jupyter lab instance
@$(EXEC) jupyter lab
shell: ## Jump into poetry shell.
poetry shell
check: format-check type-check lint-check test ## Run all CI/CD checks
docs: ## Make a local HTML doc server that updates on changes to from Sphinx source
@$(EXEC) sphinx-autobuild -b html docs docs/build/html $(SPHINX_AUTO_EXTRA)