-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
115 lines (94 loc) · 5.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
NAME := numerai_predict
ECR_REPO := ${ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com
GIT_REF := $$(git rev-parse --short HEAD)
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: lint
lint: ## Run linter
ruff check . --fix
.PHONY: build
build: build_3_9 build_3_10 build_3_11 ## Build all Python containers
.PHONY: build_3_9
build_3_9: ## Build Python 3.9 container
docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_py_3_9:${GIT_REF} -t ${NAME}_py_3_9:latest -f py3.9/Dockerfile .
.PHONY: build_3_10
build_3_10: ## Build Python 3.10 container
docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_py_3_10:${GIT_REF} -t ${NAME}_py_3_10:latest -f py3.10/Dockerfile .
.PHONY: build_3_11
build_3_11: ## Build Python 3.11 container
docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_py_3_11:${GIT_REF} -t ${NAME}_py_3_11:latest -f py3.11/Dockerfile .
.PHONY: build_shell
build_shell: ## Build Python 3.11 container
docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_shell:${GIT_REF} -t ${NAME}_shell:latest -f shell/Dockerfile .
.PHONY: test
test: test_predict test_3_9 test_3_10 test_3_11 ## Test all container versions
.PHONY: test_predict
test_predict: build_shell ## Test predict script
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_shell:latest python -m unittest tests.test_predict
.PHONY: test_3_9
test_3_9: build_3_9 ## Test Python 3.9 pickle
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_9:latest --model /tests/models/model_3_9_legacy.pkl
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_9:latest --model /tests/models/model_3_9.pkl
.PHONY: test_3_10
test_3_10: build_3_10 ## Test Python 3.10 pickle
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_10:latest --model /tests/models/model_3_10_legacy.pkl
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_10:latest --model /tests/models/model_3_10.pkl
.PHONY: test_3_11
test_3_11: build_3_11 ## Test Python 3.11 pickle
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_11:latest --model /tests/models/model_3_11_legacy.pkl
docker run -i --rm -v ./tests/:/tests/ -v /tmp:/tmp ${NAME}_py_3_11:latest --model /tests/models/model_3_11.pkl
.PHONY: push_latest
push_latest: push_latest_3_9 push_latest_3_10 push_latest_3_11 ## Push latest docker containers
.PHONY: push_latest_3_9
push_latest_3_9: build_3_9 ## Push Python 3.9 contianer tagged latest
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_9:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_9:${GIT_REF}
docker tag ${NAME}_py_3_9:latest ${ECR_REPO}/${NAME}_py_3_9:latest
docker push ${ECR_REPO}/${NAME}_py_3_9:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_9:latest
.PHONY: push_latest_3_10
push_latest_3_10: build_3_10 ## Release Python 3.10 contianer tagged latest
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_10:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_10:${GIT_REF}
docker tag ${NAME}_py_3_10:latest ${ECR_REPO}/${NAME}_py_3_10:latest
docker push ${ECR_REPO}/${NAME}_py_3_10:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_10:latest
.PHONY: push_latest_3_11
push_latest_3_11: build_3_11## Release Python 3.11 contianer tagged latest
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_11:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_11:${GIT_REF}
docker tag ${NAME}_py_3_11:latest ${ECR_REPO}/${NAME}_py_3_11:latest
docker push ${ECR_REPO}/${NAME}_py_3_11:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_11:latest
.PHONY: push_latest_shell
push_latest_shell: build_shell## Release Python 3.11 contianer tagged latest
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_shell:${GIT_REF} ${ECR_REPO}/${NAME}_shell:${GIT_REF}
docker tag ${NAME}_shell:latest ${ECR_REPO}/${NAME}_shell:latest
docker push ${ECR_REPO}/${NAME}_shell:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_shell:latest
.PHONY: push_stable
push_stable: push_stable_3_9 push_stable_3_10 push_stable_3_11 ## Push all container tagged stable
.PHONY: push_stable_3_9
push_stable_3_9: build_3_9 ## Release Python 3.9 contianer tagged stable
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_9:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_9:${GIT_REF}
docker tag ${NAME}_py_3_9:latest ${ECR_REPO}/${NAME}_py_3_9:stable
docker push ${ECR_REPO}/${NAME}_py_3_9:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_9:stable
.PHONY: push_stable_3_10
push_stable_3_10: build_3_10 ## Release Python 3.10 contianer tagged stable
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_10:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_10:${GIT_REF}
docker tag ${NAME}_py_3_10:latest ${ECR_REPO}/${NAME}_py_3_10:stable
docker push ${ECR_REPO}/${NAME}_py_3_10:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_10:stable
.PHONY: push_stable_3_11
push_stable_3_11: build_3_11## Release Python 3.11 contianer tagged stable
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
docker tag ${NAME}_py_3_11:${GIT_REF} ${ECR_REPO}/${NAME}_py_3_11:${GIT_REF}
docker tag ${NAME}_py_3_11:latest ${ECR_REPO}/${NAME}_py_3_11:stable
docker push ${ECR_REPO}/${NAME}_py_3_11:${GIT_REF}
docker push ${ECR_REPO}/${NAME}_py_3_11:stable