Skip to content

Commit

Permalink
base: Update JupyterLab to v4.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
benz0li committed Nov 23, 2023
1 parent 946b3fe commit 536a918
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 152 deletions.
2 changes: 1 addition & 1 deletion VERSION_MATRIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Topmost entry = Tag `latest`

| Python | Jupyter Hub | Jupyter Lab | code‑server (Code) | Git | Git LFS | Pandoc | CTAN date[^2] | Quarto[^2] | Linux distro |
|:-----------|:------------|:------------|:-------------------|:-------|:--------|:-------|:--------------|:------------|:-------------|
| 3.11.6 | 4.0.2 | 3.6.6 | 4.19.0 (1.84.2) | 2.43.0 | 3.4.0 | 3.1.1 | | 1.3.450 | Debian 12 |
| 3.11.6 | 4.0.2 | 4.0.9 | 4.19.0 (1.84.2) | 2.43.0 | 3.4.0 | 3.1.1 | | 1.3.450 | Debian 12 |
| 3.11.5 | 4.0.2 | 3.6.6 | 4.17.1 (1.82.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑10‑02 | 1.3.450 | Debian 12 |
| 3.11.4 | 4.0.2 | 3.6.5 | 4.16.1 (1.80.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑08‑24 | 1.3.450 | Debian 12 |
| 3.10.13 | 4.0.2 | 3.6.5 | 4.16.1 (1.80.2) | 2.42.0 | 3.4.0 | 3.1.1 | 2023‑08‑24 | 1.3.450 | Debian 12 |
Expand Down
96 changes: 0 additions & 96 deletions base/conf/jupyter/etc/jupyter/jupyter_notebook_config.py

This file was deleted.

25 changes: 12 additions & 13 deletions base/conf/jupyter/etc/jupyter/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

# mypy: ignore-errors
import os
import shutil
import stat
import subprocess
from pathlib import Path

from jupyter_core.paths import jupyter_data_dir

c = get_config()
c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0"
c.ServerApp.port = 8888
#c.ServerApp.open_browser = False
Expand Down Expand Up @@ -61,15 +62,14 @@ def _codeserver_command(port):
[req_distinguished_name]
"""
if "GEN_CERT" in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, "notebook.pem")
os.makedirs(dir_name, exist_ok=True)
dir_name = Path(jupyter_data_dir())
dir_name.mkdir(parents=True, exist_ok=True)
pem_file = dir_name / "notebook.pem"

# Generate an openssl.cnf file to set the distinguished name
cnf_file = os.path.join(os.getenv("CONDA_DIR", "/usr/lib"), "ssl", "openssl.cnf")
if not os.path.isfile(cnf_file):
with open(cnf_file, "w") as fh:
fh.write(OPENSSL_CONFIG)
cnf_file = Path("/usr/lib/ssl/openssl.cnf")
if not cnf_file.exists():
cnf_file.write_text(OPENSSL_CONFIG)

# Generate a certificate if one doesn't exist on disk
subprocess.check_call(
Expand All @@ -87,10 +87,9 @@ def _codeserver_command(port):
]
)
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.ServerApp.certfile = pem_file
pem_file.chmod(stat.S_IRUSR | stat.S_IWUSR)
c.ServerApp.certfile = str(pem_file)

# Change default umask for all subprocesses of the notebook server if set in
# the environment
# Change default umask for all subprocesses of the notebook server if set in the environment
if "NB_UMASK" in os.environ:
os.umask(int(os.environ["NB_UMASK"], 8))
3 changes: 2 additions & 1 deletion base/latest.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG CUDA_IMAGE_FLAVOR
ARG NB_USER=jovyan
ARG NB_UID=1000
ARG JUPYTERHUB_VERSION=4.0.2
ARG JUPYTERLAB_VERSION=3.6.6
ARG JUPYTERLAB_VERSION=4.0.9
ARG CODE_BUILTIN_EXTENSIONS_DIR=/opt/code-server/lib/vscode/extensions
ARG CODE_SERVER_VERSION=4.19.0
ARG GIT_VERSION=2.43.0
Expand Down Expand Up @@ -235,6 +235,7 @@ RUN export PIP_BREAK_SYSTEM_PACKAGES=1 \
jupyterlab-git \
jupyterlab-lsp \
notebook \
nbclassic \
nbconvert \
python-lsp-server[all] \
## Include custom fonts
Expand Down
75 changes: 42 additions & 33 deletions base/scripts/usr/local/bin/before-notebook.d/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,49 @@ if [ "$(id -u)" == 0 ] ; then
# Update timezone if needed
if [ "$TZ" != "Etc/UTC" ]; then
echo "Setting TZ to $TZ"
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime \
&& echo "$TZ" > /etc/timezone
fi

# Add/Update locale if needed
if [ ! -z "$LANGS" ]; then
if [ -n "$LANGS" ]; then
for i in $LANGS; do
sed -i "s/# $i/$i/g" /etc/locale.gen
done
fi
if [ "$LANG" != "en_US.UTF-8" ]; then
sed -i "s/# $LANG/$LANG/g" /etc/locale.gen
fi
if [[ "$LANG" != "en_US.UTF-8" || ! -z "$LANGS" ]]; then
if [[ "$LANG" != "en_US.UTF-8" || -n "$LANGS" ]]; then
locale-gen
fi
if [ "$LANG" != "en_US.UTF-8" ]; then
echo "Setting LANG to $LANG"
update-locale --reset LANG=$LANG
update-locale --reset LANG="$LANG"
fi

CS_USD="/home/$NB_USER/.local/share/code-server/User"
# Update code-server settings
su $NB_USER -c "mkdir -p /home/$NB_USER/.local/share/code-server/User"
if [[ ! -f "/home/$NB_USER/.local/share/code-server/User/settings.json" ]]; then
su $NB_USER -c "cp ${CP_OPTS:--a} /var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json"
chown :$NB_GID "/home/$NB_USER/.local/share/code-server/User/settings.json"
su "$NB_USER" -c "mkdir -p $CS_USD"
if [[ ! -f "$CS_USD/settings.json" ]]; then
su "$NB_USER" -c "cp ${CP_OPTS:--a} /var/backups/skel/.local/share/code-server/User/settings.json \
$CS_USD/settings.json"
chown :"$NB_GID" "$CS_USD/settings.json"
fi
# Update code-server settings
su "$NB_USER" -c "mv $CS_USD/settings.json $CS_USD/settings.json.bak"
su "$NB_USER" -c "sed -i ':a;N;\$!ba;s/,\n\}/\n}/g' $CS_USD/settings.json.bak"
if [[ $(jq . "$CS_USD/settings.json.bak" 2> /dev/null) ]]; then
su "$NB_USER" -c "jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
$CS_USD/settings.json.bak > \
$CS_USD/settings.json"
else
su "$NB_USER" -c "mv $CS_USD/settings.json.bak $CS_USD/settings.json"
fi

su $NB_USER -c "mv /home/$NB_USER/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak"
su $NB_USER -c "sed -i ':a;N;\$!ba;s/,\n\}/\n}/g' \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak"
su $NB_USER -c "jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak > \
/home/$NB_USER/.local/share/code-server/User/settings.json"
# Remove old .zcompdump files
rm -f "/home/$NB_USER/.zcompdump"*
else
# Warn if the user wants to change the timezone but hasn't started the
# container as root.
Expand All @@ -58,7 +64,7 @@ else

# Warn if the user wants to change the locale but hasn't started the
# container as root.
if [[ ! -z "$LANGS" ]]; then
if [[ -n "$LANGS" ]]; then
echo "WARNING: Container must be started as root to add locale(s)!"
fi
if [[ "$LANG" != "en_US.UTF-8" ]]; then
Expand All @@ -67,22 +73,25 @@ else
LANG=en_US.UTF-8
fi

CS_USD="$HOME/.local/share/code-server/User"
# Update code-server settings
mkdir -p /home/$NB_USER/.local/share/code-server/User
if [[ ! -f "/home/$NB_USER/.local/share/code-server/User/settings.json" ]]; then
mkdir -p "$CS_USD"
if [[ ! -f "$CS_USD/settings.json" ]]; then
cp -a /var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json
"$CS_USD/settings.json"
fi
# Update code-server settings
mv "$CS_USD/settings.json" "$CS_USD/settings.json.bak"
sed -i ':a;N;$!ba;s/,\n\}/\n}/g' "$CS_USD/settings.json.bak"
if [[ $(jq . "$CS_USD/settings.json.bak" 2> /dev/null) ]]; then
jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
"$CS_USD/settings.json.bak" > \
"$CS_USD/settings.json"
else
mv "$CS_USD/settings.json.bak" "$CS_USD/settings.json"
fi

mv /home/$NB_USER/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak
sed -i ':a;N;$!ba;s/,\n\}/\n}/g' \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak
jq -s '.[0] * .[1]' \
/var/backups/skel/.local/share/code-server/User/settings.json \
/home/$NB_USER/.local/share/code-server/User/settings.json.bak > \
/home/$NB_USER/.local/share/code-server/User/settings.json
# Remove old .zcompdump files
rm -f "$HOME/.zcompdump"*
fi

# Remove old .zcompdump files
rm -f /home/$NB_USER/.zcompdump*
10 changes: 5 additions & 5 deletions base/scripts/usr/local/bin/before-notebook.d/limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ set -e

DIVISOR=1024

if [[ "${SWAP_ENABLE}" == "1" || "${SWAP_ENABLE}" == "yes" ]]; then
FACTOR=$(echo 1 ${SWAP_FACTOR:-1} | awk '{ printf "%.1f", $1 + $2 }')
if [[ "$SWAP_ENABLE" == "1" || "$SWAP_ENABLE" == "yes" ]]; then
FACTOR=$(echo 1 "${SWAP_FACTOR:-1}" | awk '{ printf "%.1f", $1 + $2 }')
else
FACTOR=1
fi

if [ ! -z "${MEM_LIMIT}" ]; then
ulimit -Sv $(echo $MEM_LIMIT $DIVISOR $FACTOR |
awk '{ printf "%.0f", $1 / $2 * $3 }')
if [ -n "$MEM_LIMIT" ]; then
ulimit -Sv "$(echo "$MEM_LIMIT" "$DIVISOR $FACTOR" |
awk '{ printf "%.0f", $1 / $2 * $3 }')"
fi
4 changes: 2 additions & 2 deletions base/scripts/usr/local/bin/busy
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright (c) 2022 b-data GmbH.
# Distributed under the terms of the MIT License.

while [ ! -z $JUPYTERHUB_API_TOKEN ]; do
while [ -n "$JUPYTERHUB_API_TOKEN" ]; do
t=$(date -Iseconds)
curl -s \
$JUPYTERHUB_ACTIVITY_URL -H \
"$JUPYTERHUB_ACTIVITY_URL" -H \
"Authorization: token $JUPYTERHUB_API_TOKEN" -d \
"{\"servers\":{\"$JUPYTERHUB_SERVER_NAME\":{\"last_activity\":\"$t\"}},\"last_activity\":\"$t\"}" \
> /dev/null 2>&1
Expand Down
8 changes: 8 additions & 0 deletions base/scripts/usr/local/bin/run-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ for f in "${1}/"*; do
echo "Sourcing shell script: ${f}"
# shellcheck disable=SC1090
source "${f}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "${f} has failed, continuing execution"
fi
;;
*)
if [ -x "${f}" ] ; then
echo "Running executable: ${f}"
"${f}"
# shellcheck disable=SC2181
if [ $? -ne 0 ] ; then
echo "${f} has failed, continuing execution"
fi
else
echo "Ignoring non-executable: ${f}"
fi
Expand Down
2 changes: 1 addition & 1 deletion scipy/latest.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ RUN dpkgArch="$(dpkg --print-architecture)" \
## Install facets
&& cd /tmp \
&& git clone https://github.com/PAIR-code/facets.git \
&& jupyter nbextension install facets/facets-dist/ --sys-prefix \
&& jupyter nbclassic-extension install facets/facets-dist/ --sys-prefix \
&& cd / \
## Install code-server extensions
&& code-server --extensions-dir ${CODE_BUILTIN_EXTENSIONS_DIR} --install-extension quarto.quarto \
Expand Down

0 comments on commit 536a918

Please sign in to comment.