Skip to content

Commit bfef720

Browse files
authored
RHOAIENG-28848: Create Jupyter TrustyAI Python 3.12 Image (#1306)
1 parent 758b444 commit bfef720

File tree

11 files changed

+28577
-4
lines changed

11 files changed

+28577
-4
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,9 @@ else ifeq ($(PYTHON_VERSION), 3.12)
417417
jupyter/pytorch/ubi9-python-$(PYTHON_VERSION) \
418418
jupyter/tensorflow/ubi9-python-$(PYTHON_VERSION) \
419419
jupyter/rocm/pytorch/ubi9-python-$(PYTHON_VERSION) \
420-
codeserver/ubi9-python-$(PYTHON_VERSION)
421-
# jupyter/trustyai/ubi9-python-$(PYTHON_VERSION)
420+
codeserver/ubi9-python-$(PYTHON_VERSION) \
421+
jupyter/rocm/pytorch/ubi9-python-$(PYTHON_VERSION) \
422+
jupyter/trustyai/ubi9-python-$(PYTHON_VERSION)
422423
# jupyter/rocm/tensorflow/ubi9-python-$(PYTHON_VERSION)
423424
# runtimes/minimal/ubi9-python-$(PYTHON_VERSION)
424425
# runtimes/datascience/ubi9-python-$(PYTHON_VERSION)
@@ -505,8 +506,9 @@ all-images: \
505506
cuda-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
506507
cuda-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
507508
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
508-
codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION)
509-
# jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION)
509+
codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION) \
510+
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
511+
jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION)
510512
# runtime-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
511513
# runtime-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION)
512514
# runtime-cuda-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
######################################################
2+
# mongocli-builder (build stage only, not published) #
3+
######################################################
4+
FROM registry.access.redhat.com/ubi9/go-toolset:latest AS mongocli-builder
5+
6+
ARG MONGOCLI_VERSION=2.0.3
7+
8+
WORKDIR /tmp/
9+
RUN curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mongodb/mongodb-cli/archive/refs/tags/mongocli/v${MONGOCLI_VERSION}.zip
10+
RUN unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip
11+
RUN cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ && \
12+
CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/
13+
14+
########################
15+
# base #
16+
########################
17+
FROM registry.access.redhat.com/ubi9/python-312:latest AS base
18+
19+
WORKDIR /opt/app-root/bin
20+
21+
# OS Packages needs to be installed as root
22+
USER root
23+
24+
# Install useful OS packages
25+
RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
26+
27+
# Other apps and tools installed as default user
28+
USER 1001
29+
30+
# Install micropipenv to deploy packages from Pipfile.lock
31+
RUN pip install --no-cache-dir -U "micropipenv[toml]"
32+
33+
# Install the oc client
34+
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
35+
-o /tmp/openshift-client-linux.tar.gz && \
36+
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
37+
rm -f /tmp/openshift-client-linux.tar.gz
38+
39+
####################
40+
# jupyter-minimal #
41+
####################
42+
FROM base AS jupyter-minimal
43+
44+
ARG JUPYTER_REUSABLE_UTILS=jupyter/utils
45+
ARG MINIMAL_SOURCE_CODE=jupyter/minimal/ubi9-python-3.12
46+
47+
WORKDIR /opt/app-root/bin
48+
49+
COPY ${JUPYTER_REUSABLE_UTILS} utils/
50+
COPY ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
51+
52+
USER 0
53+
54+
# Dependencies for PDF export
55+
RUN ./utils/install_pdf_deps.sh
56+
ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
57+
58+
USER 1001
59+
60+
WORKDIR /opt/app-root/src
61+
62+
ENTRYPOINT ["start-notebook.sh"]
63+
64+
65+
########################
66+
# jupyter-datascience #
67+
########################
68+
FROM jupyter-minimal AS jupyter-datascience
69+
70+
ARG DATASCIENCE_SOURCE_CODE=jupyter/datascience/ubi9-python-3.12
71+
72+
WORKDIR /opt/app-root/bin
73+
74+
# OS Packages needs to be installed as root
75+
USER root
76+
77+
# Install useful OS packages
78+
RUN dnf install -y jq unixODBC postgresql git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
79+
80+
# Copy dynamically-linked mongocli built in earlier build stage
81+
COPY --from=mongocli-builder /tmp/mongocli /opt/app-root/bin/
82+
83+
# Install MSSQL Client, We need a special repo for MSSQL as they do their own distribution
84+
COPY ${DATASCIENCE_SOURCE_CODE}/mssql-2022.repo-x86_64 /etc/yum.repos.d/mssql-2022.repo
85+
86+
RUN ACCEPT_EULA=Y dnf install -y mssql-tools18 unixODBC-devel && dnf clean all && rm -rf /var/cache/yum
87+
88+
ENV PATH="$PATH:/opt/mssql-tools18/bin"
89+
90+
# Other apps and tools installed as default user
91+
USER 1001
92+
93+
# Copy Elyra setup to utils so that it's sourced at startup
94+
COPY ${DATASCIENCE_SOURCE_CODE}/setup-elyra.sh ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
95+
96+
WORKDIR /opt/app-root/src
97+
98+
####################
99+
# jupyter-trustyai #
100+
####################
101+
FROM jupyter-datascience AS jupyter-trustyai
102+
103+
ARG DATASCIENCE_SOURCE_CODE=jupyter/datascience/ubi9-python-3.12
104+
ARG TRUSTYAI_SOURCE_CODE=jupyter/trustyai/ubi9-python-3.12
105+
106+
LABEL name="odh-notebook-jupyter-trustyai-ubi9-python-3.12" \
107+
summary="Jupyter trustyai notebook image for ODH notebooks" \
108+
description="Jupyter trustyai notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
109+
io.k8s.display-name="Jupyter trustyai notebook image for ODH notebooks" \
110+
io.k8s.description="Jupyter trustyai notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
111+
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
112+
io.openshift.build.commit.ref="main" \
113+
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/jupyter/trustyai/ubi9-python-3.12" \
114+
io.openshift.build.image="quay.io/opendatahub/workbench-images:jupyter-trustyai-ubi9-python-3.12"
115+
116+
USER 0
117+
118+
# Install jre that is needed to run the trustyai library
119+
RUN INSTALL_PKGS="java-17-openjdk" && \
120+
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
121+
yum -y clean all --enablerepo='*'
122+
123+
USER 1001
124+
125+
# Install Python packages and Jupyterlab extensions from Pipfile.lock
126+
COPY ${TRUSTYAI_SOURCE_CODE}/Pipfile.lock ./
127+
128+
RUN echo "Installing softwares and packages" && \
129+
micropipenv install && \
130+
rm -f ./Pipfile.lock && \
131+
# setup path for runtime configuration
132+
mkdir /opt/app-root/runtimes && \
133+
# Remove default Elyra runtime-images \
134+
rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json && \
135+
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \
136+
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
137+
# copy jupyter configuration
138+
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \
139+
# Disable announcement plugin of jupyterlab \
140+
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
141+
# Apply JupyterLab addons \
142+
/opt/app-root/bin/utils/addons/apply.sh && \
143+
# Fix permissions to support pip in Openshift environments \
144+
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
145+
fix-permissions /opt/app-root -P
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[[source]]
7+
url = "https://download.pytorch.org/whl/cu126"
8+
verify_ssl = true
9+
name = "pytorch"
10+
11+
[dev-packages]
12+
13+
[packages]
14+
# PyTorch packages
15+
torch = {version = "==2.6.0+cu126", index = "pytorch"}
16+
# TrustyAI packages
17+
# More information available at:
18+
# - https://pypi.org/project/trustyai/
19+
# - https://github.com/trustyai-explainability/trustyai-explainability-python/blob/main/requirements.txt
20+
transformers = "~=4.50.0"
21+
datasets = "~=3.4.1"
22+
accelerate = "~=1.5.2"
23+
trustyai = "~=0.6.2"
24+
# Datascience and useful extensions
25+
boto3 = "~=1.37.8"
26+
kafka-python-ng = "~=2.2.3"
27+
kfp = "~=2.12.1"
28+
matplotlib = "~=3.10.3" # Should be pinned down to this version in order to be compatible with trustyai
29+
numpy = "~=1.26.4" # Should be pinned down to this version in order to be compatible with trustyai
30+
pandas = "~=1.5.3" # Should be pinned down to this version in order to be compatible with trustyai
31+
plotly = "~=6.0.0"
32+
scikit-learn = "~=1.7.0" # Should be pinned down to this version in order to be compatible with trustyai
33+
scipy = "~=1.15.2"
34+
skl2onnx = "~=1.18.0"
35+
onnxconverter-common = "~=1.13.0" # Required for skl2onnx, as upgraded version is not compatible with protobuf
36+
codeflare-sdk = "~=0.29.0"
37+
kubeflow-training = "==1.9.2"
38+
39+
# DB connectors
40+
pymongo = "~=4.11.2"
41+
psycopg = "~=3.2.5"
42+
pyodbc = "~=5.2.0"
43+
mysql-connector-python = "~=9.3.0"
44+
45+
# JupyterLab packages
46+
odh-elyra = "==4.2.1"
47+
48+
jupyterlab = "==4.2.7"
49+
jupyter-bokeh = "~=3.0.5" # Should be pinned down to this version in order to be compatible with trustyai
50+
jupyter-server = "~=2.15.0"
51+
jupyter-server-proxy = "~=4.4.0"
52+
jupyter-server-terminals = "~=0.5.3"
53+
jupyterlab-git = "~=0.50.1"
54+
jupyterlab-lsp = "~=5.1.0"
55+
jupyterlab-widgets = "~=3.0.13"
56+
jupyter-resource-usage = "~=1.1.1"
57+
nbdime = "~=4.0.2"
58+
nbgitpuller = "~=1.2.2"
59+
60+
# Base packages
61+
wheel = "~=0.45.1"
62+
setuptools = "~=78.1.1"
63+
64+
[requires]
65+
python_version = "3.12"

0 commit comments

Comments
 (0)