A lightweight, object-orientated pipeline framework in Python
Project description
Pipelining
A lightweight, object-orientated pipeline framework in Python, with Rich-powered logging, and abstract semantics.
Features
- Modular Stages: Each processing step can be defined by subclassing the simple
Stageinterface. - Pipeline Orchestration: Stages can be composed into ordered pipelines with automatic logging injection.
- Pretty Logging: Good looking logging, powered by Rich
- Concurrency: The
MultiStepStagesupports parallelism of tasks.
Installation
This package is built for Python 3.10 or greater.
Install pipelining-colemann through PyPi with:
$ pip install pipelining-colemann
...
Example
class TextStage(Stage):
def __init__(self, name: str, message: str) -> None:
super().__init__(name)
self.message = message
def run(self, context: dict[str, Any]) -> None:
self.logger.info(f"{self.name}: {self.message}")
pipeline = Pipeline(
[TextStage("Stage 1", "Hello, World!"), TextStage("Stage 2", "Goodbye, World!")],
name="Example Pipeline",
)
pipeline.run()
A simple example like this will output:
[2025-05-07 17:52:18] INFO Starting Example Pipeline
INFO Running stage: TextStage
INFO Stage 1: Hello, World!
INFO Stage TextStage completed successfully!
INFO Running stage: TextStage
INFO Stage 2: Goodbye, World!
INFO Stage TextStage completed successfully!
INFO Example Pipeline completed successfully!
Concurrency Example
class TextStage(Stage):
def __init__(self, name: str, message: str) -> None:
super().__init__(name)
self.message = message
def run(self, _: dict[str, Any]) -> None:
self.logger.info(f"{self.name}: {self.message}")
def make_step(name: str, delay: float = 0.1) -> Callable:
def step(context):
sleep(delay)
context[name] = f"{name}_done"
return step
multistep_stage = MultiStepStage(
name="Multi-Step Stage Example",
steps=[
make_step("Step A", delay=0.2),
make_step("Step B", delay=5),
make_step("Step C", delay=0.1),
],
parallel=True,
)
text_one = TextStage(name="Text Stage One", message="This is the first text stage.")
text_two = TextStage(name="Text Stage Two", message="This is the second text stage.")
pipeline = Pipeline(
stages=[text_one, multistep_stage, text_two], name="Example Pipeline"
)
context: dict[str, Any] = {}
pipeline.run(context=context, use_tqdm=True)
This is an example of a pipeline with both normal and multi-step stages - with the multi-step stage running its steps in parallel.
Development
To setup a Python environment for this project, I recommend using Pixi - I use it and like it. You can enter the workspace using:
$ pixi shell
...
The following self-explanatory tasks are available for usage.
ruffmypytestcoverage
Testing
Tests can be run through Pixi with:
$ pixi run test
...
They can be run with coverage too, this will generate a coverage report under the htmlcov directory.
$ pixi run coverage
...
Contributing
Feel free to contribute to the project! I would appreciate any feedback or comments. Although this project has been built with my own usage in mind, I'm open to changes and improvements.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipelining_colemann-0.0.4.tar.gz.
File metadata
- Download URL: pipelining_colemann-0.0.4.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc29677fe61571e7914bfbc1bf7321ea4fc9fd2346ed93cda8fd716982e40546
|
|
| MD5 |
99c5167b57f86264f87301279644ea42
|
|
| BLAKE2b-256 |
486686fee4b901d2c19a100e692d1ac3fdbdbb971564d88a43ea2d54b1b21a2c
|
Provenance
The following attestation bundles were made for pipelining_colemann-0.0.4.tar.gz:
Publisher:
publishing.yml on colemannoah/pipelining
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipelining_colemann-0.0.4.tar.gz -
Subject digest:
cc29677fe61571e7914bfbc1bf7321ea4fc9fd2346ed93cda8fd716982e40546 - Sigstore transparency entry: 520398406
- Sigstore integration time:
-
Permalink:
colemannoah/pipelining@6240f550e951df230aa4f89260e29dcda856b784 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/colemannoah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publishing.yml@6240f550e951df230aa4f89260e29dcda856b784 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pipelining_colemann-0.0.4-py3-none-any.whl.
File metadata
- Download URL: pipelining_colemann-0.0.4-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de8483cde9f35e72be2f98f7f67d299266f8a0fef8669c57ad169883d68fd662
|
|
| MD5 |
d59dbe90829250e5da1d0ad1db040e2f
|
|
| BLAKE2b-256 |
8d8f79c3fea7cd0a0898d7118bcc1047aef231f94b7d9027c8f4bc18711a934a
|
Provenance
The following attestation bundles were made for pipelining_colemann-0.0.4-py3-none-any.whl:
Publisher:
publishing.yml on colemannoah/pipelining
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipelining_colemann-0.0.4-py3-none-any.whl -
Subject digest:
de8483cde9f35e72be2f98f7f67d299266f8a0fef8669c57ad169883d68fd662 - Sigstore transparency entry: 520398478
- Sigstore integration time:
-
Permalink:
colemannoah/pipelining@6240f550e951df230aa4f89260e29dcda856b784 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/colemannoah
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publishing.yml@6240f550e951df230aa4f89260e29dcda856b784 -
Trigger Event:
push
-
Statement type: