-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
117 lines (92 loc) · 2.67 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
105
106
107
108
109
110
111
112
113
114
115
116
117
DOCKER_IMAGE?=sbert-service
LICENSE=LICENSE
LICENSE_HEADER=LICENSE_HEADER
VENV=.venv
$(VENV):
$(MAKE) install
.PHONY: install
install: poetry-ensure-installed
poetry config --local virtualenvs.in-project true
poetry env use python3.10
poetry install
.PHONY docker-build:
docker-build: sentence-transformers transformer.pkl word2vec.bin
# squash reduces final image size by merging layers `--squash`
# but its not supported in github actions
docker build -t $(DOCKER_IMAGE) .
shared/installed:
mkdir -p shared/installed
sentence-transformers: shared/installed
# cd shared && python sentence_transformer_download.py
cd shared && ./transformer_download.sh
transformer.pkl: $(VENV) shared/installed sentence-transformers
poetry run python ./server/transformer/embeddings.py ./shared/installed
word2vec.bin: shared/installed
cd shared && poetry run python word2vec_download.py
cd shared && poetry run python word2vec_slim_download.py
build/deploy:
# put everything we want in our beanstalk deploy.zip file
# into a build/deploy folder.
mkdir -p build/deploy
cp -r ebs/bundle build/deploy/bundle
deploy.zip:
$(MAKE) clean-deploy build/deploy
cd build/deploy/bundle && zip -r $(PWD)/deploy.zip .
clean-deploy:
rm -rf build deploy.zip
.PHONY clean:
clean:
rm -rf .venv htmlcov .coverage build deploy.zip
.PHONY: deps-show
deps-show:
poetry show
.PHONY: deps-show
deps-show-outdated:
poetry show --outdated
.PHONY: deps-update
deps-update:
poetry update
LICENSE:
@echo "you must have a LICENSE file" 1>&2
exit 1
LICENSE_HEADER:
@echo "you must have a LICENSE_HEADER file" 1>&2
exit 1
.PHONY: license
license: LICENSE LICENSE_HEADER $(VENV)
poetry run python -m licenseheaders -t LICENSE_HEADER -d server $(args)
poetry run python -m licenseheaders -t LICENSE_HEADER -d tests $(args)
poetry run python -m licenseheaders -t LICENSE_HEADER -d tools $(args)
.PHONY: poetry-ensure-installed
poetry-ensure-installed:
./tools/poetry_ensure_installed.sh
.PHONY: test
test: $(VENV) install poetry-ensure-installed sentence-transformers transformer.pkl word2vec.bin
cd ./shared/ && $(MAKE) installed/sentence-transformer
SHARED_ROOT=./shared/installed poetry run python -m pytest -vv
.PHONY: black
black: $(VENV)
poetry run black .
.PHONY: format
format:
$(MAKE) license
$(MAKE) black
.PHONY: test-all
test-all:
$(MAKE) test-license
$(MAKE) test-format
$(MAKE) test-lint
$(MAKE) test-types
$(MAKE) test
.PHONY: test-format
test-format: $(VENV)
poetry run black --check .
.PHONY: test-lint
test-lint: $(VENV)
poetry run flake8 .
.PHONY: test-license
test-license: LICENSE LICENSE_HEADER
args="--check" $(MAKE) license
.PHONY: test-types
test-types: $(VENV)
poetry run mypy server