Launch a Jupyter Notebook from VM

Nick Updated by Nick

Launch a Jupyter Notebook from a VM

Recording of meeting with Max at Codio:

  1. In the Codio Course settings, go to Virtual Machine in the side navigation and toggle on Enable Virtual Machine, set the OS to Ubuntu, the Memory to 16GB, 8 vCPU, and the Stack to eCornell Jupyter sample VM.
  2. Open the unit you want to convert to VM-based and create a startup.sh file in the .guides directory.
Note: You could also create the startup.sh in the /home/codio/ directory so that it can be stored on the stack if that is preferable. However if the Jupyter Notebook name is different per unit (which it usually is), then /.guides as the directory is better as the files to be synced via codio-vm commands in startup.sh would vary per unit
  1. Add the following to the startup.sh file, replacing the {filename} with the actual filename of the file you want to sync to the VM. Add a line like that for each file you want to sync, or place all files you want in a folder and sync that.
# Forward the portcodio-vm 
port-forwarding 3000 3000

# Sync resources to VM - ADD A LINE FOR EVERY FILE YOU WANT TO SYNC
# OR PLACE THEM ALL IN A SHARED FOLDER
codio-vm sync /home/codio/workspace/{filename}.ipynb /home/ubuntu/workspace/{fileName}.ipynb
  1. Restart the Codio box via Project > Restart Box... and then run ps ax in the terminal to verify that the codio-vm sync processes are now running automatically since the box was restarted. If they aren't, you may need to reinstall Autostart Support on the box and update the stack, or troubleshoot further.
    1. To install/reinstall Autostart Support in Codio, go to Tools > Install Software and search for Autostart Support. Click the blue download button to the right and Codio will run the install commands.
  2. Try opening the .ipynb file you have synced to the VM and verify that it loads on the VM. You might see a message stating "VM starting, please wait" before the notebook loads up. This denotes the VM is starting up. It might take a few moments to spin up, however.
  3. Try logging in as a test student and verify that the JN autoloads on the VM on start. To the upper-right hand corner of the notebook, you should see "JupyterLab" and "Python 3 (ipykernel)". This denotes the VM is running.

Update the VM Image

After adding/removing or updating a file in the VM workspace, or installing/removing or updating any software on the VM stack, you will need to update the VM image by going to Tools > Virtual Machine > Publish.

After that, you will be prompted to add a new, unique stack name along with a description of the changes made to the image.

VM Stacks are not versioned like normal Codio stacks, so each time you make a new VM stack it exists as a totally separate stack that needs to be selected. For this reason, if you make changes to the VM stack, you also need to switch the VM to use this new stack in the course-level VM settings under Admin > Virtual Machine > Virtual Machine Options > Stack. Just publishing a new VM stack will not automatically switch the course to use that new stack, you must also change it in this settings area for this change to take effect. More information on this process is available in the Codio docs here: https://docs.codio.com/instructors/setupcourses/virtualmachine.html#setting-up-the-assignment-s 

Important: If you are using a VM for a particular Codio unit, make sure you have the unit settings for Gigabox Slot set to Standard. This is because if we use a higher powered gigabox slot yet deliver the content through a VM, we are still being charged for the access to that gigabox slot despite it not being directly utilized.

Resetting a Student VM in Codio

This document briefly describes how to reset a student virtual machine (VM) in Codio.

The example section below uses Jupyter Notebook, but steps 1-6 should be applicable to any Codio unit running a VM.

Quick Overview

Resetting a student’s virtual machine (VM) will revert it back to the state of the VM stack that is currently specified in the course’s ADMIN > Virtual Machine > Virtual Machine Options > STACK setting when the VM is reset (steps shown in next section). Here is an example of the Virtual Machine Options:

Resetting a student’s VM will NOT erase the work a student has saved in their notebook because saved changes on the VM are synchronized with the .ipynb file on the Codio container. One reason you might want to reset a student’s VM is if the VM stack has been changed since the student first opened their VM and you want that student’s VM to have the current VM stack that is specified in Virtual Machine Options. Since each student has a single VM for the whole Codio course (and not individual Codio units), you only need to reset a student VM in one of their projects in order for the reset to take effect in all the Codio units.

Steps to Reset a Student VM

To reset a student VM in Codio, follow these steps:

  1. Click the three-vertical-dots menu for a student’s project and select Open the project
  2. Go to the Codio menu and select Tools > Virtual Machine > Terminal
  3. When the VM Terminal is ready, click Reset VM in the top-left corner of the terminal window
  4. Enter a confirmation code to initiate the process of resetting the VM
  5. Wait for the VM to reset (this could take several minutes)
  6. When the VM has returned to a ready state, close the VM Terminal tab
  7. If you see an “Error Starting Kernel” message in Jupyter, click OK and reload your browser window
  8. Wait for the Jupyter kernel to restart
  9. Close the student project by closing your browser window

Configuring NBGrader Autograders within VM (TBD)

How did we do?

Configuring Partial Point Autograders in Codio

Contact