bibliotekar.nb.Notebook#

class bibliotekar.nb.Notebook(nb, *, name)[source]#

A Jupyter notebook.

__init__(nb, *, name)[source]#

Methods

__init__(nb, *, name)

convert_to_script()

Convert the notebook to a Python script.

execute_with_pixi(*, folder[, pixi, ...])

Execute the notebook with pixi.

load(path)

Load a notebook from a file.

save(path)

Save the notebook to a file.

strip_dev_cells()

Return a new notebook with all development-only cells removed.

tracking_data()

Return the tracking metadata associated with the notebook, if any.

with_metadata_cell(metadata)

Insert a Markdown cell at the top of the notebook with some metadata.

with_tracking_data(metadata)

Return a new notebook with new tracking metadata.

Attributes

FORMAT_VERSION

convert_to_script()[source]#

Convert the notebook to a Python script.

Return type:

str

execute_with_pixi(*, folder, pixi='pixi', pixi_env=None, timeout=10.0)[source]#

Execute the notebook with pixi.

The notebook is first converted to a Python script which is saved in the given folder. The script is then executed with IPython to allow for widgets and other IPython-specific features.

Return type:

int

classmethod load(path)[source]#

Load a notebook from a file.

Return type:

Self

save(path)[source]#

Save the notebook to a file.

Return type:

None

strip_dev_cells()[source]#

Return a new notebook with all development-only cells removed.

Any cell with the tag “remove-cell” is removed.

Return type:

Notebook

tracking_data()[source]#

Return the tracking metadata associated with the notebook, if any.

Return type:

TrackingData | None

with_metadata_cell(metadata)[source]#

Insert a Markdown cell at the top of the notebook with some metadata.

Return type:

Notebook

with_tracking_data(metadata)[source]#

Return a new notebook with new tracking metadata.

Return type:

Notebook