nirs4all.controllers.base module

Base classes for pipeline controllers.

Controllers handle the execution logic for operators in nirs4all pipelines. Each controller type knows how to execute specific operator types.

class nirs4all.controllers.base.BaseController[source]

Bases: ABC

Abstract base class for all controllers.

Controllers are responsible for executing operators within a pipeline context. They handle framework-specific logic, state management, and validation.

abstractmethod can_handle(operator: Any) bool[source]

Check if this controller can handle the given operator.

Parameters:

operator (Any) – The operator to check.

Returns:

True if this controller can handle the operator.

Return type:

bool

cleanup(operator: Any, context: ExecutionContext) None[source]

Clean up after operator execution.

This method can be overridden to perform cleanup tasks after execution.

Parameters:
  • operator (Any) – The operator that was executed.

  • context (ExecutionContext) – Pipeline execution context.

abstractmethod execute(operator: Any, context: ExecutionContext) Any[source]

Execute the operator within the pipeline context.

Parameters:
  • operator (Any) – The operator to execute.

  • context (ExecutionContext) – Pipeline execution context including data, state, etc.

Returns:

Result of operator execution.

Return type:

Any

prepare(operator: Any, context: ExecutionContext) None[source]

Prepare the operator for execution.

This method can be overridden to perform setup tasks before execution.

Parameters:
  • operator (Any) – The operator to prepare.

  • context (ExecutionContext) – Pipeline execution context.

validate(operator: Any) None[source]

Validate the operator before execution.

Parameters:

operator (Any) – The operator to validate.

Raises:

ValueError – If operator is invalid.