MitchellLab-Handbook
  • Welcome
  • Lab overview
  • Lab Policies
    • Code of conduct
    • Communication
    • Day to day expectations
    • Work and Life
    • Diversity
    • New starters
    • Lab leavers
    • Recurring events
    • Internal resources
    • External resources
    • Essential reading list
    • Record Keeping
    • Publications
    • Conferences
    • How to get help
    • Wellbeing
    • Training
    • Data management
    • Logistics
    • Appraisals
    • Leaving
    • Writing Feedback
  • Lab work
    • Lab rules
    • Lab resources
  • Computational Work
    • Coding handbook
    • Connecting to our hardware
    • Coding resources
    • Running the multiscale model
    • Teaching environment
  • Modelling Tutorials
    • Modelling Tutorial 1
    • Modelling Tutorial 2
    • Other Modelling Resources
Powered by GitBook
On this page
  • Using the JupyterHub for teaching.
  • Starting the JupyterHub for teaching.
  • Installing the JupyterHub for teaching from scratch.
  • Debugging the teaching JupyterHub
  • Updating the github repos in existing users

Was this helpful?

  1. Computational Work

Teaching environment

PreviousRunning the multiscale modelNextModelling Tutorial 1

Last updated 2 months ago

Was this helpful?

For teaching we have a separate JupyterHub environment that contains the required packages needed for teaching basic Julia and Python Modelling. This document explains how to run the jupyterhub environment and how students can use it. Finally instructions for installing the environment are provided because it wasn't simple and I never want to have to figure it out again.

Using the JupyterHub for teaching.

This environment can be accessed here here:

Some (15) users have been set up by default and additional users can easily be added. If the class is larger than 15 students this will need to happen. Give each user a login and make sure every user has a different login otherwise they will interfere with each other. The usernames and passwords are given in the table below.

User name
Password

student1

teaching1

student2

teaching2

...

...

student15

teaching15

When the students log in they will see the context of three github repos have automatically been added to their folders: is in a folder called MDModelling is in a folder called cancerModelling is in a folder called popModelling

If you want to update you teaching material, just update the appropriate GitHub repo, as this will be substantially easier than updating each user's environment on JupyterHub.

Please note the project.toml/environment.yml are ignored and dependencies need to be manually added to the appropriate docker files downloaded when installing the environment (see below).

You now should be able to simply go to the correct folder for your teaching and each student should be able to run their sheet in their environment. Warning this environment is a transient Docker environment so any results they generate will be lost unless they download them.

Starting the JupyterHub for teaching.

The magic command is: sudo docker run --name jupyterhubDockerTeaching -p9001:8111 --network jupyterhub_network -v /var/run/docker.sock:/var/run/docker.sock -v /data/jupyterhub:/srv/jupyterhub simon/jupyterhubmulti:latest

If you receive the error about the name being in use, just do: sudo docker rm [ID of existing container from error message]

Installing the JupyterHub for teaching from scratch.

Pull the docker images we need: docker pull jupyterhub/jupyterhub docker pull jupyterhub/singleuser

Create a docker network that bridges the two images: docker network create --driver bridge jupyterhub_network

Make the folders for jupyterhub sudo mkdir -pv /data/jupyterhub sudo chown -R root /data/jupyterhub sudo chmod -R 777 /data/jupyterhub

Download the customised jupyterhub_config.py wget https://mitchell.science/jupyterhub_config.py

Copy the jupyterhub_config.py to the correct location. cp jupyterhub_config.py /data/jupyterhub/jupyterhub_config.py

Download the userlist and copy it into the correct location wget https://mitchell.science/userlist cp userlist /data/jupyterhub/userlist

Download the Dockerfiles for the singleuser (jupyter sheet) and multiuser (jupyterhub) environment. wget https://mitchell.science/Dockerfile.multi wget https://mitchell.science/Dockerfile.single

Build both the singleuser and multiuser docker images: sudo docker build -f Dockerfile.multi -t simon/jupyterhubmulti . sudo docker build -f Dockerfile.single -t simon/jupytersingleuser .

If you get permission errors on the singleuser Docker image you may need to edit Dockerfile.single to include the lines: RUN mkdir -p /home/user/jovyan RUN chown "jovyan" "/home/user/jovyan" Right before the main julia dependencies are installed

Debugging the teaching JupyterHub

You might need to remove individual student's images as they won't reflect any changes otherwise: sudo docker rm jupyter-student5 You might want to view the logs of the singleuser instance: sudo docker logs jupyter-student2 All these docker images can quickly fill the SSD so consider: sudo docker system prune

The config on JLP, and HPZ4 is different. You may have more success with these files for HPZ4:

wget https://mitchell.science/hpz4/jupyterhub_config.py wget https://mitchell.science/hpz4/Dockerfile.multi wget https://mitchell.science/hpz4/Dockerfile.single wget https://mitchell.science/hpz4/userlist

The update script is also different (for some reasons the users have different names in this version of jupyterhub!):

wget https://mitchell.science/hpz4/updateGithubs.sh

this command works: sudo docker run --rm --name jupyterhubDockerTeaching -p9001:8111 --network jupyterhub_network -v /var/run/docker.sock:/var/run/docker.sock -v /data/jupyterhub:/srv/jupyterhub simon/jupyterhubmulti:latest

If you get errors accessing user folders you need to create them:

mkdir /var/lib/docker/volumes/jupyterhub-user-student9/

then run the update script to fill it with content.

Updating the github repos in existing users

Once users have been created changes in the github won't be updated as each user's storage is cached. I have created a script that will go through each user's folder move the modelling folders to a folder called "oldFolders", and re-download the GitHub repos to get the latest changes. It can be downloaded and run as follows:

You can update individual repos with individual scripts for each session.

The process is based (loosely) on , with some modifications.

Now run the magic command, and then login to the jupyterhub at : sudo docker run --name jupyterhubDockerTeaching -p9001:8111 --network jupyterhub_network -v /var/run/docker.sock:/var/run/docker.sock -v /data/jupyterhub:/srv/jupyterhub simon/jupyterhubmulti:latest

wget chmod +x updateGithubs.sh sudo ./updateGithubs.sh

Cancer: wget chmod +x updateGithubsCancer.sh sudo ./updateGithubsCancer.sh

MD: wget chmod +x updateGithubsMD.sh sudo ./updateGithubsMD.sh

Population: wget chmod +x updateGithubsPop.sh sudo ./updateGithubsPop.sh

http://139.184.170.218:9001/
https://github.com/SiFTW/MitchellLabTeachingMD
https://github.com/SiFTW/MitchellLabTeachingCancer
https://github.com/SiFTW/MitchellLabTeachingPop
this page
http://139.184.170.218:9001/
https://mitchell.science/updateGithubs.sh
https://mitchell.science/updateGithubsCancer.sh
https://mitchell.science/updateGithubsMD.sh
https://mitchell.science/updateGithubsPop.sh