nirs4all.pipeline.execution.builder module

Executor builder for creating configured PipelineExecutor instances.

This module provides a builder pattern for constructing PipelineExecutor instances with all necessary dependencies and configuration.

class nirs4all.pipeline.execution.builder.ExecutorBuilder[source]

Bases: object

Builder for creating PipelineExecutor instances.

Provides a fluent interface for configuring and building executors with all necessary dependencies. Encapsulates the complex setup logic previously duplicated between Orchestrator and other components.

Example

>>> builder = ExecutorBuilder()
>>> executor = (builder
...     .with_run_directory(run_dir)
...     .with_mode("train")
...     .with_verbose(1)
...     .build())
property artifact_registry: Any

Get the artifact registry.

build() PipelineExecutor[source]

Build the configured PipelineExecutor instance.

Creates all necessary components if not already provided, then constructs and returns a fully configured PipelineExecutor.

Returns:

Configured PipelineExecutor instance

Raises:

ValueError – If run_directory is not set

with_artifact_loader(artifact_loader: Any) ExecutorBuilder[source]

Set artifact loader for predict/explain modes.

Parameters:

artifact_loader – ArtifactLoader instance

Returns:

Self for method chaining

with_artifact_registry(artifact_registry: Any) ExecutorBuilder[source]

Set artifact registry for train mode.

Parameters:

artifact_registry – ArtifactRegistry instance

Returns:

Self for method chaining

with_continue_on_error(continue_on_error: bool) ExecutorBuilder[source]

Set whether to continue execution on errors.

Parameters:

continue_on_error – Whether to continue on errors

Returns:

Self for method chaining

with_dataset(dataset: SpectroDataset) ExecutorBuilder[source]

Set the dataset for this execution.

Parameters:

dataset – Dataset to process

Returns:

Self for method chaining

with_manifest_manager(manifest_manager: ManifestManager) ExecutorBuilder[source]

Set custom manifest manager.

Parameters:

manifest_manager – ManifestManager instance

Returns:

Self for method chaining

with_mode(mode: str) ExecutorBuilder[source]

Set execution mode.

Parameters:

mode – Execution mode (‘train’, ‘predict’, ‘explain’)

Returns:

Self for method chaining

with_plots_visible(plots_visible: bool) ExecutorBuilder[source]

Set whether to display plots.

Parameters:

plots_visible – Whether to display plots

Returns:

Self for method chaining

with_run_directory(run_directory: Path) ExecutorBuilder[source]

Set the run directory for this execution.

Parameters:

run_directory – Path to the run directory where outputs will be saved

Returns:

Self for method chaining

with_save_artifacts(save_artifacts: bool) ExecutorBuilder[source]

Set whether to save binary artifacts (models, transformers).

Parameters:

save_artifacts – Whether to save artifacts

Returns:

Self for method chaining

with_save_charts(save_charts: bool) ExecutorBuilder[source]

Set whether to save charts and visual outputs.

Parameters:

save_charts – Whether to save charts

Returns:

Self for method chaining

with_saver(saver: SimulationSaver) ExecutorBuilder[source]

Set custom simulation saver.

Parameters:

saver – SimulationSaver instance

Returns:

Self for method chaining

with_show_spinner(show_spinner: bool) ExecutorBuilder[source]

Set whether to show progress spinners.

Parameters:

show_spinner – Whether to show spinners

Returns:

Self for method chaining

with_step_runner(step_runner: StepRunner) ExecutorBuilder[source]

Set custom step runner.

Parameters:

step_runner – StepRunner instance

Returns:

Self for method chaining

with_verbose(verbose: int) ExecutorBuilder[source]

Set verbosity level.

Parameters:

verbose – Verbosity level (0=quiet, 1=info, 2=debug)

Returns:

Self for method chaining

with_workspace(workspace: Path) ExecutorBuilder[source]

Set workspace root path for artifact storage.

Parameters:

workspace – Workspace root path

Returns:

Self for method chaining

property workspace: Path | None

Get the workspace path.