Créer des sites web Jupyter interactifs avec JupyterLite

AlpOSS 2024

Jérémy Tuloup

https://jtp.io/alposs-2024

@jtpio @QuantStack

Jérémy Tuloup

  • Directeur Technique à QuantStack
  • Jupyter Distinguished Contributor
  • Jupyter Frontends SSC (Steering Software Council) representative
  • Contributeur à de nombreux projets Jupyter
  • Créateur de JupyterLite
@jtpio @QuantStack

Historique rapide de Jupyter

@jtpio @QuantStack

IPython dans le terminal

fit

@jtpio @QuantStack

REPL: Read Eval Print Loop

@jtpio @QuantStack

Pourquoi les notebooks sont populaires ?

  • Le workflow REPL
  • Avec en plus:
    • narration
    • mémoire
    • reproductibilité
    • communication
@jtpio @QuantStack

IPython Notebook

fit

@jtpio @QuantStack

Jupyter Notebook

fit

@jtpio @QuantStack

JupyterLab

fit

@jtpio @QuantStack

LIGO

@jtpio @QuantStack

Black Hole M87

@jtpio @QuantStack

L'écosystème Jupyter est très vaste

@jtpio @QuantStack
@jtpio @QuantStack
@jtpio @QuantStack

JupyterLite

  • Tout tourne dans le navigateur web via WebAssembly
  • Se base sur la stack Jupyter existante:
    • Les noyaux Pyodide et Xeus exécutent le code dans le navigateur
    • Interfaces web JupyterLab et Jupyter Notebook
    • Voici pour faire des applications web et dashboards
@jtpio @QuantStack

Jupyter

center

@jtpio @QuantStack

JupyterLite

center

@jtpio @QuantStack
@jtpio @QuantStack
@jtpio @QuantStack

Jupyter et Python dans le navigateur

center

  • ✅ pas de serveur Python
  • ✅ pas de ligne de commande pour les utilisateurs
  • ✅ pas besoin d'installer Python et autres paquets
  • ✅ peut être hébergé comme site statique
@jtpio @QuantStack

Un site Jupyter accessible en quelques secondes

center

@jtpio @QuantStack

Générateur de site statique

pip install jupyterlite-core

jupyter lite build
@jtpio @QuantStack

Fichiers HTML, CSS, JavaScript, Wasm

├── 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
...
@jtpio @QuantStack

Cas d'usage

@jtpio @QuantStack

center

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

@jtpio @QuantStack

https://github.com/rowanc1/myst-lite

@jtpio @QuantStack

Education

@jtpio @QuantStack

🚀 Deployez sur GitHub Pages

center

@jtpio @QuantStack

https://jupyterlite.github.io/demo/

@jtpio @QuantStack

🔍 Références

@jtpio @QuantStack

Merci !

@jtpio @QuantStack