forked from bentoml/BentoML
/
Makefile
91 lines (78 loc) · 3.62 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
SHELL := /bin/bash
.DEFAULT_GOAL := help
GIT_ROOT ?= $(shell git rev-parse --show-toplevel)
USE_VERBOSE ?=false
USE_GPU ?= false
USE_GRPC ?= false
help: ## Show all Makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: format format-proto lint lint-proto type style clean
format: ## Running code formatter: black and isort
@./scripts/tools/formatter.sh
format-proto: ## Running proto formatter: buf
@echo "Formatting proto files..."
docker run --init --rm --volume $(GIT_ROOT):/workspace --workdir /workspace bufbuild/buf format --config "/workspace/bentoml/grpc/buf.yaml" -w --path "bentoml/grpc"
lint: ## Running lint checker: pylint
@./scripts/tools/linter.sh
lint-proto: ## Running proto lint checker: buf
@echo "Linting proto files..."
docker run --init --rm --volume $(GIT_ROOT):/workspace --workdir /workspace bufbuild/buf lint --config "/workspace/bentoml/grpc/buf.yaml" --error-format msvs --path "bentoml/grpc"
type: ## Running type checker: pyright
@./scripts/tools/type_checker.sh
style: format lint format-proto lint-proto ## Running formatter and linter
clean: ## Clean all generated files
@echo "Cleaning all generated files..."
@cd $(GIT_ROOT)/docs && make clean
@cd $(GIT_ROOT) || exit 1
@find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
ci-%:
$(eval style := $(subst ci-, ,$@))
@./scripts/ci/style/$(style)_check.sh
.PHONY: ci-format
ci-format: ci-black ci-isort ## Running format check in CI: black, isort
.PHONY: ci-lint
ci-lint: ci-pylint ## Running lint check in CI: pylint
.PHONY: tests-suite
tests-suite: tests-unit tests-http_server tests-grpc_server ## Running BentoML tests suite (unit, e2e, integration)
tests-%:
$(eval type :=$(subst tests-, , $@))
$(eval RUN_ARGS:=$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)))
$(eval __positional:=$(foreach t, $(RUN_ARGS), -$(t)))
ifeq ($(USE_VERBOSE),true)
./scripts/ci/run_tests.sh -v $(type) $(__positional)
else ifeq ($(USE_GPU),true)
./scripts/ci/run_tests.sh -v $(type) --run-gpu-tests $(__positional)
else ifeq ($(USE_GPRC),true)
./scripts/ci/run_tests.sh -v $(type) --run-gprc-tests $(__positional)
else
./scripts/ci/run_tests.sh $(type) $(__positional)
endif
install-local: ## Install BentoML in editable mode
@pip install --editable .
install-dev-deps: ## Install all dev dependencies
@echo Installing dev dependencies...
@pip install -r requirements/dev-requirements.txt
install-tests-deps: ## Install all tests dependencies
@echo Installing tests dependencies...
@pip install -r requirements/tests-requirements.txt
install-docs-deps: ## Install documentation dependencies
@echo Installing docs dependencies...
@pip install -r requirements/docs-requirements.txt
# Docs
watch-docs: install-docs-deps ## Build and watch documentation
sphinx-autobuild docs/source docs/build/html --watch $(GIT_ROOT)/bentoml --ignore "bazel-*"
spellcheck-docs: ## Spell check documentation
sphinx-build -b spelling ./docs/source ./docs/build || (echo "Error running spellchecker.. You may need to run 'make install-spellchecker-deps'"; exit 1)
OS := $(shell uname)
ifeq ($(OS),Darwin)
install-spellchecker-deps: ## Install MacOS dependencies for spellchecker
brew install enchant
pip install sphinxcontrib-spelling
else ifneq ("$(wildcard $(/etc/debian_version))","")
install-spellchecker-deps: ## Install Debian-based dependencies for spellchecker
sudo apt install libenchant-dev
else
install-spellchecker-deps: ## Inform users to install enchant depending on their distros
@echo Make sure to install enchant from your distros package manager
@exit 1
endif