pydoit_nb.notebook#

Notebook defining classes

UnconfiguredNotebook#

class UnconfiguredNotebook(notebook_path, raw_notebook_ext, summary, doc)[source]#

Bases: object

A notebook without any configuration

doc: str#

Documentation of the notebook (can be longer than one line)

notebook_path: pathlib.Path#

Path to notebook, relative to the raw notebook directory

raw_notebook_ext: str#

Extension for the raw notebook

summary: str#

One line summary of the notebook

ConfiguredNotebook#

class ConfiguredNotebook(unconfigured_notebook, dependencies, targets, config_file, step_config_id, configuration=None)[source]#

Bases: object

A configured notebook

It might make sense to refactor this so has an UnconfiguredNotebook as one of its attributes rather than duplicatinng things. That would probably also make it clearer that a configured notebook is just the combination of an unconfigured notebook and the config we want to use with it.

config_file: pathlib.Path#

Path to the config file to use with the notebook

configuration: typing.Optional[tuple[typing.Any, ...]]#

Configuration used by the notebook.

If any of the configuration changes then the notebook will be triggered.

If nothing is provided, then the notebook will be run whenever the configuration file driving the notebook is modified (i.e. the notebook will be re-run for any configuration change).

dependencies: tuple[pathlib.Path, ...]#

Paths on which the notebook depends

step_config_id: str#

step_config_id to use for this run of the notebook

targets: tuple[pathlib.Path, ...]#

Paths which the notebook creates/controls

to_doit_task(root_dir_raw_notebooks, notebook_output_dir, base_task, converter=None, clean=True, config_changed_class=<class 'doit.tools.config_changed'>)[source]#

Convert to a doit task

Parameters:
  • root_dir_raw_notebooks (pathlib.Path) – Root directory in which the raw (not yet run) notebooks are kept

  • notebook_output_dir (pathlib.Path) – Directory in which to write out the run notebook

  • base_task (dict[str, typing.Any]) – Base task definition for this notebook step

  • converter (typing.Optional[pydoit_nb.typing.Converter]) – Converter to use to serialise configuration if needed.

  • clean (bool) – If we run doit clean, should the targets also be removed?

  • config_changed_class (typing.Any) – Class to use for creating our object which can identify if config has changed or not. This should only need to be changed in very rare circumstances. The type hint is very vague because we don’t want to repeat the pydoit API/logic here.

Returns:

dict[str, typing.Any] – Task specification for use with doit

Raises:

TypeErrorself.configuration is not None but converter is None

unconfigured_notebook: pydoit_nb.notebook.UnconfiguredNotebook#

The unconfigured notebook which should be combined with the configuration