Skip to content

API Reference

thecodecrate_pipeline

__all__ module-attribute

__all__ = (
    "Pipeline",
    "PipelineFactory",
    "PipelineFactoryInterface",
    "PipelineInterface",
    "Processor",
    "ProcessorInterface",
    "Stage",
    "StageInterface",
)

__version__ module-attribute

__version__ = '1.29.0'

Pipeline

Pipeline(
    processor: Optional[type[Processor] | Processor] = None,
    processor_instance: Optional[Processor] = None,
    *args: Any,
    **kwds: Any
)

processor instance-attribute

processor: Optional[type[Processor] | Processor]

processor_instance instance-attribute

processor_instance: Optional[Processor]

__call__ async

__call__(
    payload: T_in, /, *args: Any, **kwds: Any
) -> T_out

Processes payload through the pipeline.

_get_default_processor

_get_default_processor() -> (
    type[ChainedProcessor[T_in, T_out]]
)

_instantiate_processor

_instantiate_processor() -> Self

_instantiate_stages

_instantiate_stages() -> Self

_should_instantiate_processor

_should_instantiate_processor() -> bool

_should_instantiate_stages

_should_instantiate_stages() -> bool

clone

clone(attributes: dict[str, Any]) -> Self

get_processor_instance

get_processor_instance() -> Optional[Processor]

get_stages_instances

get_stages_instances() -> CallableCollection

pipe

pipe(stage: CallableType) -> Self

Adds a single stage to the pipeline.

process async

process(payload: T_in, *args: Any, **kwds: Any) -> T_out

Process the given payload through the pipeline.

with_processor

with_processor(
    processor: type[Processor] | Processor,
) -> Self

Attachs a processor (class or instance) to the pipeline.

with_stages

with_stages(stages: StageDefinitionCollection) -> Self

Adds a collection of stages to the pipeline.

PipelineFactory

PipelineFactory(
    stages: Optional[StageDefinitionCollection] = None,
    processor: Optional[type[Processor] | Processor] = None,
    pipeline_class: Optional[
        type[Pipeline[T_in, T_out]]
    ] = None,
    *args: Any,
    **kwds: Any
)

_target_class class-attribute instance-attribute

_target_class: Optional[type[T_target]] = None

pipeline_class instance-attribute

pipeline_class: Optional[type[Pipeline[T_in, T_out]]]

processor instance-attribute

processor: Optional[
    type[Processor[T_in, T_out]] | Processor
]

_definition

_definition() -> dict[str, Any]

_get_default_pipeline_class

_get_default_pipeline_class() -> (
    Optional[type[Pipeline[T_in, T_out]]]
)

_get_target_class

_get_target_class() -> type[Pipeline[T_in, T_out]]

add_stage

add_stage(stage: StageDefinition) -> Self

Add a single stage (class, object or function) to the pipeline.

make

make() -> T_target

with_processor

with_processor(
    processor: type[Processor] | Processor,
) -> Self

Attach a processor (class or instance) to the pipeline factory.

with_stages

with_stages(stages: StageDefinitionCollection) -> Self

Set a collection of stages (class, object or function) to the pipeline.

Processor

_call async

_call(
    callable: CallableType[T_in, T_out],
    payload: T_in,
    *args: Any,
    **kwds: Any
) -> T_out

Do the actual processing of the payload - the "process" method is just an alias to this method.

clone

clone(attributes: dict[str, Any]) -> Self

process abstractmethod async

process(
    payload: T_in,
    stages: CallableCollection,
    *args: Any,
    **kwds: Any
) -> T_out

Process the given payload through the provided stages.

Parameters:

Returns:

  • T_out ( T_out ) –

    The processed output.

Stage

__call__ abstractmethod async

__call__(
    payload: T_in, /, *args: Any, **kwds: Any
) -> T_out

Runs the stage.