Jupyter Notebooks are an interactive code environment where live code, equations, visualisations and narrative text can be combined.
The ecocloud Platform supports Jupyter Notebooks with these languages:
- Python (installed with the SciPy packages); or
- R (statistical programming language)
Jupyter Notebooks are accessed through the JupyterLab user interface in the ecocloud Platform. JupyterLab can be used for other tasks, such as to manage files on the server’s temporary storage (see storage overview) and for writing R programs in RStudio (see using RStudio). This article only covers the use of Notebooks.
A single server can run multiple Notebooks. A single server is started to run the JupyterLab user interface and the Notebooks.
The sections below describe actions on the Jupyter server:
- Launching a Jupyter server
- Return to a running Jupyter server
- Terminating a Jupyter server
And actions that can be performed on Notebooks, once a Jupyter server is running:
- Creating a new Notebook (which also starts it running)
- Saving a Notebook to a file
- Shutting down a running Notebook (so it is not running)
- Starting up a Notebook from a file
- Closing a Notebook (and leaving it running)
- Opening a Notebook (that is already running).
- Go to the tools page ⓔ.
- Follow the link for either "R (RStudio and Jupyter)" or "Scientific Python (SciPy Jupyter)". The hub control panel will appear.
- Press the “Start My Server” button. The “Spawner Options” page will appear.
- Select either “SciPy Notebook” or “RStudio Notebook” (depending on if you want to use Python or R) and press the “Spawn” button. The JupyterLab page will appear.
Note: if you do not see the "Start My Server" button, it could be because another server is already running. Currently, a maximum of one server can be run, so you will need to terminate the running server before another can be launched. It could also be because another server is in the process of being terminated, in which case please wait a minute before trying again.
Return to server
If you have closed the browser tab showing the JupyterLab interface, you can return to it by:
- Going to the ecocloud Dashboard ⓔ.
- Press the "Open" button next to the running server.
Important: this only works if the JupyterLab interface is not already in another tab. If it is in another tab, it will bring up a dialog box asking you to "Please use a different workspace." Close all the tabs showing the JupyterLab interface and try again.
When finished with the JupyterLab server, it should be terminated so the resources it uses is freed up.
- Save your data. This is very important, since all data in the server’s temporary storage will be lost when the server is terminated.
- Check that all notebooks and scripts you want to keep are saved to your workspace storage.
- Check that all input/result data you want to keep are saved to external storage.
- From the "Hub" menu choose "Control Panel". The hub control panel will appear.
- Press the “Stop My Server” button. Wait a few seconds for the “Stop My Server” button to disappear.
- Close the browser tab containing the hub control panel.
- Close the browser tab containing JupyterLab (ignore any error dialog that has appeared on it).
Caution: save any changes to the Notebooks before terminating the server. The server does not prompt you to save any unsaved changes.
The saved version of any notebooks you have running will be automatically started the next time JypyterLab is launched. If you do not want this to happen, first shutdown the notebook before terminating the server.
From the JupyterLab page, a new Jupyter Notebook can be created by:
- In the launcher (right pane), under the “Notebook” section, press the “Environment” button. For Python, the button is called “Environment (conda_py35)”; and for R, the button is called “Environment (conda_r_r34)”. A new Jupyter Notebook will appear.
- Use the notebook. For example, enter some Python/R code (e.g. “6*7”) into the field and press the “Run” button (right pointing triangle in the toolbar).
A new notebook is automatically started. It is running and using compute cycles from your server. If you are no longer using the Notebook, you should shutdown the Notebook so those compute cycles can be used for running other Notebooks.
To save changes made to the Notebook:
- From the “File” menu choose “Save Notebook As”
- Enter the name of the Notebook file. This should be a name under the workspace folder, for example "workspace/my-notebook.ipynb".
- Press the “Save” button.
Important: The "workspace" directory should be added to the front of the file name. If that is not done, it will save it to the home directory, which is not preserved when the server is terminated (i.e. your notebook will be lost, even though it has been saved). The home directory is outside the "workspace" directory, and hence it is a part of the server's scratch storage (which is lost when the server is terminated).
A shutdown Notebook is no longer running. Note this is different from terminating the Jupyter server, which stops all running Notebooks. A Notebook can always be started up again, if you have saved it to a file.
If the Notebook is visible:
From the “File” menu, choose “Close and Shutdown Notebook”.
If the notebook is not visible:
- Clicking on the “Running” tab along the left edge of the window.
- Under the “Kernel sessions” section, press the “shutdown” button to the right of the notebook you want to shutdown.
Caution: save any changes to the Notebook before shutting down the Notebook. JupyterLab does not prompt you to save any unsaved changes.
Startup a Notebook
Runs a Notebook from a file.
- Click on the “Files” tab on the left edge of the window.
- Use the file browser (let pane) to find the notebook file.
- Double click on the notebook file. It will open in a new tab in the right pane.
When finished, save any changes and close or shutdown the notebook.
Closing a notebook hides it, so you can’t see it anymore. A closed notebook is still running on the server.
- To close the notebook, from the “File” menu choose “Close Notebook” or click on the cross in the Notebook’s tab.
- You will be prompted to confirm the shutdown operation. Press the "OK" button.
A closed Notebook is still running and using compute cycles from your server. If you are no longer using the Notebook, you should shutdown the Notebook so its compute cycles can be used for running other Notebooks.
To open a closed notebook (i.e. one that is still running):
- Click on the "Running" tab along the left edge of the window.
- Under the "Kernel sessions" section, single click on the name of the notebook.