pydoit_nb.config_handling#

Tools for working with configuration

insert_path_prefix#

insert_path_prefix(config, prefix)[source]#

Insert path prefix into config attributes

This adds the prefix prefix to any attributes of config which are Path

Parameters:
Returns:

typing.TypeVar(AI, bound= attr.AttrsInstance) – Updated config

iterable_values_are_updatable#

iterable_values_are_updatable(value)[source]#

Determine whether an iterable’s values are updatable by insert_path_prefix().

Parameters:

value (collections.abc.Iterable[typing.Any]) – Value to check.

Returns:

boolTrue if value’s elements can be updated by update_attr_value(), False otherwise.

update_attr_value#

update_attr_value(value, prefix)[source]#

Update the attribute value if it is Path to include the prefix

The prefix is taken from the outer scope

Parameters:
Returns:

typing.Union[attr.AttrsInstance, pathlib.Path, typing.TypeVar(T)] – Updated value

get_step_config_ids#

get_step_config_ids(step_configs)[source]#

Get available config IDs from an iterable of step configurations

Parameters:

step_configs (collections.abc.Iterable[pydoit_nb.typing.NotebookConfigLike]) – Step configurations from which to retrieve the step config IDs

Returns:

list[str] – Step config ID from each step config in step_configs

Raises:

AttributeError – Any object in step_configs is missing a “step_config_id” attribute.

get_config_for_step_id#

get_config_for_step_id(config, step, step_config_id)[source]#

Get configuration for a specific value of step config ID for a specific step

This will fail if step isn’t a part of config

Parameters:
  • config (typing.Any) – Config from which to retrieve the step config

  • step (str) – Step in config in which to find a step that has the a step config ID equal to step_config_id

  • step_config_id (str) – Value that the retrieved configuration’s step_config_id must match

Returns:

typing.Any – Configuration for step step in config with a step config ID equal to step_config_id

Raises:
  • ValueError – No step could be found with ID equal to step_config_id

  • AttributeErrorconfig does not have a an attribute equal to the value given in step

load_hydrate_write_config_bundle#

load_hydrate_write_config_bundle(configuration_file, load_configuration_file, create_config_bundle, root_dir_output_run, converter)[source]#

Load, hydrate and write (to disk) ConfigBundleLike

Parameters:
Returns:

typing.TypeVar(CB, bound= pydoit_nb.typing.ConfigBundleLike[typing.Any]) – Loaded ConfigBundleLike