Pipeline Toolkit 0.9.2
pip install pipeline-toolkit==0.9.2
Requires Python 3.8 or later.
No runtime dependencies.
A small functional pipeline toolkit for Python.
Build reusable, editable pipelines that execute ordinary Python callables asynchronously in worker threads.
The main components are:
Core components:
Pipeline: Execute callable steps sequentially in a worker thread with support for stopping, skipping, waiting, and rerunning pipelines.Group: Manage a collection of pipelines or sub-groups with support for collective execution, control, and container operations.Checkpoint: Store values and provide a synchronization point for coordinating pipeline execution.Stack: A simple LIFO container with optional maximum capacity, useful for storing pipeline results and errors.
Functional utilities:
chain: Apply multiple callables or pipeline step tuples sequentially, passing each result to the next step and returning the final result.compose: Create a callable that applies multiple callables sequentially to a value.context_executor: Execute a context manager with a value and return its result.flow: Execute callables sequentially, yielding each intermediate result.forward: Forward a value to a specific positional or keyword argument of a callable.mut: Apply a function directly to an object for side effects and return the same object.tap: Apply a side effect to a deep copy of a value while returning the original value unchanged.pipe: Wrap a callable as a factory for creatingstepobjects with preconfigured arguments.repeat: Yield a callable step repeated a specified number of times.step: Represent a callable with preconfigured arguments and provide convenient execution and composition operations.
Example:
from pipeline import Pipeline
def add(x, y):
return x + y
def multiply(x, y):
return x * y
pipeline = Pipeline(
[
(add, (1,)),
(multiply, (2,)),
]
)
pipeline.run(5)
# Do something
pipeline.wait()
print(pipeline.result) # 12
The value flows through each step sequentially:
5
↓
add(5, 1)
↓
6
↓
multiply(6, 2)
↓
12
Ready to build your first pipeline?