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

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
dataAdditional data files required by the notebook (e.g., input data files, images, configuration files).List of labelsoptional[]
app_settingsA JupyterLab overrides.json file providing default settings. Keys are @jupyterlab/<extension>:<plugin> and values are settings objects.Labeloptional"@rules_jupyter//jupyter:lab_app_settings"
cwd_modeThe 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.Stringoptional""
envEnvironment variables to set when launching the server. Values support location expansion (e.g., $(location :target)).Dictionary: String -> Stringoptional{}
env_inheritSpecifies additional environment variables to inherit from the external environment.List of stringsoptional[]
executeWhether 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.BooleanoptionalTrue
notebookThe notebook to serve. Must be a jupyter_notebook target.Labelrequired
run_modeControls 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.Stringoptional"runfiles"