Remote JupyterLab
On this page
Visual Studio Code is one of the best source code editors. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.
You can run Visual Studio Code in your local computer and connect to a remote Jupyter Kernel running in the server.
All the computation and data access will be then performed remotely while you write your notebooks in your computer.
Requirements
You need your unique JupyterLab access token. This is available in your Profile page. Keep this token safe, consider it as a password to access your Jupyter.
Set Up
Visual Studio Code supports connecting to a remote notebook server, and we can use that to connect to our JupyterHub.
Open a local Jupyter notebook (a file with a .ipynb extension) and click on Select Kernel at the top right of the window:

In the new menu select Existing Jupyter server...

Then enter the address of your Jupyter server as:
https://darkroom.ast.cam.ac.uk/user/<username>/<server-name>/?token=<token>
If the connection is succesful you will then be able to select the remote kernel to use to run your notebook:

The kernel for your notebook should now live on your JupyterHub! You can verify this by running !hostname, which should return the hostname of your remote JupyterHub server instead of your local hostname. You can also try importing libraries that are in the remote JupyterHub server, but not your local file system.
Limitations
- Your JupyterHub notebook server must be running already when you try to open your notebook — Visual Studio Code will not automatically start it. If it has stopped, you need to log in to your JupyterHub & start it again.
- Watch out for filesystem access. When you are calling open() (or a helper function that eventually access a file) to read a file, it is going to be read from your remote JupyterHub server’s home directory, not your local system’s current directory. So if you add a new file next to your Jupyter Notebook locally, that is not automatically going to be available to the Jupyter Notebook to read.
- Installing pip or conda packages locally will have no effect, since your Python kernel is running on your JupyterHub. Use the %pip or %conda magics to install packages in the correct environment.