-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
54 lines (41 loc) · 1.72 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
PYTHON := python
PIP := $(PYTHON) -m pip
GRPC_TOOLS_VERSION := 1.62.1
all: install-deps generate-protos format check
# Dependency management targets
install-deps:
$(PIP) install pytype pylint pyink -r requirements.txt -r benchmarks/requirements.in
# Code generation/formatting targets
generate-protos: generate-and-prepend-preambles format
generate-and-prepend-preambles:
$(PIP) install grpcio-tools==$(GRPC_TOOLS_VERSION)
for id in $$(find . -name "*.proto"); do \
$(PYTHON) -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. $$id && \
PROTO_FILE=$$(echo $$id | awk '{print substr($$0, 1, length($$0)-6)}') && \
PB_GRPC_PY=$(addsuffix "_pb2_grpc.py",$$PROTO_FILE) && \
PB_PY=$(addsuffix "_pb2.py",$$PROTO_FILE) && \
cat license_preamble.txt $$PB_GRPC_PY >> $(addsuffix "_temp",$$PB_GRPC_PY) && \
mv $(addsuffix "_temp",$$PB_GRPC_PY) $$PB_GRPC_PY; \
cat license_preamble.txt $$PB_PY >> $(addsuffix "_temp",$$PB_PY) && \
mv $(addsuffix "_temp",$$PB_PY) $$PB_PY; \
done
format:
$(PIP) install pyink
pyink --pyink-indentation 2 --line-length 80 --verbose .
# Code checking related targets
check: type-check format-check linter-check
type-check:
$(PIP) install pytype
pytype --jobs auto --disable=import-error,module-attr jetstream/ benchmarks/
format-check:
$(PIP) install pyink
pyink --pyink-indentation 2 --line-length 80 --check --verbose .
linter-check:
$(PIP) install pylint
pylint --ignore-patterns=".*_pb2.py,.*_pb2_grpc.py" jetstream/ benchmarks/
# Testing related targets
tests: unit-tests check-test-coverage
unit-tests:
coverage run -m unittest -v
check-test-coverage:
coverage report -m --omit="jetstream/core/proto/*,jetstream/engine/tokenizer_pb2.py,jetstream/external_tokenizers/*" --fail-under=96