pipeline_stage¶
pipeline_stage ¶
Base pipeline stage abstraction.
Defines the contract for all processing stages using Template Method pattern for execution flow.
PipelineStage ¶
Bases: ABC, Generic[TInput, TOutput]
Abstract base class for all pipeline stages.
Implements Template Method pattern with hooks for extensibility. All stages follow Single Responsibility and are composable.
Initialize pipeline stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable stage name |
required |
Source code in ondine/stages/pipeline_stage.py
process
abstractmethod
¶
Core processing logic (must be implemented by subclasses).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
TInput
|
Input data for this stage |
required |
context
|
Any
|
Execution context with shared state |
required |
Returns:
| Type | Description |
|---|---|
TOutput
|
Processed output data |
Source code in ondine/stages/pipeline_stage.py
validate_input
abstractmethod
¶
Validate input before processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
TInput
|
Input to validate |
required |
Returns:
| Type | Description |
|---|---|
ValidationResult
|
ValidationResult with errors/warnings |
execute ¶
Execute stage with pre/post hooks (Template Method).
This method orchestrates the execution flow and should not be overridden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
TInput
|
Input data |
required |
context
|
Any
|
Execution context |
required |
Returns:
| Type | Description |
|---|---|
TOutput
|
Processed output |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input validation fails |
Source code in ondine/stages/pipeline_stage.py
before_process ¶
Hook called before processing (default: no-op).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Any
|
Execution context |
required |
after_process ¶
Hook called after successful processing (default: no-op).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TOutput
|
Processing result |
required |
context
|
Any
|
Execution context |
required |
on_error ¶
Hook called on processing error (default: re-raise).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The exception that occurred |
required |
context
|
Any
|
Execution context |
required |
Returns:
| Type | Description |
|---|---|
Exception
|
Exception to raise (can transform error) |
Source code in ondine/stages/pipeline_stage.py
estimate_cost
abstractmethod
¶
Estimate processing cost for this stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
TInput
|
Input data to estimate for |
required |
Returns:
| Type | Description |
|---|---|
CostEstimate
|
Cost estimate |