JupyterLite#
JupyterLite is a special version of
JupyterLab which provides many features of jupyter_server
and ipykernel
in the
browser.
Show code cell source
import json
from pathlib import Path
from IPython.display import Markdown
import jupyter_starters
lite_version = __import__("jupyterlite").__version__
lite_warning = f"""
```{{warning}}
JupyterLite is under active development, and the starters integration probably only works with `{ lite_version }`, or later.
```
""".strip()
Markdown(lite_warning)
JupyterLite is under active development, and the starters integration probably only works with `0.1.0b18`, or later.
Including Starters in a JupyterLite site#
Get the Lab Extension#
By default, just having jupyter-starters
installed in the same environment as
JupyterLite will force it to be included.
Alternately, a jupyter_build_config.json
can be provided in the directory where
jupyter lite build
is executed.
Show code cell source
conf = {
"LiteBuildConfig": {
"federated_labextensions": [
f"https://pypi.io/packages/source/j/jupyter-starters/jupyter_starters-{ jupyter_starters.__version__ }-py3-none-any.whl"
]
}
}
Markdown(
f"""
#### `jupyter_lite_config.json`
```json
{json.dumps(conf, indent=2, sort_keys=True)}
```
"""
)
jupyter_lite_config.json
{
"LiteBuildConfig": {
"federated_labextensions": [
"https://pypi.io/packages/source/j/jupyter-starters/jupyter_starters-2.0.0a0-py3-none-any.whl"
]
}
}
Define Starters in Settings#
Starters can be defined in overrides.json
.
Show code cell source
overrides = {
k: v
for k, v in json.load(Path("../../.binder/overrides.json").open()).items()
if k.startswith("@deathbeds/jupyterlab-starters")
}
Markdown(
f"""
#### `overrides.json`
```json
{json.dumps(overrides, indent=2, sort_keys=True)}
```
"""
)
overrides.json
{
"@deathbeds/jupyterlab-starters:settings-provider": {
"starters": {
"hello-notebook": {
"category": "Notebook",
"content": {
"content": {
"cells": [
{
"cell_type": "markdown",
"source": "# Hello {{ world }}!"
}
]
},
"name": "hello-{{ world | lower }}.ipynb",
"type": "notebook"
},
"description": "A Hello World notebook.",
"label": "Hello Notebook",
"rank": 42,
"schema": {
"description": "An example of a _Hello World_ notebook.",
"properties": {
"world": {
"default": "Jupyter",
"description": "The world to greet.",
"type": "string"
}
},
"title": "Hello Notebook",
"type": "object"
},
"type": "content"
},
"todo": {
"category": "Productivity",
"content": {
"content": "# {{ title }}\n{% for item in items %}\n- [{% if item.done %}x{% else %} {% endif %}] {{ item.description }}{% endfor %}",
"name": "TODO.md"
},
"description": "A todo list",
"label": "TODO List",
"schema": {
"default": {
"title": "Things To Do"
},
"properties": {
"items": {
"items": {
"properties": {
"description": {
"default": "a thing",
"type": "string"
},
"done": {
"type": "boolean"
}
},
"type": "object"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"title": "A TODO List",
"type": "object"
},
"type": "content",
"uiSchema": {
"ui:order": [
"title",
"items"
]
}
}
}
}
}
Build the Site#
Use the JupyterLite CLI:
jupyter lite build
Build a Link#
When publishing a link, a Starter Tree URL can be used to launch a starter as soon as the UI loads.
https://jupyterstarters.readthedocs.io/static/lab/index.html?starter=todo