Skip to content
A demonstration repository showing how to open JupyterLab with a custom layout on mybinder.org
Jupyter Notebook Shell
Branch: master
Clone or download
Latest commit c027442 Jul 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.jupyter/lab/user-settings/@jupyterlab/apputils-extension Delete unused file. Feb 15, 2019
binder Update to release. Jul 7, 2019
README.md Updates for JupyterLab 1.0 Jun 21, 2019
demo.ipynb Initial work on a workspaces demo repository. Jan 28, 2019

README.md

Example of launching binder with a custom JupyterLab layout

Binder

We would like to be able to launch JupyterLab from a binder deployment with a specific layout. For instance, the repository authors may want to open a particular file or notebook, or they may want to display a custom widget, or pull up some helpful documentation. That way, when the user or student opens the binder, they immediately are shown the most useful information.

JupyterLab provides functionality to store layouts as JSON files on disk which allow for state restoration. These layout files (called workspaces) can be specified via URL, and can be used to specify demo layouts. This repository is a demonstration of how to use that functionality.

Making a workspace

The easiest way to make a workspace is to launch JupyterLab and arrange the application in the layout you prefer. Once you have your layout, open a terminal and enter

mkdir binder
jupyter lab workspaces export > binder/workspace.json

This will store your workspace in a new file called workspace.json. You will distribute this file along with your binder repository.

Configuring binder to use the workspace

Just putting the workspace file in your repository is not enough. At binder launch time, you must import that workspace, and then load JupyterLab with it.

There is a corresponding import command for exactly this use case.

In our binder postBuild script, we enter the following:

#!/bin/bash

# Import the workspace into JupyterLab
jupyter lab workspaces import binder/workspace.json

The first line specifies that we are using bash to execute the script. The second performs the import of the workspace file.

In some cases you may want to edit a workspace to insert values that are not available at the time of the image build. If that is the case, you can also perform the workspace import in a binder start script.

Custom settings

Like workspaces, JupyterLab settings are stored on the server in JSON files. You can also distribute these with your repository. The default location for setting files is in ~/.jupyter/lab/user-settings. For instance, this repository includes a setting file that sets a dark theme for the application:

{
    "theme": "JupyterLab Dark"
}

In this case, all that is required is to place the setting files in the right directory.

Deployment

At this point, you just need to push your repository to the remote, and open binder with a default URL pointing to JupyterLab.

This demo used the default workspace (which is shown when you navigate to /lab), but it is also possible to import to named workspaces, which may be useful if your repository wants to use several different layouts.

You can’t perform that action at this time.