Skip to content

Commit c277cbf

Browse files
authored
pull dev_packages task commands into separate tasks (#39)
* pull dev_packages cp into separate tasks * unrelated fix * check env var before wrapping git commands * also capture gpu_dev_packages * update to match non-GPU builds
1 parent 2172b33 commit c277cbf

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ requirements.R
2020
run.sh
2121

2222
# Ignore these even at the parent-level directories; only to be used as placeholders for local development
23-
dev_packages
23+
**/*dev_packages
2424

2525
# ...except for these places where we care about changes happening
2626
# (NOTE: this is because the tasks should copy the files down into the build directories)

Taskfile.python.yaml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,19 @@ tasks:
131131
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
132132
cmds:
133133
# ensure the datascience image is built first
134-
- task python:datascience:build IDENTIFIER=noteable-gpu NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
134+
- task python:datascience:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
135135
# copy over noteable-specific files
136136
- task python:noteable:copy-files IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
137-
# copy dev_packages for local builds, even if we aren't using the dev stage
138-
- sudo cp -R python/noteable/dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
139137
# build the noteable image off of the datascience image
140138
- 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
141139

140+
noteable:build-with-dev-packages:
141+
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
142+
cmds:
143+
# copy dev_packages in and then build with BUILD_TARGET specified
144+
- sudo cp -R python/noteable/dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
145+
- task python:noteable:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} BUILD_TARGET=dev
146+
142147
# Noteable GPU image
143148
noteable-gpu:lock-dependencies:
144149
desc: Lock Python dependencies for Noteable builds using pip-compile
@@ -152,11 +157,16 @@ tasks:
152157
- task python:datascience-gpu:build IDENTIFIER=noteable-gpu NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}}
153158
# copy over noteable-specific files
154159
- task python:noteable:copy-files IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} FILE_PREFIX="gpu."
155-
# copy dev_packages for local builds, even if we aren't using the dev stage
156-
- sudo cp -R python/noteable/gpu_dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
157160
# build the noteable-gpu image off of the datascience-gpu image
158161
- 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
159162

163+
noteable-gpu:build-with-dev-packages:
164+
desc: LOCAL DEV - Build the Python 3.x image with "Noteable feature"-related packages (SQL, git integration, DEX, etc), GPU support, and dev_packages
165+
cmds:
166+
# copy dev_packages in and then build with BUILD_TARGET specified
167+
- sudo cp -R python/noteable/gpu_dev_packages python/noteable/{{.NBL_PYTHON_VERSION}}/
168+
- task python:noteable-gpu:build IDENTIFIER=noteable NBL_PYTHON_VERSION={{.NBL_PYTHON_VERSION}} BUILD_TARGET=gpu-dev
169+
160170
# convenience functions for building multiple images in parallel
161171
base:lock-all-dependencies:
162172
desc: Lock Python dependencies for all Python 3.x builds using pip-compile
@@ -259,14 +269,12 @@ tasks:
259269
noteable:build-all-with-dev-packages:
260270
desc: LOCAL DEV - Build all `noteable` images with `dev_packages` included
261271
deps:
262-
- task: noteable:build
272+
- task: noteable:build-with-dev-packages
263273
vars:
264274
NBL_PYTHON_VERSION: 3.9
265-
BUILD_TARGET: dev
266-
- task: noteable:build
275+
- task: noteable:build-with-dev-packages
267276
vars:
268277
NBL_PYTHON_VERSION: 3.10
269-
BUILD_TARGET: dev
270278

271279
noteable-gpu:lock-all-dependencies:
272280
desc: Lock Python dependencies for all Python 3.x GPU builds using pip-compile
@@ -280,21 +288,21 @@ tasks:
280288
desc: Build all Python noteable-gpu images
281289
deps:
282290
- task: noteable-gpu:build
283-
vars: { NBL_PYTHON_VERSION: 3.9 }
291+
vars:
292+
NBL_PYTHON_VERSION: 3.9
284293
- task: noteable-gpu:build
285-
vars: { NBL_PYTHON_VERSION: 3.10 }
294+
vars:
295+
NBL_PYTHON_VERSION: 3.10
286296

287297
noteable-gpu:build-all-with-dev-packages:
288298
desc: LOCAL DEV - Build all `noteable` images with `gpu_dev_packages` included
289299
deps:
290-
- task: noteable-gpu:build
300+
- task: noteable-gpu:build-with-dev-packages
291301
vars:
292302
NBL_PYTHON_VERSION: 3.9
293-
BUILD_TARGET: gpu-dev
294-
- task: noteable-gpu:build
303+
- task: noteable-gpu:build-with-dev-packages
295304
vars:
296305
NBL_PYTHON_VERSION: 3.10
297-
BUILD_TARGET: gpu-dev
298306

299307
# convenience functions for building all images
300308
lock-all-dependencies:

python/base-gpu/3.10/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:1.5
22
# hadolint ignore=DL3006
3-
FROM base
3+
FROM base AS main
44

55
ARG NBL_PYTHON_VERSION=3.10
66

python/base-gpu/3.11/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:1.5
22
# hadolint ignore=DL3006
3-
FROM base
3+
FROM base AS main
44

55
ARG NBL_PYTHON_VERSION=3.11
66

python/base-gpu/3.9/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:1.5
22
# hadolint ignore=DL3006
3-
FROM base
3+
FROM base AS main
44

55
ARG NBL_PYTHON_VERSION=3.9
66

python/noteable/git-wrapper.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
# Allowed command list
66
allowed_commands=( "commit" "pull" "push" "status" "diff" "add" "fetch" "log" "version" )
77

8-
# Check if the command is allowed
9-
# shellcheck disable=SC2076
10-
if [[ ! " ${allowed_commands[*]} " =~ " ${1} " ]]; then
11-
echo "That git command is not allowed, contact [email protected] if you think this is a mistake."
12-
exit 1
8+
# If the NTBL_IS_GIT_BACKED env var is "true" then we check to see if the command is allowed.
9+
# If the env var is not set or is not "true" then we just pass through to git.
10+
if [[ "${NTBL_IS_GIT_BACKED}" == "true" ]]; then
11+
# Check if the command is allowed
12+
# shellcheck disable=SC2076
13+
if [[ ! " ${allowed_commands[*]} " =~ " ${1} " ]]; then
14+
echo "That git command is not allowed, contact [email protected] if you think this is a mistake."
15+
exit 1
16+
fi
1317
fi
1418

1519
# Otherwise pass through to git at /usr/bin/git

0 commit comments

Comments
 (0)