forked from labfunctions/labfunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (142 loc) · 4.94 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
define USAGE
Super awesome hand-crafted build system ⚙️
Commands:
setup Install dependencies, dev included
lock Generate requirements.txt
test Run tests
lint Run linting tests
run Run docker image with --rm flag but mounted dirs.
release Publish docker image based on some variables
docker Build the docker image
tag Make a git tab using poetry information
endef
export USAGE
.EXPORT_ALL_VARIABLES:
GIT_TAG := $(shell git describe --tags)
CUDA=11.5
# from poetry pyproject.toml
LF_VERSION :=$(shell python3 scripts/get_version.py)
FULLPY_PKG := $(shell python3 scripts/get_package_name.py)
API_VERSION := "v1"
BUILD := $(shell git rev-parse --short HEAD)
PROJECTNAME := $(shell basename "$(PWD)")
PACKAGE_DIR = $(shell basename "$(PWD)")
DOCKERID = $(shell echo "nuxion")
# REGISTRY := registry.nyc1.algorinfo
# RANDOM := $(shell echo $RANDOM | md5sum | head -c 20; echo;)
help:
@echo "$$USAGE"
.PHONY: startenv
startenv:
poetry shell
docker-compose start
alembic upgrade head
clean:
find . ! -path "./.eggs/*" -name "*.pyc" -exec rm {} \;
find . ! -path "./.eggs/*" -name "*.pyo" -exec rm {} \;
find . ! -path "./.eggs/*" -name ".coverage" -exec rm {} \;
rm -rf build/* > /dev/null 2>&1
rm -rf dist/* > /dev/null 2>&1
rm -rf .ipynb_checkpoints/* > /dev/null 2>&1
rm -rf docker/client/dist
rm -rf docker/all/dist
lock-dev:
poetry export -f requirements.txt --output requirements/requirements_dev.txt --extras server --without-hashes --dev
lock-all:
poetry export -f requirements.txt --output requirements/requirements_all.txt --without-hashes --extras server --extras cloud --extras stores
lock-client:
poetry export -f requirements.txt --output requirements/requirements_client.txt --without-hashes --extras stores
cp requirements/requirements_client.txt labfunctions/conf/templates/requirements_client.txt
lock: lock-all lock-client lock-dev
build: lock
poetry build
echo ${PWD}
tar xvfz dist/${FULLPY_PKG}.tar.gz -C dist/
cp dist/${FULLPY_PKG}/setup.py .
preversion:
poetry version prerelease
./scripts/update_versions.sh ${API_VERSION}
.PHONY: generate-docker
generate-docker:
lab runtimes generate official-all
mv Dockerfile.official-all docker/Dockerfile.all
lab runtimes generate official-client
mv Dockerfile.official-client docker/Dockerfile.client
lab runtimes generate official-gpu
mv Dockerfile.official-gpu docker/Dockerfile.client.gpu
python3 scripts/docker_compose.py 127.0.0.1
cp docker/docker-compose.yaml docker-compose.yaml
minor:
poetry version minor
./scripts/update_versions.sh ${API_VERSION}
black:
black --config ./.black.toml labfunctions tests
isort:
isort labfunctions tests --profile=black
lint: black isort
.PHONY: test
test:
PYTHONPATH=$(PWD) pytest --cov-report xml --cov=labfunctions tests/
.PHONY: test-html
test-html:
PYTHONPATH=$(PWD) pytest --cov-report=html --cov=labfunctions tests/
.PHONY: e2e
e2e:
pytest -s -k test_ e2e/
.PHONY: install
install:
poetry install --dev
.PHONY: web
web:
lab web --apps workflows,history,projects,runtimes -A --workers 1 -L
.PHONY: agent
agent:
lab agent run --qnames cpu,gpu,build,control -m local/ba/asd
.PHONY: docker-client
docker-client:
docker build -t ${DOCKERID}/${PROJECTNAME}:latest-client -f docker/Dockerfile.client .
docker tag ${DOCKERID}/${PROJECTNAME}:latest-client ${DOCKERID}/${PROJECTNAME}:${LF_VERSION}-client
.PHONY: docker-client-push
docker-client-push:
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)-client
.PHONY: docker-client-gpu
docker-client-gpu:
docker build -t ${DOCKERID}/${PROJECTNAME}:latest-client-cuda${CUDA} -f docker/Dockerfile.client.gpu .
docker tag ${DOCKERID}/${PROJECTNAME}:latest-client-cuda${CUDA} ${DOCKERID}/${PROJECTNAME}:${LF_VERSION}-client-cuda${CUDA}
.PHONY: docker-client-push
docker-client-gpu-push:
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)-client-cuda${CUDA}
.PHONY: docker-all
docker-all:
docker build -t ${DOCKERID}/${PROJECTNAME} -f docker/Dockerfile.all .
docker tag ${DOCKERID}/${PROJECTNAME}:latest ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)
.PHONY: docker-dev
docker-dev:
docker build -t nuxion/labdev -f Dockerfile.3.8-slim .
.PHONY: docker-all-push
docker-all-push:
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)
.PHONY: docker
docker: docker-client docker-client-gpu docker-all
.PHONY: docker-release
docker-release: docker
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)-client
docker push ${DOCKERID}/${PROJECTNAME}:$(LF_VERSION)-client-gpu
.PHONY: publish
publish:
poetry publish
.PHONY: publish-test
publish-test:
poetry publish --build -r test
.PHONY: redis-cli
redis-cli:
docker-compose exec redis redis-cli
.PHONY: docs-server
docs-serve:
sphinx-autobuild docs docs/_build/html --port 9292 --watch ./
.PHONY: tag
tag:
# https://git-scm.com/docs/pretty-formats/2.20.0
#poetry version prealese
git tag -a $(shell poetry version --short) -m "$(shell git log -1 --pretty=%s | head -n 1)"