-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (55 loc) · 1.4 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
LINT_DIRS = mymodel flask_augmentations
FLASK_APP ?= flask_augmentations.app:app
COMMIT ?=
IMAGE_REMOTE_PREFIX ?= artemlops
IMAGE_NAME ?= flask_augmentations
IMAGE_TAG ?= $(COMMIT)
IMAGE_LOCAL_FULL = $(IMAGE_NAME):$(IMAGE_TAG)
IMAGE_REMOTE_FULL = $(IMAGE_REMOTE_PREFIX)/$(IMAGE_LOCAL_FULL)
setup:
python -m pip install -U pip setuptools wheel
python -m pip install -r requirements-dev.txt
format:
black $(LINT_DIRS)
isort $(LINT_DIRS)
lint:
flake8 $(LINT_DIRS)
isort -c $(LINT_DIRS)
mypy $(LINT_DIRS)
serve:
FLASK_APP=$(FLASK_APP) flask run -p 8080
test: test_model test_flask
@echo "OK"
test_model:
python -m pytest mymodel
test_flask:
python -m pytest flask_augmentations
docker_build:
docker build -f Dockerfile -t $(IMAGE_LOCAL_FULL) .
docker_push:
docker tag $(IMAGE_LOCAL_FULL) $(IMAGE_REMOTE_FULL)
docker push $(IMAGE_REMOTE_FULL)
docker_serve: require.COMMIT
docker run --rm -d --name flask_augmentations -p 8080:8080 $(IMAGE_REMOTE_FULL)
docker_kill:
docker kill flask_augmentations
.PHONY: \
setup \
serve \
test \
test_model \
test_flask \
docker_build \
docker_push \
docker_serve
# utils
##
# This target prints provided variable value,
# for example: 'make print.IMAGE_NAME'
.SILENT: print.%
print.%:
@echo $($*)
# This target allows us to explicitly require some env var to be set.
.SILENT: require.%
require.%:
$(if $(value $(*)),,$(error Missing required argument $(*)))