Awesome JupyterLab Extensions

Jupyter Lab is one of the most widely used IDEs in the data science community. They are the choice of tool for many data scientists when it comes to quick prototyping and exploratory analysis. A JupyterLab neatly bundles many functionalities together, enabling collaborative, extensible, and scalable data science. However, this article is not about the various advantages of the Jupyter Lab. I believe there are a plethora of resources on that topic. Instead, the focus here will be on one of the useful components of JupyterLab called Extensions. These extensions are pretty helpful and can enhance a person’s productivity when working alone or in a team. Let’s start by understanding what an extension is, and then we’ll quickly go through some of the useful JupyterLab extensions currently available on Github.

Extensions

The JupyterLab has been designed as an extensible and modular environment. As a result, one can easily add and integrate new components into the existing environment. Extensions work on this very core idea. JupyterLab can be easily extended via third-party extensions. These extensions, written by developers from the Jupyter community, are essentially npm packages (the standard package format in Javascript development). So what makes these extensions so useful? Well, here is an excerpt from the official documentation which answers this question:

“Extensions can add items to the menu or command palette, keyboard shortcuts, or settings in the settings system. Extensions can provide an API for other extensions to use and can depend on other extensions. In fact, the whole of JupyterLab itself is simply a collection of extensions that are no more powerful or privileged than any custom extension.”

Installation

In this article, we’ll look at some of the useful extensions and how they can enhance our experience while working with the jupyter lab. But before we begin, let’s quickly look at how we can install these extensions. To install JupyterLab extensions, you need to have Node.js installed, either directly installed from the Node.js website or as follows.

conda install -c conda-forge nodejs
or# For Mac OSX users
brew install node

Once installed, it appears as a new icon in the JupyterLab sidebar.

Extension Manager

To manage the various extensions, we can use the extension manager. By default, the manager is disabled but can be enabled by clicking on the enable button.

Enable the extension manager | Image by Author

Alternatively, you can search for the Extension Manager in the command palette and enable it there also.

Enable the extension manager by searching in the command palette | Image by Author

Useful JupyterLab Extensions

Let’s now take a tour of some of the useful extensions available currently in JupyterLab. Please keep in mind that these are third party extensions and are not reviewed. Some extensions may introduce security risks or contain malicious code that runs on your machine.

You can search for the desired extension in the extension manager. While searching, you’ll notice that some of these extensions have a Jupyter icon next to their name. These extensions are released by the Jupyter organization and are always placed first.

Available Jupyter Lab extensions | Image by Author

1️⃣ . Jupyterlab Google Drive

As the name suggests, the jupyterlab-google-drive extension provides cloud storage for the JupyterLab via the google drive. Once installed, this extension adds a Google Drive file browser to the left side panel of JupyterLab. You need to be logged into your google account to access the files stored in your google drive through JupyterLab.

Installation: Through Extension Manager

You can install the extension via the extension manager. Search for the name of the extension in the search bar and install it.

Installing the jupyterlab-google-drive extension | Image by Author

You will then need to restart the environment. Once you do so, you will be greeted with the following prompt:

Prompt for JupyterLab build on installing the extension | Image by Author

Click on Build to incorporate any changes, and you’ll instantly see a google drive icon in the sidebar. Apart from installing the extension, you will also need to authenticate your JupyterLab deployment with Google. Go through the setup file or the link here for the process. Once you fill in the credentials, you’ll be able to access your drive from the jupyter lab.

Jupyterlab Google Drive Extension | Image by Author

Installation: Through Comand Line Interface

Alternatively, you can install the extension via the CLI, as follows:

#Install the jupyterlab-google-drive extension
jupyter labextension install @jupyterlab/google-drive#Set up your credentials using this guide.# Start JupyterLab
jupyter lab

Now, if someone shares a notebook or a markdown file with you, it will reflect in the shared with me folder in Jupyter Lab. You can open it and edit it in the Jupyter environment seamlessly.

2️⃣. JupyterLab GitHub

JupyterLab Github is a JupyterLab extension for accessing GitHub repositories. With this extension, you can select GitHub organizations, browse their repositories, and open the files in those repositories. If the repositories contain a jupyter notebook, you’ll be able to access them directly in your JupyterLab environment.

Installation

Again, you can install this extension either through the extension manager or through the CLI. Please be aware that this package has indicated that it needs a corresponding server extension, which you will be prompted to install before using the extension.

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

After installation, you need to get the credentials from GitHub.

Usage

Once the credentials and permissions are entered, you can access all your repositories in the JupyterLab environment without switching between different interfaces.

JupyterLab Github extension | Image by Author

3️⃣. Jupyterlab Git

Jupyterlab-git is another useful JupyterLab extension used for version control using git.

Installation

To install the extensions, you can follow perform the following steps:

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

Once installed, the Git extension can be accessed from the Git tab on the left panel

Jupyterlab-git extension | Image by Author

4️⃣. Jupyterlab-TOC

The Jupyterlab-TOC extension populates a table of contents on the left side of a JupyterLab interface. If there is a notebook or a markdown file open, its corresponding TOC will be generated on the sidebar. The entries are scrollable and clickable.

Installation

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

Usage

Once the extension is installed, you can modify some of its properties via JupyterLab’s advanced settings editor. For instance, you can collapse sections of notebooks from the ToC by setting the collapsibleNotebooks parameter as True.

Jupyterlab-TOC extension | Image by Author

5️⃣. Jupyterlab-drawio

Drawio plugin is a JupyterLab extension for standalone integration of drawio/ mxgraph into Jupyterlab. draw.io is a free online diagram software for making flowcharts, process diagrams, org charts, UML, ER, and network diagrams.

Installation

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

Usage

Jupyterlab-drawio extension | Image by Author

6️⃣. Jupyterlab-Topbar

The Jupyterlab-topbar is an extension for modifying the top bar in the JupyterLab interface. The top bar can be used to place a few useful indicators like:

Indicators on Top Bar in a Jupyter Lab environment | Image by Author

Installation

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

Usage

Once the extension is installed and enabled, you’ll see some indicators on the top bar. There will be a log-out button, dark and light theme switch, custom message, and memory indicators.

Jupyterlab-Topbar Extension | Image by Author

7️⃣. Jupyterlab Code Formatter

The Jupyterlab Code Formatter is a small plugin to support various code formatters in JupyterLab. This is one of my favorite extensions since it takes away a lot of pain from code formatting.

Installation

The first step is to install the plugin.

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

The next step would be to install the code formatters. The Jupyterlab Code Formatter currently supports the following formatters in Python and R.

The Jupyterlab Code Formatter currently supports the following formatters in Python and R. | Image by Author
# Install your favourite code formatters from the list abovepip install black isort#orconda install black isort

You can then restart the JupyterLab and configure the plugin, as mentioned here. A quick demo is shown below but for detailed usage, follow the documentation. The code for the following demo has been taken from the Github repository of the extension.

Jupyterlab Code Formatter Extension | Image by Author

8️⃣. Jupyterlab-chart-editor

The jupyterlab-chart-editor extension is used for editing the Plotly charts, based on https://github.com/plotly/react-chart-editor. The extension enables editing Plotly charts through a user-friendly point-and-click interface.

Installation

L: Installation through Extension Manager || R: Installation through Command Line Interface | Images by Author

Usage

The following example has been taken from the official documentation. A figure is first created using plotly and then written to a JSON file. The saved file is then opened using the newly installed plotly editor, and some changes are made to it right on the jupyterLab environment.

Jupyterlab-chart-editor Demo: Source — Official Documentation

Conclusion

In this article, we looked at some useful JupyterLab extensions that make the JupyterLab stand out. Having different tools in a single workplace makes it very useful since one doesn’t have to switch between different environments to get the things done. These add ons will surely make your data analysis process much smoother and more productive.


Originally published here

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s