How to quickly create a test kernel#

This is a follow up on Kernels. In some cases, the process of publishing new Python modules can take long. In the meantime, you can create a test kernel to use it in Jupyterhub. In this example, we are not going to create a new conda env but only the kernel configuration files.

Note

in this tutorial, I will take the module python3/2021-01. as an example.

Create a kernel configuration file#

  1. log in to Levante

  2. module load python3

  3. python -m ipykernel install --user --name python3-2021-01 --display-name="python3/2021-01"

Now, a kernelspec is created (as printed in the terminal) in `Installed kernelspec python3-2021-01 in /path/to/.local/share/jupyter/kernels/python3-2021-01

Create a bash script#

We need a bash script to load the test module:

  1. touch start-kernel.sh

  2. chmod +x start-kernel.sh

  3. put the following lines in the start-kernel.sh

#!/bin/bash

module purge

module load python3/2021.01-gcc-9.1.0

python -m ipykernel_launcher -f "$1"

Modify kernel.json#

Finally, you need to change the link to start-kernel.sh in the kernel specification file created in the first step. It should look like this:

{
 "argv": [
     "/path/to/start-kernel.sh",
     "{connection_file}"
 ],
 "display_name": "python3/2021-01",
 "language": "python"
}

Start a Jupyter Notebook/lab and the new kernel should be available.