Skip to content

Builder

This module provides the implementation of the PipelineBuilder class, which is responsible for building and configuring a pipeline of processes and permanences for the TensorImgPipeline project.

The PipelineBuilder class allows for the registration of classes, loading of configuration files, validation of configuration sections, and construction of the complete pipeline. It handles errors related to configuration loading, class instantiation, and process addition.

Classes:

Name Description
PipelineBuilder

A class to build and configure a pipeline of processes and permanences.

Functions:

Name Description
get_objects_for_pipeline

str) -> dict[str, type]: Retrieves and combines objects to be registered for a given pipeline.

Usage Example:

TODO: Add usage example

Copyright (C) 2025 Matti Kaupenjohann

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

PipelineBuilder

Builds pipeline components from configuration.

__init__()

Initialize the builder with empty registries.

build()

Construct permanences and process specifications.

Returns:

Type Description
tuple[dict[str, Permanence], list[ProcessWithParams]]

Tuple of (permanences_dict, process_specs_list)

Raises:

Type Description
ConfigSectionError

If config sections are invalid

InstTypeError

If permanence/process instantiation fails

RegistryError

If class not found in registry

load_config(path)

Load configuration from file.

Parameters:

Name Type Description Default
path Path

Path to the TOML configuration file

required

Raises:

Type Description
ConfigNotFoundError

If config file doesn't exist

ConfigInvalidTomlError

If TOML parsing fails

ConfigPermissionError

If file can't be read

register_class(name, class_type)

Register a permanence or process class.

Parameters:

Name Type Description Default
name str

Name to register the class under

required
class_type type

The class to register

required

Raises:

Type Description
RegistryError

If registration fails or class is invalid

get_objects_for_pipeline(pipeline_name)

Retrieves and combines objects to be registered for a given pipeline.

Parameters:

Name Type Description Default
pipeline_name str

The name of the pipeline for which to retrieve objects.

required

Returns:

Type Description
dict[str, type[Permanence] | type[PipelineProcess]]

dict[str, type]: A dictionary containing the combined objects from permanences_to_register and processes_to_register of the specified pipeline module, with both instance names and class names as keys.

Raises:

Type Description
ModuleNotFoundError

If the pipeline module cannot be found.