Lightweight composition of async pipelines where each stage receives the previous stage's output.
Project description
async-pipeline
A small library for composing async pipelines: each Stage receives the previous stage’s output, executed in order.
Requirements
- Python 3.14 or newer
Install with uv
In your project:
uv add async-pipeline
To work on this library:
git clone <repo-url>
cd async-pipeline
uv sync
Basic usage
from async_pipeline import Pipeline, Stage
async def add_one(value: int) -> int:
return value + 1
async def multiply_by_two(value: int) -> int:
return value * 2
pipeline = Pipeline([
Stage("add_one", add_one),
Stage("multiply_by_two", multiply_by_two),
])
result = await pipeline.run(10)
assert result == 22
Synchronous handlers are supported as well (the stage’s run method remains async):
def add_one(value: int) -> int:
return value + 1
pipeline = Pipeline([
Stage("add_one", add_one),
])
result = await pipeline.run(1)
assert result == 2
Errors
Failures inside a handler are surfaced as StageExecutionError, including the stage name and the original exception:
from async_pipeline import Pipeline, Stage, StageExecutionError
async def broken(value: int) -> int:
raise RuntimeError("boom")
pipeline = Pipeline([
Stage("broken", broken),
])
try:
await pipeline.run(1)
except StageExecutionError as exc:
assert exc.stage_name == "broken"
assert isinstance(exc.original_error, RuntimeError)
A Pipeline with no stages raises ValueError at construction time.
Development commands
uv sync
uv run pytest
uv run ruff check .
uv run mypy src
Roadmap
- Retry — retry policies per stage or for the whole pipeline
- Timeout — cap how long a stage may run
- Hooks — before/after each stage or the full pipeline
- Concurrent map — a stage that processes collections with bounded concurrency
License
See the LICENSE file.
Project details
Release history Release notifications | RSS feed
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 async_pipeline-0.1.3.tar.gz.
File metadata
- Download URL: async_pipeline-0.1.3.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f22c9e4e180ca7454783ca622089b5eef763448d52dd9e104a4382f72364ba
|
|
| MD5 |
df87cdabe8beb2de38de81f8952c6ee1
|
|
| BLAKE2b-256 |
419920134fc9e2466c9005dc5c6616b5e36967be1b148c534b60b26f27a8b400
|
Provenance
The following attestation bundles were made for async_pipeline-0.1.3.tar.gz:
Publisher:
publish.yml on HenriqueKoga/async-pipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_pipeline-0.1.3.tar.gz -
Subject digest:
63f22c9e4e180ca7454783ca622089b5eef763448d52dd9e104a4382f72364ba - Sigstore transparency entry: 1435978787
- Sigstore integration time:
-
Permalink:
HenriqueKoga/async-pipeline@88708ead20546ee121d66ea7e0d36c7b8d7cb409 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/HenriqueKoga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88708ead20546ee121d66ea7e0d36c7b8d7cb409 -
Trigger Event:
push
-
Statement type:
File details
Details for the file async_pipeline-0.1.3-py3-none-any.whl.
File metadata
- Download URL: async_pipeline-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cb12a041bc5c93ebc2a7f3f019c6911e24a4b9f6c3b6ee9c0f77815d86732c7
|
|
| MD5 |
64ecdb7b0fa47f67a3ca7cc2617aa272
|
|
| BLAKE2b-256 |
e44537ba18548e89c1a67ef2c5c675602b413590ba75a4c41e2531bd51a94f4c
|
Provenance
The following attestation bundles were made for async_pipeline-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on HenriqueKoga/async-pipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_pipeline-0.1.3-py3-none-any.whl -
Subject digest:
0cb12a041bc5c93ebc2a7f3f019c6911e24a4b9f6c3b6ee9c0f77815d86732c7 - Sigstore transparency entry: 1435978789
- Sigstore integration time:
-
Permalink:
HenriqueKoga/async-pipeline@88708ead20546ee121d66ea7e0d36c7b8d7cb409 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/HenriqueKoga
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88708ead20546ee121d66ea7e0d36c7b8d7cb409 -
Trigger Event:
push
-
Statement type: