Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doku:jupyterhub [2023/02/27 09:03] – [BYOI: Bring your own (Singularity) Image] katrindoku:jupyterhub [2023/11/14 13:51] (current) – [Necessary Packages] katrin
Line 70: Line 70:
 To stop the server, click on 'Control Panel' at the top right and choose 'Stop My Server' To stop the server, click on 'Control Panel' at the top right and choose 'Stop My Server'
  
-===== BYOI: Bring your own (Singularity) Image =====+===== BYOI: Bring your own (Apptainer/Singularity) Image =====
  
-It is possible to use a custom singularity image with our JupyterHub profiles. +It is possible to use a custom apptainer/singularity image with our JupyterHub profiles. 
  
-A good starting point is to have a look at the official JupyterHub Docker Stacks Images @ [[https://github.com/jupyter/docker-stacks|Docker-Stacks]].+==== Necessary Packages ====
  
-In a nutshell it is only necessary to install the following packages into your docker image +A good starting point for creating your own container is the documentation of the official JupyterHub Docker Stacks Images @ [[https://github.com/jupyter/docker-stacks|Docker-Stacks]] 
-  * jupyterhub==3.0.0 - This package pulls in all the necessary dependencies to start a jupyter server +
-  * git+https://github.com/katringoogoo/batchspawner.git@jupyterhub-3.0.0b1 This package provides functionality needed to run in the slurm environment of VSC (e.g. `batchspawner-singleuser` script).+
  
-In addition we also install the following jupyterlab extensions in our images but they are not strictly necessary and just provide extended functionality like memory monitoring for the user:+Apart from adding your own software the image also needs to have at least the following packages for it to be able to run in our JupyterHub environment: 
 +<code> 
 +# This package pulls in all the necessary dependencies to start a jupyter server 
 +# Make sure this always matches the current JupyterHub version used by VSC 
 +jupyterhub==3.1.1         
 + 
 +# This package provides functionality needed to run in the slurm environment of VSC (e.g. `batchspawner-singleuser` script). 
 +git+https://github.com/katringoogoo/batchspawner.git@1.2.0+auth_fix         
 +</code> 
 + 
 +In addition we usually also install the following jupyterlab extensions in our images but they are not strictly necessary and just provide extended functionality like memory monitoring for the user:
   * jupyterlab-system-monitor   * jupyterlab-system-monitor
   * jupyterlab-git    * jupyterlab-git 
-  * jupyterlab-widgets+  * jupyterlab-widgets (or jupyterlab_widgets in conda)
  
-**An up 2 date list of packages can always be found in our repo: [[https://gitlab.tuwien.ac.at/vsc/vsc-jupyterhub-notebooks/-/blob/main/tools/requirements.txt|requirements.txt]]**+**An up 2 date list of packages can always be found in our repo: [[https://gitlab.tuwien.ac.at/vsc/jupyterhub/jupyterhub-docker-stacks/-/blob/main/tools/requirements.txt|requirements.txt]]**
  
-In order to be able to use the image with JupyterHub you also have to make sure to convert it to a **singularity image** (or build it as a singularity image in the first place) and place it into a folder that is accessible from the VSC compute nodes. +=== Run hooks from /usr/local/bin/before-notebook.d ===
- +
-Building a singularity image from e.g. a docker container can easily be done with the `singularity build` command. See the singularity documentation for examples: [[https://apptainer.org/user-docs/3.8/build_a_container.html|Build a (singularity) container]] +
- +
-==== Run hooks from /usr/local/bin/before-notebook.d ====+
  
 If your image needs to run hooks before startup (e.g. the pyspark image depends on this [[https://github.com/jupyter/docker-stacks/blob/master/pyspark-notebook/Dockerfile|PySpark Dockerfile]]), the docker stack images provide a folderfor such startup scripts `/usr/local/bin/before-notebook.d`.  If your image needs to run hooks before startup (e.g. the pyspark image depends on this [[https://github.com/jupyter/docker-stacks/blob/master/pyspark-notebook/Dockerfile|PySpark Dockerfile]]), the docker stack images provide a folderfor such startup scripts `/usr/local/bin/before-notebook.d`. 
Line 101: Line 105:
 Note: Contact us to get read rights to the repository. Note: Contact us to get read rights to the repository.
  
 +==== Build your own custom image from a docker image ====
  
 +[[https://docs.docker.com/engine/reference/builder/|Dockerfile Documentation]]
  
 +If you already have a docker image you want to start from or if you are more familiar with docker image creation you can just use that image and create it into a singularity image after you are finished.
  
-===== FAQ =====+Note: Make sure that you use the right versions for the current version of our JupyterHub (the version is displayed at the bottom of the [[http://jupyterhub.vsc.ac.at|jupyterhub page]] and was 3.1.1 at the time of writing).
  
-  * **The OTP SMS says 'login at vsc3'? Is this an issue?**+After selecting / building the docker image all that needs to be done is to convert it into a **singularity image**
  
-No this is a current limitation of our OTP system and should not cause any problems.+You can do this by executing the following lines (assuming your docker image is named "my_image"
 +<code> 
 +singularity build my_image.sif docker://my_image 
 +</code> 
 + 
 +See the documentation for more examples: [[https://apptainer.org/user-docs/3.8/build_a_container.html|Build (singularity) container]] 
 + 
 +When the conversion process has finished make sure that the resulting ".sif" file is placed in a folder that is available from all compute nodes (e.g. home dir; data dir) 
 + 
 +Note: the conversion can be done on our cluster since we have singularity installed on our nodes.  
 + 
 +==== Directly build a singularity/apptainer image ==== 
 + 
 +Instead of starting with docker you can also directly build a singularity image that is ready to use with our JupyterHub instance. 
 + 
 +For this you need to create a so called ".def" file - see the singularity documentation for more information on this format: [[https://apptainer.org/user-docs/3.8/definition_files.html|Definition Files]] 
 + 
 +Here is a minimal example using the datascience docker stacks image as a basis: 
 +<code> 
 +BootStrap: docker 
 +From: jupyter/datascience-notebook:hub-3.1.1 
 + 
 +%post 
 +/opt/conda/bin/pip install jupyterhub==3.1.1 git+https://github.com/katringoogoo/batchspawner.git@1.2.0+auth_fix                
 +</code> 
 + 
 +If we save the file as "my_image.def" we can use the build command to build the image with singularity/apptainer.  
 + 
 +Please not that you have to use apptainer if you want to build on the cluster, since the singularity version that comes installed on all nodes from the OS needs root rights to build an image. 
 + 
 +  * VSC4: module load --auto apptainer/1.1.9-gcc-12.2.0-vflkcfi 
 +  * VSC5: module load --auto apptainer/1.1.6-gcc-12.2.0-xxfuqni 
 + 
 + 
 +<code> 
 +# load an apptainer module (see above) 
 +module load --auto apptainer/<version> 
 + 
 +# build the image 
 +apptainer build my_image.sif my_image.def 
 +</code> 
 + 
 +If you cannot use the versions provided on VSC you can of course also build the image on your own machine and upload it the VSC. 
 + 
 +===== FAQ =====
  
   * **My Server instance is stuck and I get a timeout when I try to reload the window. Going to the VSC jupyterhub website also results in a timeout.**   * **My Server instance is stuck and I get a timeout when I try to reload the window. Going to the VSC jupyterhub website also results in a timeout.**
  • doku/jupyterhub.1677488635.txt.gz
  • Last modified: 2023/02/27 09:03
  • by katrin