OSC provides an isolated and custom Jupyter environment for each classroom project that requires Jupyter Notebook or JupyterLab. The interface can be accessed at class.osc.edu. To set up this interface, please apply for a classroom project that is unique for the course. More details on the classroom project can be found in our classroom project guide. The custom Jupyter environment for the course will be tied to this
project ID. Please inform us if you have additional requirements for storage. Once we get the information, we will provide you a
course ID (which is commonly the course ID provided by PI + school code, e.g.
PHYS280_WIT) and add your course to the interface.
Before testing the interface, please follow the instructions below to create a Jupyter environment for the course and send us with the full path of the environment. Once we update the interface, you can login to class.osc.edu and start testing the course. After login, you will see several Apps listed. Pick Jupyter App and that will take you to the Jupyter Job submission page. Please pick your course from the drop-down menu under the Class materials and the number of hours and cores needed.
Set up a Jupyter environment for class
A Jupyter environment for class is created using Python 3 venv module, and it is shared with students. The environment created is an isolated Python environment, meaning that system Python packages and user's local packages become inaccessible when you activate this environment. It is easy for PI to manage packages dedicated for class.
Using project space
If project space is used, e.g.
/fs/ess/projectID/courseID/jupyter where you want to install Jupyter environment, no permission change is required because students would be added into the project.
Create a virtual environment
Login to Owens or Pitzer at OSC (see Getting Connected). In a terminal, assuming that the
course ID is PHYSIC6820 and
project ID is PAS1234, run the following commands to create a virtual environment in project space
~support/classroom/tools/create_class_venv --prompt "PHYSIC6820" /fs/ess/PAS1234/PHYSIC6820/jupyter
Initiate the environment
After creating the virtual environment, activate the environment:
source /fs/ess/PAS1234/PHYSIC6820/jupyter/bin/activate # use activate.csh if you are in a C shell
Then install Jupyter Notebook and python packges for class, e.g. numpy:
(PHYSIC6820)$ pip install jupyterlab jupyter-console qtconsole ipywidgets (PHYSIC6820)$ pip install numpy (PHYSIC6820)$ deactivate
deactivate is not required if you continue testing and using packages installed in the Jupyter environment.
/fs/ess/projectID/courseID/jupyter as default Jupyter environment for classroom setup. If you set up a different location, you must update us with the full path of the Jupyter environment in order to complete the interface for classroom. Once the information is recevied, we will update the interfrace, and you can login to class.osc.edu to test your Jupyter classroom.
Install more packages
PI can install more package anytime in a terminal
source /fs/ess/PAS1234/PHYSIC6820/jupyter/bin/activate # use activate.csh if you use C shell (PHYSIC6820)$ pip install pkg1 pkg2 ... (PHYSIC6820)$ deactivate
or in a Jupyter notebook
Enable PDF exporter
To export a notebook as PDF file, it needs complete Tex environment and Pandoc binary (not pandoc python package). The former is taken care of by our system module. For the latter PI needs to install pandoc in a class Jupyter environment:
%%bash cd $TMPDIR wget https://github.com/jgm/pandoc/releases/download/2.10.1/pandoc-2.10.1-linux-amd64.tar.gz tar xf pandoc-2.10.1-linux-amd64.tar.gz -C $VIRTUAL_ENV --strip=1
An extra step might be required to fix the permission issue
%%bash chmod 755 $VIRTUAL_ENV/jupyter/share/jupyter/nbconvert/templates/html
Enable local package access (optional)
By default this Jupyter environment is an isolated Python environment. Anyone launches
python from this environment can only access packages installed inside unless
PYTHONPATH is used. PI can change it by setting
include-system-site-packages = true in
/PATH/TO/JUPYTER/VENV/pyvenv.cfg. This will allows students to access packages in home directory
~/.local/lib/pythonx.x/site-packages ,and install packages via
pip install –user.
When a class session starts, we create a classroom workspace under PI's and students' home space:
$HOME/osc_classes/courseID, and launch Jupyter at the workspace. The root
/ will appear in the landing page (Files) but everything can be found in
$HOME/osc_classes/courseID on OSC clusters.
Share class material
PI can share class material from home or project space with students. For example, you have a directory called modules in project space
/fs/ess/projectID/courseID/modules (source) that contains the class material. When a student launch a Jupyter session, the diretory will be copied to the student's worksapce
$HOME/osc_classes/courseID (destinatation). The student will see the directory modules at the landing page:
PI can add files to the material source directory. New files will be copied to the destination everytime when a new Jupyter session starts.
Once you decide the location for the material, please update us with the full path of the material directory.
Access student workspace
PI and TAs can access a student's workspace with limited permissions. First, PI sends us a request with the information including PI's and TAs' OSC accounts. After a student launches a class session, you can access known files and directories in the student's workspace. For example, you cannot explore the student's workspace
ls /users/PZS1234/student1/osc_classes/courseID ls: cannot open directory /users/PZS1234/student1/osc_classes/courseID: Permission denied
but you can access a known file or directory in the workspace