|
| 1 | +PYTHON := python |
| 2 | +PIP := $(PYTHON) -m pip |
| 3 | +GRPC_TOOLS_VERSION := 1.62.1 |
| 4 | + |
| 5 | +all: update-and-install-deps generate-protos format check |
| 6 | + |
| 7 | +# Dependency management targets |
| 8 | +update-and-install-deps: update-deps install-deps |
| 9 | + |
| 10 | +update-deps: |
| 11 | + $(PIP) install pip-tools |
| 12 | + $(PYTHON) -m piptools compile requirements.in |
| 13 | + |
| 14 | +install-deps: |
| 15 | + $(PIP) install pytype pylint pyink -r requirements.txt -r benchmarks/requirements.in |
| 16 | + |
| 17 | +# Code generation/formatting targets |
| 18 | +generate-protos: generate-and-prepend-preambles format |
| 19 | + |
| 20 | +generate-and-prepend-preambles: |
| 21 | + $(PIP) install grpcio-tools==$(GRPC_TOOLS_VERSION) |
| 22 | + for id in $$(find . -name "*.proto"); do \ |
| 23 | + $(PYTHON) -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. $$id && \ |
| 24 | + PROTO_FILE=$$(echo $$id | awk '{print substr($$0, 1, length($$0)-6)}') && \ |
| 25 | + PB_GRPC_PY=$(addsuffix "_pb2_grpc.py",$$PROTO_FILE) && \ |
| 26 | + PB_PY=$(addsuffix "_pb2.py",$$PROTO_FILE) && \ |
| 27 | + cat license_preamble.txt $$PB_GRPC_PY >> $(addsuffix "_temp",$$PB_GRPC_PY) && \ |
| 28 | + mv $(addsuffix "_temp",$$PB_GRPC_PY) $$PB_GRPC_PY; \ |
| 29 | + cat license_preamble.txt $$PB_PY >> $(addsuffix "_temp",$$PB_PY) && \ |
| 30 | + mv $(addsuffix "_temp",$$PB_PY) $$PB_PY; \ |
| 31 | + done |
| 32 | + |
| 33 | +format: |
| 34 | + $(PIP) install pyink |
| 35 | + pyink --pyink-indentation 2 --line-length 80 --verbose . |
| 36 | + |
| 37 | +# Code checking related targets |
| 38 | +check: type-check format-check linter-check |
| 39 | + |
| 40 | +type-check: |
| 41 | + $(PIP) install pytype |
| 42 | + pytype --jobs auto --disable=import-error,module-attr jetstream/ benchmarks/ |
| 43 | + |
| 44 | +format-check: |
| 45 | + $(PIP) install pyink |
| 46 | + pyink --pyink-indentation 2 --line-length 80 --check --verbose . |
| 47 | + |
| 48 | +linter-check: |
| 49 | + $(PIP) install pylint |
| 50 | + pylint --ignore-patterns=".*_pb2.py,.*_pb2_grpc.py" jetstream/ benchmarks/ |
| 51 | + |
| 52 | + |
| 53 | +# Testing related targets |
| 54 | +tests: unit-tests check-test-coverage |
| 55 | + |
| 56 | +unit-tests: |
| 57 | + coverage run -m unittest -v |
| 58 | + |
| 59 | +check-test-coverage: |
| 60 | + coverage report -m --omit="jetstream/core/proto/*,jetstream/engine/tokenizer_pb2.py,jetstream/third_party/*" --fail-under=96 |
0 commit comments