This presentation aims to demonstrate how to use a Jupyter instance deployed inside a SlapOS Theia.
This tutorial assumes you have access to a Theia Runner inside which a Jupyter has been deployed.
Open a Theia terminal ( Menu > Terminal > New Terminal ) and type:
slapos service list
slapos service info <instance name>
In this example we upload a screenshot image to Jupyter, but this may also be used to upload any kind of file, for example a zipped directory.
The files in Jupyter (whether files uploaded to Jupyter or notebooks created by Jupter) can be accessed directly from Theia.
The first step is to find the directory reserved for the Jupyter instance: probably ~/srv/runner/slappart0, but if the Theia Runner contains several instances it could also be in slappart1, slappart2, ...
In order to be sure you can type: slapos node status and see in which slappart the Jupyter service is running.
slapos node status
The Jupyter files are then located in the var/notebooks subdirectory: ~/srv/runner/slappart0/var/notebooks.
You can either use a terminal or the Theia file explorer on the right to expand runner > instance > slappart0 > var > notebooks and open the files with the graphical interface.
runner > instance > slappart0 > var > notebooks
For instance, if you've uploaded a zipped file to Jupyter, you can go to this location in the terminal and unzip it with the command line.
If you have special Python library requirements, you might want to create a Python virtual environment and install your own packages.
> # create a virtual environment called myenv (creates a myenv folder in the current directory)
> python -m venv myenv
> # go to the myenv directory
> cd myenv
> # activate the environment
> source bin/activate
(myenv) > # when the environment is activated:
(myenv) > # - the prompt starts with (myenv)
(myenv) > # - you can install your dependencies locally with: pip install ...
(myenv) > # - the `python` command now refers to the virtual environment's python interpreter
(myenv) > # - this `python` has all your installed dependencies available
(myenv) > # you can deactivate and reactivate the environment at will
(myenv) > deactivate
Once you have your own Python environment, you can add it a new Jupyter kernel and use it from Jupyter:
> # go to your environment directory and activate your virtual environment
> source bin/activate
(myenv) > # install ipykernel
(myenv) > pip install ipykernel
(myenv) > # add this Python virtual environment as a Jupyter kernel called mykernel
(myenv) > python -m ipykernel install --user --name=mykernel
You may need to reload the Jupyter page before your new kernel appears in the list.