-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathMakefile
More file actions
516 lines (446 loc) · 23 KB
/
Makefile
File metadata and controls
516 lines (446 loc) · 23 KB
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
SELF ::= $(firstword $(MAKEFILE_LIST))
# https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
.SHELLFLAGS := -Eeux -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Used where we need an empty expansion (avoids undefined variable warning).
empty :=
# todo: leave the default recipe prefix for now
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX =
IMAGE_REGISTRY ?= quay.io/opendatahub/workbench-images
RELEASE ?= 2025b
RELEASE_PYTHON_VERSION ?= 3.12
# additional user-specified caching parameters for $(CONTAINER_ENGINE) build
CONTAINER_BUILD_CACHE_ARGS ?= --no-cache
# whether to push the images to a registry as they are built
PUSH_IMAGES ?= yes
# INDEX_MODE: auto (default), public-index, or rh-index - controls lock file generation
INDEX_MODE ?= auto
# KONFLUX: whether to build images from Dockerfile.konflux.* (default: no)
KONFLUX ?= no
# OS dependant: Generate date, select appropriate cmd to locate container engine
ifdef OS
ifeq ($(OS), Windows_NT)
DATE ?= $(shell powershell -Command "Get-Date -Format 'yyyyMMdd'")
WHERE_WHICH ?= where
endif
endif
DATE ?= $(shell date +'%Y%m%d')
WHERE_WHICH ?= which
# linux/amd64 or darwin/arm64
OS_ARCH=$(shell go env GOOS)/$(shell go env GOARCH)
BUILD_ARCH ?= linux/amd64
IMAGE_TAG ?= $(RELEASE)_$(DATE)
KUBECTL_BIN ?= bin/kubectl
KUBECTL_VERSION ?= v1.23.11
YQ_BIN ?= bin/yq
YQ_VERSION ?= v4.44.6
NOTEBOOK_REPO_BRANCH_BASE ?= https://raw.githubusercontent.com/opendatahub-io/notebooks/main
REQUIRED_RUNTIME_IMAGE_COMMANDS="curl python3"
REQUIRED_CODE_SERVER_IMAGE_COMMANDS="curl python oc code-server"
REQUIRED_R_STUDIO_IMAGE_COMMANDS="curl python oc /usr/lib/rstudio-server/bin/rserver"
# Detect and select the system's available container engine
ifeq (, $(shell $(WHERE_WHICH) podman))
DOCKER := $(shell $(WHERE_WHICH) docker)
ifeq (, $(DOCKER))
$(error "Neither Docker nor Podman is installed. Please install one of them.")
endif
CONTAINER_ENGINE := docker
else
CONTAINER_ENGINE := podman
endif
# Build function for the notebook image:
# ARG 1: Image tag name.
# ARG 2: Path of Dockerfile we want to build.
# ARG 3: Path of the build-args conf file to use.
define build_image
$(eval IMAGE_NAME := $(IMAGE_REGISTRY):$(1)-$(IMAGE_TAG))
# Checks if there’s a build-args/*.conf matching the Dockerfile
$(eval BUILD_DIR := $(dir $(2)))
$(eval DOCKERFILE_NAME := $(notdir $(2)))
$(eval CONF_FILE := $(3))
# if the conf file exists, transform it into --build-arg KEY=VALUE flags
$(eval BUILD_ARGS := $(shell \
if [ -f $(CONF_FILE) ]; then \
awk -F= '!/^#/ && NF {gsub(/^[ \t]+|[ \t]+$$/, "", $$1); gsub(/^[ \t]+|[ \t]+$$/, "", $$2); printf "--build-arg %s=%s ", $$1, $$2}' $(CONF_FILE); \
fi))
# Make is only used for local and GHA builds (Konflux does not run make).
# Default to local build for hermetic-capable targets: always set LOCAL_BUILD=true
# when prefetch-input/ exists; mount cachi2/output only when it exists (after prefetch).
$(eval LOCAL_BUILD_ARG := $(if $(wildcard $(BUILD_DIR)prefetch-input),--build-arg LOCAL_BUILD=true,))
$(eval CACHI2_VOLUME := $(if $(and $(wildcard cachi2/output),$(wildcard $(BUILD_DIR)prefetch-input)),--volume $(ROOT_DIR)cachi2/output:/cachi2/output:Z,))
$(info # Building $(IMAGE_NAME) using $(DOCKERFILE_NAME) with $(CONF_FILE) and $(BUILD_ARGS)...)
@if [ -d '$(BUILD_DIR)prefetch-input' ] && [ ! -d cachi2/output ]; then \
echo "Prefetch required for hermetic build. Run: scripts/lockfile-generators/prefetch-all.sh --component-dir $(patsubst %/,%,$(BUILD_DIR)) -- see scripts/lockfile-generators/README.md"; \
exit 1; \
fi
$(ROOT_DIR)/scripts/sandbox.py --dockerfile '$(2)' --platform '$(BUILD_ARCH)' -- \
$(CONTAINER_ENGINE) build $(CONTAINER_BUILD_CACHE_ARGS) $(LOCAL_BUILD_ARG) $(CACHI2_VOLUME) --platform=$(BUILD_ARCH) --label release=$(RELEASE) --tag $(IMAGE_NAME) --file '$(2)' $(BUILD_ARGS) {}\;
endef
# Push function for the notebook image:
# ARG 1: Path of image context we want to build.
define push_image
$(eval IMAGE_NAME := $(IMAGE_REGISTRY):$(subst /,-,$(1))-$(IMAGE_TAG))
$(info # Pushing $(IMAGE_NAME) image...)
$(CONTAINER_ENGINE) push $(IMAGE_NAME)
endef
# Build and push the notebook images:
# ARG 1: Image tag name.
# ARG 2: Path of Dockerfile we want to build.
#
# PUSH_IMAGES: allows skipping podman push
define image
$(eval BUILD_DIRECTORY := $(shell echo $(2) | sed 's/\/Dockerfile.*//'))
$(eval VARIANT := $(shell echo $(notdir $(2)) | cut -d. -f2))
$(eval DOCKERFILE := $(BUILD_DIRECTORY)/Dockerfile$(if $(KONFLUX:no=),.konflux,$(empty)).$(VARIANT))
$(eval CONF_FILE := $(BUILD_DIRECTORY)/build-args/$(if $(KONFLUX:no=),konflux.,$(empty))$(shell echo $(VARIANT)).conf)
$(info #*# Image build Dockerfile: <$(DOCKERFILE)> #(MACHINE-PARSED LINE)#*#...)
$(info #*# Image build directory: <$(BUILD_DIRECTORY)> #(MACHINE-PARSED LINE)#*#...)
$(call build_image,$(1),$(DOCKERFILE),$(CONF_FILE))
$(if $(PUSH_IMAGES:no=),
$(call push_image,$(1))
)
endef
####################################### Build helpers #######################################
# https://stackoverflow.com/questions/78899903/how-to-create-a-make-target-which-is-an-implicit-dependency-for-all-other-target
skip-init-for := all-images deploy% undeploy% test% validate% refresh-lock-files scan-image-vulnerabilities print-release
ifneq (,$(filter-out $(skip-init-for),$(MAKECMDGOALS) $(.DEFAULT_GOAL)))
$(SELF): bin/buildinputs
endif
bin/buildinputs: scripts/buildinputs/buildinputs.go scripts/buildinputs/go.mod scripts/buildinputs/go.sum
$(info Building a Go helper for Dockerfile dependency analysis...)
go build -C "scripts/buildinputs" -o "$(ROOT_DIR)/$@" ./...
####################################### Buildchain for Python using ubi9 #####################################
.PHONY: jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/minimal/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: jupyter-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION)
jupyter-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/datascience/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: cuda-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
cuda-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/minimal/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: cuda-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
cuda-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/tensorflow/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: cuda-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
cuda-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/pytorch/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: cuda-jupyter-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION)
cuda-jupyter-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/pytorch+llmcompressor/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION)
jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/trustyai/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: runtime-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
runtime-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/minimal/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: runtime-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION)
runtime-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/datascience/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: runtime-cuda-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
runtime-cuda-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/pytorch/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: runtime-cuda-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION)
runtime-cuda-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/pytorch+llmcompressor/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: runtime-cuda-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
runtime-cuda-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/tensorflow/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
.PHONY: codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION)
codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,codeserver/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
####################################### Buildchain for Python using C9S #######################################
.PHONY: rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
rstudio-c9s-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,rstudio/c9s-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: cuda-rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
cuda-rstudio-c9s-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,rstudio/c9s-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
####################################### Buildchain for Python using rhel9 #######################################
.PHONY: rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,rstudio/rhel9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cpu)
.PHONY: cuda-rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
cuda-rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,rstudio/rhel9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.cuda)
####################################### Buildchain for AMD Python using UBI9 #######################################
.PHONY: rocm-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/minimal/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.rocm)
.PHONY: rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/rocm/tensorflow/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.rocm)
.PHONY: rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,jupyter/rocm/pytorch/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.rocm)
.PHONY: rocm-runtime-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-runtime-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/rocm-pytorch/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.rocm)
.PHONY: rocm-runtime-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
rocm-runtime-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION):
$(call image,$@,runtimes/rocm-tensorflow/ubi9-python-$(RELEASE_PYTHON_VERSION)/Dockerfile.rocm)
####################################### Deployments #######################################
# Download kubectl binary
.PHONY: bin/kubectl
bin/kubectl:
ifeq (,$(wildcard $(KUBECTL_BIN)))
@mkdir -p bin
@curl -sSL https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/$(OS_ARCH)/kubectl > \
$(KUBECTL_BIN)
@chmod +x $(KUBECTL_BIN)
endif
# Download yq binary
.PHONY: bin/yq
bin/yq:
$(eval YQ_RELEASE_FILE := yq_$(subst /,_,$(OS_ARCH)))
ifeq (,$(wildcard $(YQ_BIN)))
@mkdir -p bin
@curl -sSL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_RELEASE_FILE} > \
$(YQ_BIN)
@chmod +x $(YQ_BIN)
endif
.PHONY: deploy9
deploy9-%: bin/kubectl bin/yq
$(eval TARGET := $(shell echo $* | sed 's/-ubi9-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/ubi9-python-$(PYTHON_VERSION)/kustomize/base)
ifndef NOTEBOOK_TAG
$(eval NOTEBOOK_TAG := $*-$(IMAGE_TAG))
endif
$(info # Deploying notebook from $(NOTEBOOK_DIR) directory...)
@arg=$(IMAGE_REGISTRY) $(YQ_BIN) e -i '.images[].newName = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
@arg=$(NOTEBOOK_TAG) $(YQ_BIN) e -i '.images[].newTag = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
$(KUBECTL_BIN) apply -k $(NOTEBOOK_DIR)
.PHONY: undeploy9
undeploy9-%: bin/kubectl
$(eval TARGET := $(shell echo $* | sed 's/-ubi9-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/ubi9-python-$(PYTHON_VERSION)/kustomize/base)
$(info # Undeploying notebook from $(NOTEBOOK_DIR) directory...)
$(KUBECTL_BIN) delete -k $(NOTEBOOK_DIR)
.PHONY: deploy-c9s
deploy-c9s-%: bin/kubectl bin/yq
$(eval TARGET := $(shell echo $* | sed 's/-c9s-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/c9s-python-$(PYTHON_VERSION)/kustomize/base)
ifndef NOTEBOOK_TAG
$(eval NOTEBOOK_TAG := $*-$(IMAGE_TAG))
endif
$(info # Deploying notebook from $(NOTEBOOK_DIR) directory...)
@arg=$(IMAGE_REGISTRY) $(YQ_BIN) e -i '.images[].newName = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
@arg=$(NOTEBOOK_TAG) $(YQ_BIN) e -i '.images[].newTag = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
$(KUBECTL_BIN) apply -k $(NOTEBOOK_DIR)
.PHONY: undeploy-c9s
undeploy-c9s-%: bin/kubectl
$(eval TARGET := $(shell echo $* | sed 's/-c9s-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/c9s-python-$(PYTHON_VERSION)/kustomize/base)
$(info # Undeploying notebook from $(NOTEBOOK_DIR) directory...)
$(KUBECTL_BIN) delete -k $(NOTEBOOK_DIR)
.PHONY: deploy-rhel9
deploy-rhel9-%: bin/kubectl bin/yq
$(eval TARGET := $(shell echo $* | sed 's/-rhel9-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/rhel9-python-$(PYTHON_VERSION)/kustomize/base)
ifndef NOTEBOOK_TAG
$(eval NOTEBOOK_TAG := $*-$(IMAGE_TAG))
endif
$(info # Deploying notebook from $(NOTEBOOK_DIR) directory...)
@arg=$(IMAGE_REGISTRY) $(YQ_BIN) e -i '.images[].newName = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
@arg=$(NOTEBOOK_TAG) $(YQ_BIN) e -i '.images[].newTag = strenv(arg)' $(NOTEBOOK_DIR)/kustomization.yaml
$(KUBECTL_BIN) apply -k $(NOTEBOOK_DIR)
.PHONY: undeploy-rhel9
undeploy-rhel9-%: bin/kubectl
$(eval TARGET := $(shell echo $* | sed 's/-rhel9-python.*//'))
$(eval PYTHON_VERSION := $(shell echo $* | sed 's/.*-python-//'))
$(eval NOTEBOOK_DIR := $(subst -,/,$(subst cuda-,,$(TARGET)))/rhel9-python-$(PYTHON_VERSION)/kustomize/base)
$(info # Undeploying notebook from $(NOTEBOOK_DIR) directory...)
$(KUBECTL_BIN) delete -k $(NOTEBOOK_DIR)
# Verify the notebook's readiness by pinging the /api endpoint and executing the corresponding test_notebook.ipynb file in accordance with the build chain logic.
.PHONY: test
test-%: bin/kubectl
$(info # Running tests for $* notebook...)
@./scripts/test_jupyter_with_papermill.sh $*
# Validate that runtime image meets minimum criteria
# This validation is created from subset of https://github.com/elyra-ai/elyra/blob/9c417d2adc9d9f972de5f98fd37f6945e0357ab9/Makefile#L325
# Elyra pins are applied from ci/requirements-elyra.txt (kubectl cp) so CI stays reproducible when PyPI drops a pin.
.PHONY: validate-runtime-image
validate-runtime-image: bin/kubectl
$(eval NOTEBOOK_NAME := $(subst .,-,$(subst cuda-,,$*)))
$(info # Running tests for $(NOTEBOOK_NAME) runtime...)
$(KUBECTL_BIN) wait --for=condition=ready pod runtime-pod --timeout=300s
@required_commands=$(REQUIRED_RUNTIME_IMAGE_COMMANDS)
fail=0
if [[ $$image == "" ]] ; then
echo "Usage: make validate-runtime-image image=<container-image-name>"
exit 1
fi
for cmd in $$required_commands ; do
echo "=> Checking container image $$image for $$cmd..."
if ! $(KUBECTL_BIN) exec runtime-pod which $$cmd > /dev/null 2>&1 ; then
echo "ERROR: Container image $$image does not meet criteria for command: $$cmd"
fail=1
continue
fi
if [ $$cmd == "python3" ]; then
echo "=> Checking notebook execution..."
if ! $(KUBECTL_BIN) cp "$(CURDIR)/ci/requirements-elyra.txt" runtime-pod:/tmp/requirements-elyra.txt || \
! $(KUBECTL_BIN) exec runtime-pod -- /bin/sh -c "python3 -m pip install -r /tmp/requirements-elyra.txt > /dev/null && \
curl -fsSL https://raw.githubusercontent.com/nteract/papermill/main/papermill/tests/notebooks/simple_execute.ipynb --output simple_execute.ipynb && \
python3 -m papermill simple_execute.ipynb output.ipynb > /dev/null" ; then
echo "ERROR: Image does not meet Python requirements criteria in pipfile"
fail=1
fi
fi
done
if [ $$fail -eq 1 ]; then
echo "=> ERROR: Container image $$image is not a suitable Elyra runtime image"
exit 1
else
echo "=> Container image $$image is a suitable Elyra runtime image"
fi;
.PHONY: validate-codeserver-image
validate-codeserver-image: bin/kubectl
$(eval NOTEBOOK_NAME := $(subst .,-,$(subst cuda-,,$*)))
$(info # Running tests for $(NOTEBOOK_NAME) code-server image...)
$(KUBECTL_BIN) wait --for=condition=ready pod codeserver-pod --timeout=300s
@required_commands=$(REQUIRED_CODE_SERVER_IMAGE_COMMANDS)
if [[ $$image == "" ]] ; then
echo "Usage: make validate-codeserver-image image=<container-image-name>"
exit 1
fi
for cmd in $$required_commands ; do
echo "=> Checking container image $$image for $$cmd..."
if ! $(KUBECTL_BIN) exec codeserver-pod which $$cmd > /dev/null 2>&1 ; then
echo "ERROR: Container image $$image does not meet criteria for command: $$cmd"
fail=1
continue
fi
done
.PHONY: validate-rstudio-image
validate-rstudio-image: bin/kubectl
$(eval NOTEBOOK_NAME := $(subst .,-,$(subst cuda-,,$(image))))
$(eval PYTHON_VERSION := $(shell echo $(image) | sed 's/.*-python-//'))
$(info # Running tests for $(NOTEBOOK_NAME) RStudio Server image...)
$(KUBECTL_BIN) wait --for=condition=ready pod rstudio-pod --timeout=300s
@required_commands=$(REQUIRED_R_STUDIO_IMAGE_COMMANDS)
if [[ $$image == "" ]] ; then
echo "Usage: make validate-rstudio-image image=<container-image-name>"
exit 1
fi
echo "=> Checking container image $$image for package installation..."
$(KUBECTL_BIN) exec -it rstudio-pod -- mkdir -p /opt/app-root/src/R/temp-library > /dev/null 2>&1
if $(KUBECTL_BIN) exec rstudio-pod -- R -e "install.packages('tinytex', lib='/opt/app-root/src/R/temp-library')" > /dev/null 2>&1 ; then
echo "Tinytex installation successful!"
else
echo "Error: Tinytex installation failed."
fi
for cmd in $$required_commands ; do
echo "=> Checking container image $$image for $$cmd..."
if $(KUBECTL_BIN) exec rstudio-pod which $$cmd > /dev/null 2>&1 ; then
echo "$$cmd executed successfully!"
else
echo "ERROR: Container image $$image does not meet criteria for command: $$cmd"
fail=1
continue
fi
done
echo "=> Fetching R script from URL and executing on the container..."
curl -sSL -o test_script.R "${NOTEBOOK_REPO_BRANCH_BASE}/rstudio/c9s-python-$(PYTHON_VERSION)/test/test_script.R" > /dev/null 2>&1
$(KUBECTL_BIN) cp test_script.R rstudio-pod:/opt/app-root/src/test_script.R > /dev/null 2>&1
if $(KUBECTL_BIN) exec rstudio-pod -- Rscript /opt/app-root/src/test_script.R > /dev/null 2>&1 ; then
echo "R script executed successfully!"
rm test_script.R
else
echo "Error: R script failed."
fail=1
continue
fi
# ======================================================================================
# Refresh lock files
# Usage examples:
# gmake refresh-lock-files <- auto mode (rh-index if uv.lock.d/ exists, else public-index)
# gmake refresh-lock-files INDEX_MODE=public-index <- force public-index
# gmake refresh-lock-files INDEX_MODE=public-index DIR=jupyter/minimal/ubi9-python-3.12
# ======================================================================================
DIR ?=
.PHONY: refresh-lock-files
refresh-lock-files:
@echo "==================================================================="
@echo "🔁 Refreshing lock files using INDEX_MODE=$(INDEX_MODE)"
@echo "==================================================================="
@cd $(ROOT_DIR) && ./uv run scripts/pylocks_generator.py $(INDEX_MODE) $(DIR)
# This is only for the workflow action
# For running manually, set the required environment variables
.PHONY: scan-image-vulnerabilities
scan-image-vulnerabilities:
python ci/security-scan/quay_security_analysis.py
# This is used primarily for gen_gha_matrix_jobs.py to we know the set of all possible images we may want to build
.PHONY: all-images
ifeq ($(RELEASE_PYTHON_VERSION), 3.12)
all-images: \
jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
jupyter-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION) \
cuda-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
cuda-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
cuda-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
cuda-jupyter-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION) \
codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION) \
jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION) \
runtime-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
runtime-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION) \
runtime-cuda-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
runtime-cuda-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
runtime-cuda-pytorch-llmcompressor-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-runtime-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-runtime-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rocm-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
rstudio-c9s-python-$(RELEASE_PYTHON_VERSION) \
cuda-rstudio-c9s-python-$(RELEASE_PYTHON_VERSION) \
rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION) \
cuda-rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
else
$(error Invalid Python version $(RELEASE_PYTHON_VERSION))
endif
# This is used primarily for `konflux_generate_component_build_pipelines.py` to we know the build release version
.PHONY: print-release
print-release:
@echo "$(RELEASE)"
.PHONY: setup
setup:
./uv sync --locked
.PHONY: test
test:
@echo "Running quick static tests"
./uv run pytest -m 'not buildonlytest'
@./scripts/check_dockerfile_alignment.sh
.PHONY: test-unit
test-unit:
@echo "Running Python unit tests"
./uv run pytest -m 'not buildonlytest' --ignore=tests/containers tests/ ntb/
@echo "Running Go unit tests"
go test -C scripts/buildinputs -cover ./...
PYTEST_ARGS ?=
.PHONY: test-integration
test-integration:
ifeq ($(PYTEST_ARGS),)
$(error Usage: make test-integration PYTEST_ARGS="--image=<image>")
endif
@echo "Running container integration tests"
./uv run pytest tests/containers -m 'not openshift and not cuda and not rocm' $(PYTEST_ARGS)
.PHONY: unit-test integration-test
unit-test: test-unit
integration-test: test-integration