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. Before using this interface, please apply for a classroom project account that is unique for the course. More details on the classroom project can be 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 and add your course to the server with the class module created using the
Before testing the module, please follow the instructions below to create a Jupyter environment for class and send us with the full path of the environment. Once we update the server, you can login to class.osc.edu to test the Jupyter environment. 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 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 switch to (activate) this environment. It is easy for PI to manage packages dedicated for class.
PI can create a Jupyter environment in either own home or project space.
Using project space (recommended)
If project space is used, e.g.
/fs/ess/projectID/courseID/jupyter, no permission change is required because students would be added into the project.
Using home space
For example, a Jupyter environment is created at
$HOME/osc_classes/courseID/jupyter. and your class project ID is
PAS1234. Then add execution permission to
$HOME and the sub-directories,
mkdir -p $HOME/osc_classes/courseID/jupyter nfs4_setfacl -a A:g:projectID@osc.edu:X $HOME nfs4_setfacl -a A:g:projectID@osc.edu:X $HOME/osc_classes
Create a virtual environment
Login to Owens or Pitzer at OSC, and in a terminal
module reset mkdir -p /PATH/TO/JUPYTER/VENV python3 -m venv --without-pip --prompt "courseID” /PATH/TO/JUPYTER/VENV
/PATH/TO/JUPYTER/VENV can be one of examples above or any place you prefer.
Initiate the environment
After createing the virtual environment, switch to (activate) it and install Jupyter and any python packages for class
source /PATH/TO/JUPYTER/VENV/bin/activate # use activate.csh if you are in a C shell (courseID)$ curl https://bootstrap.pypa.io/get-pip.py |python (courseID)$ pip install jupyterlab jupyter-console qtconsole ipywidgets (courseID)$ pip install pkg1 pkg2 ... (courseID)$ deactivate
deactivate is not required if you continue testing and using packages installed in the Jupyter environment.
Once PI complete creating the environment, please update us with the full path of the environment in order to complete the server setup.
Install more packages
PI can install more package anytime in a terminal
source /PATH/TO/JUPYTER/VENV/bin/activate # use activate.csh if you use C shell (courseID)$ pip install pkg1 pkg2 ... (courseID)$ deactivate
or in a Jupyter Notebook during the class
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 now. For the latter PI needs to install pandoc in a 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
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 at OSC.
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.