jupyter_lab
Rules
jupyter_lab
load("@rules_jupyter//jupyter:jupyter_lab.bzl", "jupyter_lab")
jupyter_lab(name, data, app_settings, cwd_mode, env, env_inherit, execute, notebook, run_mode)
Launches a Jupyter Lab server for interactive notebook development.
This rule creates an executable target that, when run via bazel run, starts a Jupyter Lab
server with the notebook's dependencies available in the virtualenv. By default, when a user
opens the printed URL in their browser, all notebook cells are automatically executed — exactly
as if the user clicked "Run All Cells" in Lab's Run menu.
Example:
jupyter_notebook(
name = "my_notebook",
src = "notebook.py",
deps = ["@pip_deps//polars"],
)
jupyter_lab(
name = "my_lab",
notebook = ":my_notebook",
)
Then run: bazel run :my_lab
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| data | Additional data files required by the notebook (e.g., input data files, images, configuration files). | List of labels | optional | [] |
| app_settings | A JupyterLab overrides.json file providing default settings. Keys are @jupyterlab/<extension>:<plugin> and values are settings objects. | Label | optional | "@rules_jupyter//jupyter:lab_app_settings" |
| cwd_mode | The working directory mode for notebook execution. If not specified, uses the toolchain's default_cwd. execution_root sets the working directory to Bazel's execution root, while notebook_root sets it to the notebook's parent directory. | String | optional | "" |
| env | Environment variables to set when launching the server. Values support location expansion (e.g., $(location :target)). | Dictionary: String -> String | optional | {} |
| env_inherit | Specifies additional environment variables to inherit from the external environment. | List of strings | optional | [] |
| execute | Whether to automatically execute all notebook cells when the user opens the notebook in their browser. When True, Lab triggers 'Run All Cells' as soon as the notebook loads. Can be overridden at runtime with -- --no-execute. | Boolean | optional | True |
| notebook | The notebook to serve. Must be a jupyter_notebook target. | Label | required | |
| run_mode | Controls where the notebook is served from. runfiles (default) copies the notebook to a temp directory with symlinked data dependencies. source serves the notebook directly from the source tree for in-place editing with unrestricted file access; requires a .ipynb source. | String | optional | "runfiles" |