• Stars
    star
    443
  • Rank 98,504 (Top 2 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JupyterLab Extensions by Examples

JupyterLab Extensions by Examples

Github Actions Status Binder

  1. Goal
  2. Develop by Examples
    1. CodeMirror extension
    2. Commands
    3. Command Palette
    4. Completer
    5. Main Widget Content Header
    6. Context Menu
    7. Custom Log Console
    8. Datagrid
    9. Collaborative Document
    10. Hello World
    11. Kernel Messaging
    12. Kernel Output
    13. Launcher
    14. Log Messages
    15. Main Menu
    16. Metadata Form
    17. MIME Renderer
    18. Notifications
    19. React Widget
    20. Server Hello World
    21. Settings
    22. Signals
    23. State
    24. Toolbar Item
    25. Widgets
  3. Prerequisites
  4. Develop and Use the Examples
  5. Test the Examples
  6. Install a Published Extension
  7. About JupyterLab
  8. Credits
  9. Community Guidelines and Code of Conduct

TL;DR

The goal of this repository is to show how to develop extensions for JupyterLab, presented as short tutorial series.

To get started:

# clone the repository
git clone https://github.com/jupyterlab/extension-examples.git jupyterlab-extension-examples

# go to the extension examples folder
cd jupyterlab-extension-examples

# create a new environment
conda env create

# activate the environment
conda activate jupyterlab-extension-examples

# go to the hello world example
cd hello-world

# Required to deal with Yarn 3 workspace rules
touch yarn.lock

# install the extension in editable mode
python -m pip install -e .

# install your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite

# build the TypeScript source after making changes
jlpm run build

# start JupyterLab
jupyter lab

The examples currently target JupyterLab 4.0 or later.

If you would like to use the examples with JupyterLab 3.x, check out the 3.x branch.

If you would like to use the examples with JupyterLab 2.x, check out the 2.x branch.

If you would like to use the examples with JupyterLab 1.x, check out the 1.x branch.

Note that the 1.x, 2.x and 3.x branches are not updated anymore.

Develop by Examples

You may find it easier to learn how to create extensions by examples, instead of going through the documentation.

Start with the Hello World and then jump to the topic you are interested in.

You can expect from each example:

  • An explanation of its functionality.
  • An image or screencast showing its usage.
  • The list of used JupyterLab API and Extension Points.
  • Explanations of the internal working, illustrated with code snippets.

We have structured the examples based on the extension points. Browse the previews below or skip them and jump directly to the sections for developers.

You are welcome to open any issue or pull request.

CodeMirror extension

Add a configurable CodeMirror extension.

CodeMirror extension

Commands

Extend the main app with a Command.

Command example

Command Palette

Register commands in the Command Palette.

Command Palette

Completer

Customize tab autocomplete data sources.

Completer

Main Widget Content Header

Put widgets at the top of a main JupyterLab area widget.

contentHeader

Context Menu

Add a new button to an existent context menu.

Context Menu

Custom Log Console

Create a new log console.

Custom Log Console

Datagrid

Display a Datagrid as a Lumino Widget.

Datagrid

Collaborative Document

Create new documents and make them collaborative.

Documents

Hello World

Set up the development environment and print to the console.

Hello World

Kernel Messaging

Interact with a kernel from an extension.

Kernel Messages

Kernel Output

Render kernel messages in an OutputArea.

OutputArea class

Launcher

Start your extension from the Launcher.

Launcher

Log Messages

Send a log message to the log console.

Log Messages

Main Menu

Add a Menu to the main app.

Main Menu

Metadata Form

Add user interface to edit cell or notebook metadata.

Metadata Form

MIME Renderer

Add a MIME renderer for mp4 content to the application.

MIME Renderer

Notifications

Emit notifications.

Notifications

React Widget

Create a React.js Widget in JupyterLab.

react-widget

Server Hello World

Create a minimal extension with backend (i.e. server) and frontend parts.

Server Hello World

Settings

Create and use new Settings for your extension.

Settings

Signals

Use Signals to allow Widgets communicate with each others.

Button with Signal

State

Use State persistence in an extension.

State

Toolbar Item

Add a new button to the notebook toolbar.

Toolbar button

Widgets

Add a new Widget element to the main window.

Custom Tab

Prerequisites

Writing an extension requires basic knowledge of JavaScript, Typescript and potentially Python.

Don't be scared of Typescript, even if you never coded in TypeScript before you touch JupyterLab you may find it easier to understand than pure JavaScript if you have a basic understanding of object oriented programming and types.

These examples are developed and tested on top of JupyterLab. You can create a conda environment to get started after cloning this repository.

conda env create && \
  conda activate jupyterlab-extension-examples

The previous command will use the environment.yml file as requirements for the environment.

Develop and Use the Examples

Build and Install all Examples at once

jlpm
jlpm build-ext
jlpm install-py
jlpm install-ext
jupyter lab

To rebuild all the extensions:

jlpm build-ext

To clean the lib folders:

jlpm clean-ext

Build and Install one Example

Go to the example directory you want to install, e.g. cd ./hello-world, and run the following commands:

touch yarn.lock
pip install -e .
jupyter labextension develop . --overwrite

Rebuild the extension:

jlpm run build

You can now start JupyterLab and check if your extension is working fine:

jupyter lab

Change the Sources

If you want to develop and iterate on the code, you will need to open 2 terminals.

In terminal 1, go to the extension folder and run the following:

jlpm watch

Then in terminal 2, start JupyterLab:

jupyter lab

From there, you can change your extension source code, it will be recompiled, and you can refresh your browser to see your changes.

We are using embedme to embed code snippets into the markdown READMEs. If you make changes to the source code, ensure you update the README and run jlpm embedme from the root of the repository to regenerate the READMEs.

Update extension template

Execute from the example root folder:

./scripts/update-template.sh

Then fix the conflicts.

Test the Examples

The examples are automatically tested for:

  • Homogeneous configuration:
    Configuration files are compared to the reference ones of the hello-world example
  • TypeScript code lint
  • Installation in JupyterLab:
    The installation is checked by listing the installed extension and running JupyterLab with the helper python -m jupyterlab.browser_check
  • Integration test:
    Those tests are emulating user action in JupyterLab to check the extension is behaving as expected.
    The tests are defined in the ui-tests subfolder within each example. This is possible thanks to a tool called playwright.

Install a Published Extension

Once your extension is published on pypi.org (outside of this scope), you can install it with the following command:

pip install <published_extension>

About JupyterLab

JupyterLab can be used as a platform to combine existing data-science components into a new powerful application that can be deployed remotely to many users. Some of the higher level components that can be used are text editors, terminals, notebooks, interactive widgets, filebrowser, renderers for different file formats that provide access to an enormous ecosystem of libraries from different languages.

Complementary to these examples, you can rely on the official JupyterLab documentation.

Credits

We would like to thank MMesch for initiating this work, as well as everyone else who contributed!

Community Guidelines and Code of Conduct

This examples repository is a Jupyter project and follows the Jupyter Community Guides and Code of Conduct.

More Repositories

1

jupyterlab

JupyterLab computational environment.
TypeScript
14,050
star
2

jupyterlab-desktop

JupyterLab desktop application, based on Electron.
TypeScript
3,616
star
3

jupyter-ai

A generative AI extension for JupyterLab
Python
3,132
star
4

jupyterlab-git

A Git extension for JupyterLab
TypeScript
1,453
star
5

jupyterlab-toc

Table of Contents extension for JupyterLab
TypeScript
726
star
6

jupyterlab-latex

JupyterLab extension for live editing of LaTeX documents
TypeScript
626
star
7

lumino

Lumino is a library for building interactive web applications
TypeScript
612
star
8

debugger

A visual debugger for Jupyter notebooks, consoles, and source files
TypeScript
562
star
9

jupyter-renderers

Renderers and renderer extensions for JupyterLab
HTML
488
star
10

jupyterlab-github

GitHub integration for JupyterLab
TypeScript
412
star
11

jupyterlab-google-drive

Cloud storage for JupyterLab using Google Drive
TypeScript
400
star
12

retrolab

JupyterLab distribution with a retro look and feel πŸŒ…
Jupyter Notebook
282
star
13

jupyterlab-monaco

A JupyterLab extension providing the Monaco editor
TypeScript
237
star
14

jupyterlab-demo

Demonstrations of JupyterLab
Jupyter Notebook
184
star
15

extension-cookiecutter-ts

A cookiecutter recipe for JupyterLab extensions in Typescript
CSS
179
star
16

jupyterlab-data-explorer

First class datasets in JupyterLab
TypeScript
178
star
17

jupyter-collaboration

A Jupyter Server Extension Providing Support for Y Documents
Jupyter Notebook
163
star
18

jupyterlab_server

A set of server components for JupyterLab and JupyterLab like applications
Python
139
star
19

jupyterlab-hdf5

Open and explore HDF5 files in JupyterLab. Can handle very large (TB) sized files, and datasets of any dimensionality
Jupyter Notebook
115
star
20

jupyterlab-celltags

A JupyterLab extension for notebook cell tags
TypeScript
113
star
21

jupyterlab-commenting

Commenting and annotation for JupyterLab
Jupyter Notebook
101
star
22

language-packs

Language packs for JupyterLab ecosystem
Python
78
star
23

scipy2018-jupyterlab-tutorial

Tutorial material and instruction for scipy 2018 jupyterlab tutorial
Jupyter Notebook
73
star
24

frontends-team-compass

A repository for team interaction, syncing, and handling meeting notes across the JupyterLab ecosystem.
58
star
25

extension-cookiecutter-js

A cookiecutter recipe for building JupyterLab extensions.
Python
55
star
26

jupyterlab-shortcutui

A JupyterLab extension for managing keyboard shortcuts
TypeScript
54
star
27

scipy2019-jupyterlab-tutorial

Scipy 2019 JupyterLab tutorial
Jupyter Notebook
51
star
28

extension-template

A `copier` template for JupyterLab extensions
Jinja
51
star
29

jupyterlab-statusbar

A status bar for JupyterLab
TypeScript
49
star
30

theme-cookiecutter

A cookiecutter template to help you make new JupyterLab theme extensions
CSS
49
star
31

jupyterlab-plugin-playground

A dynamic extension loader for JupyterLab
TypeScript
47
star
32

jupyterlab_pygments

Pygments theme making use of JupyterLab CSS variables
Python
39
star
33

hatch-jupyter-builder

A hatch plugin to help build Jupyter packages
Python
38
star
34

pull-requests

A JupyterLab extension for reviewing GitHub pull requests
Python
37
star
35

jupyterlab_xkcd

Random xkcd comic in a JupyterLab panel
TypeScript
31
star
36

galata

JupyterLab UI Testing Framework
JavaScript
30
star
37

jupyterlab-metadata-service

Linked data exploration in JupyterLab.
TypeScript
29
star
38

jupyterlab-telemetry

A JupyterLab extension for logging and telemetry of usage data
TypeScript
29
star
39

jupyterlab_apod

JupyterLab extension tutorial answer key. Please see the tutorial at https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html
TypeScript
23
star
40

jupytercon-jupyterlab-tutorial

JupyterCon 2018 JupyterLab tutorial
Jupyter Notebook
22
star
41

mimerender-cookiecutter-ts

Cookie cutter for JupyterLab mimerenderer extensions using TypeScript
Python
19
star
42

pytest-check-links

pytest plugin that checks URLs
Python
17
star
43

jupyterlab-mp4

Example mimerenderer extension for showing mp4 videos.
TypeScript
17
star
44

mimerender-cookiecutter

A cookiecutter for rendering MIME type based output
Python
15
star
45

jupyter-chat

An extension to add a chat panel to JupyterLab
TypeScript
14
star
46

ui-profiler

Extension for profiling performance of JupyterLab UI for JupyterLab core developers, extension developers, and advanced users.
TypeScript
13
star
47

benchmarks

Benchmarking tools for JupyterLab
Jupyter Notebook
12
star
48

maintainer-tools

Workflows and Actions meant to be used by other repositories to make repo maintenance easier
Python
11
star
49

runall-extension

Add a "Run All Cells" toolbar button, context menu item, and keyboard shortcut.
TypeScript
8
star
50

jupyterlab-media

Repository storing movies and other media for JupyterLab tutorials and documentation
8
star
51

vscode-config-template

A copier template for creating the IDE config needed to debug the Python and Typescript code in any Jupyter project
Dockerfile
8
star
52

jupytercon-jupyterlab-training

JupyterCon 2018 JupyterLab Training
7
star
53

jupyterlab-translate

JupyterLab Language pack helper
Python
7
star
54

richoutput-js

Experimental investigation into a rendermime for es6 modules rendering rich output
Jupyter Notebook
7
star
55

jupyterlab-module-federation

Experimental playground for a JupyterLab extension system based on Module Federation
Python
5
star
56

jupyterlab-bot

JupyterLab Bot
Python
5
star
57

jupyterlab-probot

A probot for JupyterLab development
TypeScript
3
star
58

language-pack-cookiecutter

Template for Jupyterlab Language packs
Jinja
3
star
59

ux-research

3
star
60

.github

Community health files for the @JupyterLab organization
1
star
61

jupyter-builder

Build tools for JupyterLab (and remixes)
Python
1
star