Skip to content

Create a JupyterLab Application

This guide explains how to add the JupyterLab package to your Plexus applications and use it. Before continuing, read Create a Docker application.

Login

Create application

After reading Create a Docker application, you can configure the application using the JupyterLab package provided by Plexus. You can also add SSH access by installing the sshd service in the container.

Configure ports

This is an interactive application, so configure it as a service and expose:

  • JupyterLab: port 8888
  • SSH: port 22

Ports configuration

Configure container

Configure the required fields as described in Create a Docker application.

Scripts configuration

Readiness probe

Set the readiness script provided by the JupyterLab package: curl 0.0.0.0:8888.

Pre-run script

First, it's necessary to add the script to configure the aac user, adjust its UID and GID based on host system values, ensure ownership of key directories, and declare the environment variables at the container level in /etc/bash.bashrc:

useradd aac
echo "aac:$PLEXUS_SECRET_KEY" | chpasswd
echo "USERNAME: aac"
echo "PASSWORD: $PLEXUS_SECRET_KEY"
usermod -aG sudo aac
if [ -n "$HOST_USER_ID" ] && [ -n "$HOST_GROUP_ID" ]; then
  groupmod -g $HOST_GROUP_ID aac
  usermod -u $HOST_USER_ID -g $HOST_GROUP_ID  aac
fi


export -p | grep -v "declare -x HOME" >> /etc/bash.bashrc

chown -R aac:aac /tmp
chown -R aac:aac /home/aac
usermod --shell /bin/bash aac

Run script

Plexus sets up JupyterLab and exposes the secure access token via the PLEXUS_SECRET_KEY environment variable.

The script performs the following tasks:

  • Start the SSH service.
  • Install JupyterLab version 4.2.5.
  • Launch JupyterLab with specified configurations, including token-based authentication, Bash terminal settings, and root access.
echo "Starting  SSH service"
apt update && apt-get install openssh-server -y && service ssh start
echo "SSH service started"

pip install jupyterlab==4.2.5

jupyter lab --notebook-dir=/home/aac --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.token=$PLEXUS_SECRET_KEY --NotebookApp.terminado_settings="{'shell_command': ['/bin/bash']}"

Application execution

You can run the application in any queue with GPU. The endpoints appear on the right side of the workload view.

JupyterLab

  1. Select the JupyterLab endpoint.
  2. Copy the secret key.
  3. Click Connect.

JupyterLab login

Use the secret key to log in to JupyterLab.

JupyterLab after login

JupyterLab browser

SSH

  1. Select the SSH endpoint.
  2. Click Connect.
  3. Copy the shell command and run it in your terminal.
  4. Use the password shown in the window.

SSH endpoint