๐Ÿ’ก JupyterLite, Emscripten-forge, Xeus, and Mamba

The computational quartet for in browser interactive computing

๐Ÿ—ผ PyData Paris 2024

๐Ÿ“… 2024-09-25

  • ๐Ÿ‘ค Jeremy Tuloup
  • ๐Ÿ‘ค Ian Thomas
  • ๐Ÿ‘ค Thorsten Beier

About

  • ๐Ÿ‘ค Jeremy Tuloup
  • ๐Ÿ‘ค Ian Thomas
  • ๐Ÿ‘ค Thorsten Beier
  • ๐Ÿง‘โ€๐Ÿš€ QuantStack

What is JupyterLite?

JupyterLite is a JupyterLab distribution that runs entirely in the web browser, backed by in-browser language kernels.

"Normal Jupyter"

center

JupyterLite

center

Lightweight Jupyter Frontend running in the browser

center

  • โœ… no Python server
  • โœ… no command line
  • โœ… no need to install Python and other packages on the user machine
  • โœ… can be hosted as a static website

Boots in seconds

center

The jupyter-lite CLI is a Static Site Generator (SSG)

# install the CLI
pip install jupyterlite-core

# build the website
jupyter lite build

It generates static assets that can be served easily

โ”œโ”€โ”€ api
โ”‚ย ย  โ””โ”€โ”€ translations
โ”‚ย ย      โ”œโ”€โ”€ all.json
โ”‚ย ย      โ””โ”€โ”€ en.json
โ”œโ”€โ”€ bootstrap.js
โ”œโ”€โ”€ build
โ”‚ย ย  โ”œโ”€โ”€ 9507.1e6cc5d.js
โ”‚ย ย  โ”œโ”€โ”€ 9602.62bf0f1.js
โ”‚ย ย  โ”œโ”€โ”€ 9621.e2e8b5d.js
โ”‚ย ย  โ”œโ”€โ”€ ...
โ”‚ย ย  โ”œโ”€โ”€ repl
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ bundle.js
โ”‚ย ย  โ”œโ”€โ”€ retro
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ bundle.js
โ”‚ย ย  โ”œโ”€โ”€ schemas
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ all.json
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ @jupyterlab
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ application-extension
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ commands.json
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ context-menu.json
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ shell.json
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ sidebar.json
โ”‚ย ย  โ”œโ”€โ”€ themes
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ @jupyterlab
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ theme-dark-extension
โ”‚ย ย  โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ index.css
โ”‚ย ย  โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ index.js
...
...
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ theme-light-extension
โ”‚ย ย  โ”‚ย ย          โ”œโ”€โ”€ index.css
โ”‚ย ย  โ”‚ย ย          โ””โ”€โ”€ index.js
โ”œโ”€โ”€ config-utils.js
โ”œโ”€โ”€ extensions
โ”‚ย ย      โ””โ”€โ”€ xeus-python-kernel
โ”‚ย ย          โ””โ”€โ”€ static
โ”‚ย ย              โ”œโ”€โ”€ numpy-1.24.2-py310h6d2fff6_0.0.data
โ”‚ย ย              โ”œโ”€โ”€ numpy-1.24.2-py310h6d2fff6_0.0.js
โ”‚ย ย              โ”œโ”€โ”€ python-3.10.2-h_hash_26_cpython.0.data
โ”‚ย ย              โ”œโ”€โ”€ python-3.10.2-h_hash_26_cpython.0.js
โ”‚ย ย              โ”œโ”€โ”€ python_data.js
โ”‚ย ย              โ”œโ”€โ”€ remoteEntry.35b4eac217ec6bf078a4.js
โ”œโ”€โ”€ lab
โ”‚ย ย  โ”œโ”€โ”€ favicon.ico
โ”‚ย ย  โ”œโ”€โ”€ index.html
โ”‚ย ย  โ”œโ”€โ”€ jupyter-lite.ipynb
โ”‚ย ย  โ”œโ”€โ”€ jupyter-lite.json
โ”‚ย ย  โ”œโ”€โ”€ package.json
โ”‚ย ย  โ”œโ”€โ”€ tree
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ index.html
โ”‚ย ย  โ””โ”€โ”€ workspaces
โ”‚ย ย      โ””โ”€โ”€ index.html
...

Easy to deploy

Served via well-cacheable, static HTTP(S) on most static web hosts

center
center
center

center
center
center

Standing on the shoulders of giants

  • Built from the ground-up using JupyterLab components and extensions
  • The frontend communicates to the in-browser kernels via the Jupyter Protocol

Wasm powered Jupyter running in the browser

center

๐Ÿ’ก Interactive Computing in the browser

  • Python kernels:
    • Pyodide
    • Xeus Python
  • Visualizations:
    • matplotlib
    • ipywidgets
    • plotly
    • and more...

๐Ÿš€ Embed a live Python console on your website

center

Embed with:

<iframe
  src="https://jupyterlite.github.io/demo/repl/index.html?kernel=python&toolbar=1"
  width="100%"
  height="500px"
>
</iframe>

Or even the full JupyterLab UI

numpy.org

center

sympy.org

center

jupyterlite-sphinx

center

๐Ÿš€ Deploy your own on GitHub Pages

Quickstart: https://github.com/jupyterlite/xeus-python-demo

center

Deploy static web applications with Voici

center

๐Ÿ–ผ๏ธ Voici Gallery

center

๐Ÿ’ช Strengths

  • Easy to deploy and scale (static files)
  • Interactive computing in the browser accessible to more people
  • Simpler for users (no need to install Python and other packages locally)
  • Educational use cases
  • Reproducibility time capsule

center

๐Ÿงช Current developments

  • In-browser terminal
  • AI code completions and chat
  • Real Time Collaboration via WebRTC
  • Emscripten Forge and Conda Forge

โœจ AI code completions and chat

๐Ÿ‘ฅ Real Time Collaboration

Terminal

JupyterLab

  • Terminal connects to a real shell running on the server

JupyterLite

  • Now has experimental support for a Terminal running in the browser
  • Early stage work in progress

The quartet of tools

JupyterLite

  • The browser application

Emscripten-forge

  • Recipes
  • Building and uploading packages

Xeus

  • Programming language kernels

Mamba

  • Package manager
  • Resolving and installing packages

What is a kernel?

center

JupyterLite kernels: pyodide and xeus

center

Python kernel differences

ย  pyodide xeus
Build and package system pip-based conda-based
Install packages at runtime โœ… %pip install ipympl โŒ
Supports pre-installed packages โŒ โœ…
Supports time.sleep โŒ โœ…

๐Ÿ”จ Emscripten-forge and mamba

Building WebAssembly packages

platform pip-based toolchain conda-based toolchain
noarch, linux, macos, windows PyPI conda-forge
emscripten-wasm32 pyodide emscripten-forge

How do I use package 'x' in JupyterLite?

Create a JupyterLite deployment

Local deployment with both python kernels

build-environment.yml:

name: jlite-build
channels:
  - conda-forge
dependencies:
  - python
  - jupyter_server
  - jupyterlite-core
  - jupyterlite-pyodide-kernel
  - jupyterlite-xeus

environment.yml:

name: jlite-demo
channels:
  - https://repo.mamba.pm/emscripten-forge
  - conda-forge
dependencies:
  - xeus-python
  - ipympl
  - matplotlib

Sequence of commands:

micromamba create -f build-environment.yml
micromamba activate jlite-build
jupyter lite build --contents contents
jupyter lite serve

Summary of improvements in the last year

  • More stable and easy-to-use build system in Emscripten-forge rattler-build
  • Experimental Terminal in JupyterLite

Roadmap

  • R kernel
  • Proposal to move emscripten-forge to conda-forge
  • Xeus kernel install packages at runtime

๐Ÿ™ Thanks!

Thanks to all the contributors of JupyterLite, Pyodide, Emscripten Forge, and the Jupyter Community!