-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTaskfile.python.yaml
326 lines (288 loc) · 14.9 KB
/
Taskfile.python.yaml
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
version: 3
# https://hub.docker.com/_/python/tags?page=1&name=slim-bullseye
vars:
NBL_PYTHON_VERSION: 3.9
IDENTIFIER: base
BUILD_TARGET: main
# NOTE: When using `deps: []`, variables are inherited from the current task, but when calling them
# directly in `cmds: []`, the variables have to be passed in explicitly.
tasks:
base:copy-files:
desc: Copy files from the Python directory to the build directories
cmds:
- task copy-root-files LANGUAGE=python IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}}
- task copy-language-files LANGUAGE=python IDENTIFIER={{.IDENTIFIER}} NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}}
- cp python/base-gpu/environment.txt python/base-gpu/{{.NBL_PYTHON_VERSION}}/environment.txt
- cp python/base-gpu/gpu.Aptfile python/base-gpu/{{.NBL_PYTHON_VERSION}}/gpu.Aptfile
- cp python/base-gpu/run.sh python/base-gpu/{{.NBL_PYTHON_VERSION}}/run.sh
- cp python/base-gpu/initial-condarc python/base-gpu/{{.NBL_PYTHON_VERSION}}/initial-condarc
base:pyenv:install:
desc: Install the specified version of Python using pyenv
cmds:
- pyenv install -s {{.NBL_PYTHON_VERSION}}
base:pyenv:virtualenv:
desc: Create a new virtual environment using pyenv
deps: [base:pyenv:install]
cmds:
- pyenv virtualenv {{.NBL_PYTHON_VERSION}} py{{.NBL_PYTHON_VERSION}} || true
base:deps:install-pip-tools:
desc: Install Python dependencies
deps: [base:pyenv:virtualenv]
cmds:
- $(pyenv root)/versions/py{{.NBL_PYTHON_VERSION}}/bin/python -m pip install pip-tools==6.13.0
base:deps:copy-requirements:
desc: Copy identifier-level *requirements.in files to the version-level build directories
cmds:
- mkdir -p python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}
- cp python/{{.IDENTIFIER}}/{{.FILE_PREFIX}}requirements.in python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}/{{.FILE_PREFIX}}requirements.in
generates:
- python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}/{{.FILE_PREFIX}}requirements.in
# Base image
base:lock-dependencies:
desc: Uses piptools compile to lock Python dependency versions for a specific build identifier, version, and file prefix (e.g. "gpu.")
deps: [base:deps:install-pip-tools]
cmds:
- task python:base:deps:copy-requirements FILE_PREFIX={{.FILE_PREFIX}} IDENTIFIER={{.IDENTIFIER}} NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# specifically looks at the python/<ident>/<version>/<version>.requirements.in file, not the generic requirements.in files
- $(pyenv root)/versions/py{{.NBL_PYTHON_VERSION}}/bin/python -m piptools compile --output-file python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}/{{.FILE_PREFIX}}requirements.txt python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}/{{.NBL_PYTHON_VERSION}}.{{.FILE_PREFIX}}requirements.in
generates:
- python/{{.IDENTIFIER}}/{{.NBL_PYTHON_VERSION}}/{{.FILE_PREFIX}}requirements.txt
base:build:
desc: Build the Python 3.x base image after copying required files
cmds:
- task python:base:copy-files IDENTIFIER=base NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=base BUILD_TARGET=base
# Base GPU image
base-gpu:lock-dependencies:
desc: Lock Python dependencies for GPU builds using pip-compile
deps: [base:lock-dependencies]
cmds:
- task python:base:lock-dependencies IDENTIFIER=base-gpu NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
base-gpu:build:
desc: Build the Python 3.x image with GPU support after copying required files
cmds:
# ensure the base image is built first
- task python:base:build IDENTIFIER=datascience NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# copy base-gpu specific files
- task python:base:copy-files IDENTIFIER=base-gpu NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
- cp python/base-gpu/environment.txt python/base-gpu/{{.NBL_PYTHON_VERSION}}/environment.txt
- cp python/base-gpu/gpu.Aptfile python/base-gpu/{{.NBL_PYTHON_VERSION}}/gpu.Aptfile
- cp python/base-gpu/run.sh python/base-gpu/{{.NBL_PYTHON_VERSION}}/run.sh
- cp python/base-gpu/initial-condarc python/base-gpu/{{.NBL_PYTHON_VERSION}}/initial-condarc
# build the base-gpu image off of the base image
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=base-gpu BUILD_TARGET=main -- --build-context base=docker-image://local/kernel-python-{{.NBL_PYTHON_VERSION}}-base:dev
# Datascience image
datascience:lock-dependencies:
desc: Lock Python dependencies for datascience builds using pip-compile
cmds:
- task python:base:lock-dependencies IDENTIFIER=datascience NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
datascience:build:
desc: Build the Python 3.x image with datascience packages extending the base image of the same version
cmds:
# ensure the base image is built first
- task python:base:build IDENTIFIER=datascience NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# build the datascience image off of the base image
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=datascience BUILD_TARGET=main -- --build-context base=docker-image://local/kernel-python-{{.NBL_PYTHON_VERSION}}-base:dev
# Datascience GPU image
datascience-gpu:lock-dependencies:
desc: Lock Python dependencies for datascience builds using pip-compile
cmds:
- task python:base:lock-dependencies IDENTIFIER=datascience NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} FILE_PREFIX="gpu."
datascience-gpu:build:
desc: Build the Python 3.x image with datascience packages and GPU support
cmds:
# ensure the base-gpu image is built first
- task python:base-gpu:build IDENTIFIER=datascience NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# build the datascience-gpu image off of the base-gpu image
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=datascience BUILD_TARGET=gpu TAG_SUFFIX=-gpu -- --build-context base=docker-image://local/kernel-python-{{.NBL_PYTHON_VERSION}}-base-gpu:dev
# Noteable image
noteable:copy-files:
desc: Copy files from the `python/noteable` directory to the build directories
deps: [base:deps:copy-requirements]
cmds:
- cp python/noteable/Aptfile python/noteable/{{.NBL_PYTHON_VERSION}}/Aptfile
- cp python/noteable/git_credential_helper.py python/noteable/{{.NBL_PYTHON_VERSION}}/git_credential_helper.py
- cp python/noteable/git-wrapper.sh python/noteable/{{.NBL_PYTHON_VERSION}}/git-wrapper.sh
- cp python/noteable/ipython_config.py python/noteable/{{.NBL_PYTHON_VERSION}}/ipython_config.py
- cp python/noteable/.pythonrc python/noteable/{{.NBL_PYTHON_VERSION}}/.pythonrc
noteable:lock-dependencies:
desc: Lock Python dependencies for Noteable builds using pip-compile
cmds:
- task python:base:lock-dependencies IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
noteable:build:
desc: Build the Python 3.x image with "Noteable feature"-related packages (SQL, git integration, DEX, etc) extending the datascience image of the same version
cmds:
# ensure the datascience image is built first
- task python:datascience:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# copy over noteable-specific files
- task python:noteable:copy-files IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# build the noteable image off of the datascience image
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=noteable BUILD_TARGET={{.BUILD_TARGET}} -- --build-context base=docker-image://local/kernel-python-{{.NBL_PYTHON_VERSION}}-datascience:dev
noteable:build-with-dev-packages:
desc: LOCAL DEV - Build the Python 3.x image with "Noteable feature"-related packages (SQL, git integration, DEX, etc) and dev_packages extending the datascience image of the same version
cmds:
# copy dev_packages in and then build with BUILD_TARGET specified
- sudo cp -R python/noteable/dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
- task python:noteable:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} BUILD_TARGET=dev
# Noteable GPU image
noteable-gpu:lock-dependencies:
desc: Lock Python dependencies for Noteable builds using pip-compile
cmds:
- task python:base:lock-dependencies IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} FILE_PREFIX="gpu."
noteable-gpu:build:
desc: Build the Python 3.x image with "Noteable feature"-related packages (SQL, git integration, DEX, etc) and GPU support
cmds:
# ensure the datascience-gpu image is built first
- task python:datascience-gpu:build IDENTIFIER=noteable-gpu NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
# copy over noteable-specific files
- task python:noteable:copy-files IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} FILE_PREFIX="gpu."
# build the noteable-gpu image off of the datascience-gpu image
- task build LANGUAGE=python NBL_LANGUAGE_VERSION={{.NBL_PYTHON_VERSION}} IDENTIFIER=noteable BUILD_TARGET={{.BUILD_TARGET}} TAG_SUFFIX=-gpu -- --build-context base=docker-image://local/kernel-python-{{.NBL_PYTHON_VERSION}}-datascience-gpu:dev
noteable-gpu:build-with-dev-packages:
desc: LOCAL DEV - Build the Python 3.x image with "Noteable feature"-related packages (SQL, git integration, DEX, etc), GPU support, and dev_packages
cmds:
# copy dev_packages in and then build with BUILD_TARGET specified
- sudo cp -R python/noteable/gpu_dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
- task python:noteable-gpu:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} BUILD_TARGET=gpu-dev
# convenience functions for building multiple images in parallel
base:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x builds using pip-compile
deps:
- task: base:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: base:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: base:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.11 }
base:build-all:
desc: Build all Python base images
deps:
- task: base:build
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: base:build
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: base:build
vars: { NBL_PYTHON_VERSION: 3.11 }
base-gpu:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x GPU builds using pip-compile
deps:
- task: base-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: base-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: base-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.11 }
base-gpu:build-all:
desc: Build all Python base-gpu images
deps:
- task: base-gpu:build
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: base-gpu:build
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: base-gpu:build
vars: { NBL_PYTHON_VERSION: 3.11 }
# datascience convenience functions
datascience:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x builds using pip-compile
deps:
- task: datascience:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: datascience:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: datascience:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.11 }
datascience:build-all:
desc: Build all Python datascience images
deps:
- task: datascience:build
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: datascience:build
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: datascience:build
vars: { NBL_PYTHON_VERSION: 3.11 }
datascience-gpu:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x GPU builds using pip-compile
deps:
- task: datascience-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: datascience-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: datascience-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.11 }
datascience-gpu:build-all:
desc: Build all Python datascience-gpu images
deps:
- task: datascience-gpu:build
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: datascience-gpu:build
vars: { NBL_PYTHON_VERSION: 3.10 }
- task: datascience-gpu:build
vars: { NBL_PYTHON_VERSION: 3.11 }
# Noteable convenience functions
noteable:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x builds using pip-compile
deps:
- task: noteable:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: noteable:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
noteable:build-all:
desc: Build all Python noteable images
deps:
- task: noteable:build
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: noteable:build
vars: { NBL_PYTHON_VERSION: 3.10 }
noteable:build-all-with-dev-packages:
desc: LOCAL DEV - Build all `noteable` images with `dev_packages` included
deps:
- task: noteable:build-with-dev-packages
vars:
NBL_PYTHON_VERSION: 3.9
- task: noteable:build-with-dev-packages
vars:
NBL_PYTHON_VERSION: 3.10
noteable-gpu:lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x GPU builds using pip-compile
deps:
- task: noteable-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.9 }
- task: noteable-gpu:lock-dependencies
vars: { NBL_PYTHON_VERSION: 3.10 }
noteable-gpu:build-all:
desc: Build all Python noteable-gpu images
deps:
- task: noteable-gpu:build
vars:
NBL_PYTHON_VERSION: 3.9
- task: noteable-gpu:build
vars:
NBL_PYTHON_VERSION: 3.10
noteable-gpu:build-all-with-dev-packages:
desc: LOCAL DEV - Build all `noteable` images with `gpu_dev_packages` included
deps:
- task: noteable-gpu:build-with-dev-packages
vars:
NBL_PYTHON_VERSION: 3.9
- task: noteable-gpu:build-with-dev-packages
vars:
NBL_PYTHON_VERSION: 3.10
# convenience functions for building all images
lock-all-dependencies:
desc: Lock Python dependencies for all Python 3.x builds using pip-compile
deps:
- task: base:lock-all-dependencies
- task: base-gpu:lock-all-dependencies
- task: datascience:lock-all-dependencies
- task: datascience-gpu:lock-all-dependencies
- task: noteable:lock-all-dependencies
- task: noteable-gpu:lock-all-dependencies
build-all:
desc: Build all Python images
deps:
- task: base:build-all
- task: base-gpu:build-all
- task: datascience:build-all
- task: datascience-gpu:build-all
- task: noteable:build-all
- task: noteable-gpu:build-all