cluster:usage_tips:jupyter

Jupyter

Jupyter is a notebook-based development platform for Python projects, widely used in machine learning projects. JuypyterHub is a service that provides Jypyter notebooks for users on a given machine. Currently, one jupyterHub server is accessible for Sleep Revolution researchers on the computing hub Dunwich.

In order to access the JupyterHub server, access the VPN, and navigate to dunwich.sleep.ru.is/jupyter. You will be greeted with a login screen where you should use your Sleep revolution credentials (without @sleep.ru.is).

JupyterHub allows each user to use their own python environments if the default ones have missing packages.

To create a new python environment we use conda, open a new terminal in jupyterhub.

The command for creating a new conda environment named myenv for example is

conda create -n myenv

Note the location of the new environment.

To be able to use the environment in jupyterhub you need to install ipykernel to the environment:

conda activate myenv
conda install ipykernel

Finally, to register the environment with jupyterhub, type the command, replacing myenv with the name of your environment, and displayname with a nice name for your environment that you can select from a dropdown list in jupyter.

You also need to replace the path to your environment with by replacing “myenv” with the name of your environment and adjusting the python version at the end of the path if necessary.

.conda/envs/myenv/bin/python3 -m ipykernel install --name 'myenv' --display-name "displayname" --user

To remove the myenv environment, the command is:

jupyter kernelspec uninstall myenv

Now you are ready to create your own Jupyter Notebook. Click the blue plus button in the main screen and select an environment, e.g. your newly created myenv.You can change the environment later by selecting a different kernel.

To install a package, examplepackage for example, to the example environment myenv that you created and added to the JupyterHub open a new python console on JupyterHub by selecting the myenv environment and executing

conda install examplepackage

After the installation, you should be able to restart the kernel, and use your new examplepackage

The path to access data from the sleep database always starts with /datasets

EXAMPLE: If the name of your data set is “examplesleepstudy” you can read an .csv file in this folder like this:

pd.read_csv("/datasets/examplesleepstudy/examplefile.csv")

In oder to explore the structure of the folder you are trying to access use the terminal to show the contents of the folder:

ls /datasets/examplesleepstudy
  • cluster/usage_tips/jupyter.txt
  • Last modified: 2023/03/16 08:48
  • by lukab