JupyterLab

Creating JupyterLab assignments

K
Written by Kevin Wesley
Updated over a week ago

Container Architecture lab types are in general release. Please contact support@vocareum.com to set up a compatible course.

Creating a JupyterLab Assignment

From the course page select "Edit Assignments".

Create a name for the assignment, choose the Jupyterlab lab type from the dropdown menu and select "Save and continue".

Adding your new lab to a new or existing group is optional

Now you have created your first Part. From this page you can access the Part Settings by selecting Part 1. You can open Configure Workspace to begin populating your lab. And Student View to emulate the student experience during development.

Configure Workspace

Select Configure Workspace to launch the instructor IDE.

Jupyter Notebook will open to the /work directory

Uploading and Creating A New Notebook

From the instructor IDE select the upload icon and select your notebook. Or select "New" to create a new notebook.

Once you have uploaded the notebook select "Deploy" to apply this change across the learner work environments.

Grading with nbgrader

Vocareum supports nbgrader for Jupyter. Details on how to generate a graded notebook here

Releasing Data

To release data sets to students simply upload a file, such as a .csv or .png, into the Jupyter workarea.

Select "Generate Notebook(s)" and you will now see an additional field for "Data Files". This will allow you to choose which files to move to the "startercode" directory and whether to make the files "read-only". Files greater than 8mb will only be available as "read-only".

Note, if you do not wish to affect rubric items or changes to the grading script carefully review and de-select any related fields.

When a file is not read-only the entire file will be placed into the startercode.

Read-only files will be moved into the data directory and rather than the files themselves being added to startercode. A symbolic link will instead be created which links to your file located in the data folder.

Installing Packages

To install packages that will be available globally, across all learner environments, instructors will need to create a new image. Enter Configure Workspace and open the terminal in your Jupyter Notebook. Install your package with the sudo command.

sudo pip3 install <package>

Instructors can install packages locally for testing. Learners can install to their local directory as well. Enter Configure Workspace and open the terminal in your Jupyter Notebook. Install package with the pip command.

pip3 install <package>

Install packages for Python 3.8:

sudo python3.8 -m pip install <package>

(see Changing the Kernel Version for installing Python 3.8)

Install Julia packages globally

sudo su
export JULIA_DEPOT_PATH="/opt/julia"
julia -e "using Pkg; Pkg.add([\"Combinatorics\", \"LightGraphs\"])"

To make the new packages available in learner environments select Save Image.

From the "Save Container Image" window give the new image a name. You can choose to have the the current running image replaced and container restarted. When you are done with your selections press "Save".

The package is now available for all learners.

If you do not choose to replace the current image at the time, you will need to return to the Lab Definition menu in the Part settings and adjust the lab type to select the newly created image. Select 'Save Part'.

Changing the Kernel Version

Jupyterlab containers come with Python 3.10 installed. If your coursework requires a notebook to run on a different version of Python you will need to run the following script in the Jupyterlab terminal:

sudo su
apt-get update
apt-get -y install python3-pip
python3.8 -m pip install ipykernel
python3.8 -m ipykernel install --name=Python3.8
mv /usr/local/share/jupyter/kernels/python3.8 /usr/local/venvs/jupyter/share/jupyter/kernels/

In this example we are using Python3.8

It may take a couple minutes to render but you will now be able to change the Kernel from the Jupyter tool bar.

Jupyter Container File System

While configuring the container, there is a file system mounted in the container. These files are not a part of the docker image. The purpose of these files are multifold -

  • /course - This directory is common to the entire course and is available only to the grading script.

  • /data - Place data here to make it available to the learners. For large data sets, it is a more efficient way to deliver data than make it a part of the image or copy to startercode. Every lab gets access to a readonly copy of the data.

  • /docs - If there is a README.md, README.html, README.txt or README.pdf file present in this directory it will be showed to the user in a panel on the right side of the learner interface.

  • /private - Place necessary course content or data that does not need to be seen by the learner.

  • /scripts - This directory is not visible to the learner. It can hold the scripts and any related files that might be required for executing the script.

  • /startercode - Initializes the student environment. All the content of this directory is copied to /home/labsuser directory when the learner launches the lab.

  • /work - This directory can be used to develop and test coursework, starter code, scripts, etc. Can also be used for creating quiz.md before running "Generate Quiz" operation.

Did this answer your question?