Kernels for Jupyter App

The Jupter Ap will provide the Python kernel from the system module for Python indicated in the application launch form.  To make other kernels available, they can be managed through a directory that the user indicates. The following procedure makes use of a default directory location, and uses the example of creating a 'bash kernel' from a PyPi project supporting that capability.

Procedure to create a kernel from a Python virtual environment

Develop a protocol for distinguishing environments meant to run on Pioneer from Markov or Rider, if necessary.  Create the virtual environment in the appropriate parent directory. 

cd /home/mrd20/local/pioneer/venvs

The following steps will create the venv for a specific version of Python.

module load Python/3.10.4-GCCcore-11.2.0

python3 -m venv bash_Py3.10.4  # choose your own name as you wish

Activate the environment, and install the package(s) into the environment.

source bash_Py3.10.4/bin/activate # activates the venv

pip3 install bash_kernel  # install within the venv

Lastly, generate a kernel to support the virtual environment.

python3 -m bash_kernel install --user --name bash_Py3.10.4 --display-name="bash kernel py3.10.4"   

The kernel info is installed by default into: ~/.local/share/jupyter/kernels/<kernel-name>

With the Jupyter module loaded, use 'kernelspec' as follows to see all available kernels.

[mrd20@hpc7 venvs]$ module load JupyterLab/3.5.0-GCCcore-11.3.0 

[mrd20@hpc7 venvs]$ jupyter kernelspec list

Available kernels:

  python3          /usr/local/easybuild_allnodes/software/IPython/8.5.0-GCCcore-11.3.0/share/jupyter/kernels/python3

  bash_py3.10.4    /home/mrd20/.local/share/jupyter/kernels/bash_py3.10.4

  bash_py3.9.6     /home/mrd20/.local/share/jupyter/kernels/bash_py3.9.6

  ir               /home/mrd20/.local/share/jupyter/kernels/ir

  jpvenv396        /home/mrd20/.local/share/jupyter/kernels/jpvenv396