A lightweight in-memory pipeline framework built around before, run, and after.
Project description
pipeline-frame
pipeline-frame is a lightweight in-memory pipeline framework for Python 3.11+.
It keeps the model intentionally narrow: every step is built around before(), run(), and after().
Core idea
Define a linear pipeline with Step instances and | composition:
from pipeline_frame import Pipeline, PipelineContext, Step
class A(Step):
def before(self, context: PipelineContext) -> None:
print("a.before")
def run(self, context: PipelineContext) -> None:
context.set("text", context.input["text"].strip())
def after(self, context: PipelineContext) -> None:
print("a.after")
class B(Step):
def run(self, context: PipelineContext) -> None:
context.set_output(context.get("text").upper())
pipeline = A() | B()
result = pipeline.run({"text": " hello world "})
print(result.output)
Execution is linear and easy to reason about:
A.before()
A.run()
A.after()
B.before()
B.run()
B.after()
Async steps use the same lifecycle, but run through await pipeline.arun(...):
from pipeline_frame import Pipeline, PipelineContext, Step
class Fetch(Step):
async def run(self, context: PipelineContext) -> None:
context.set("text", context.input["text"].strip())
class Render(Step):
async def run(self, context: PipelineContext) -> None:
context.set_output(context.get("text").upper())
pipeline = Pipeline("request").add(Fetch).add(Render)
result = await pipeline.arun({"text": " hello world "})
print(result.output)
Pipeline.arun() accepts mixed sync/async step methods. If a step defines async lifecycle methods, do not call Pipeline.run().
If you want to keep an explicit pipeline name, you can also write:
pipeline = Pipeline("request") | A() | B()
Design goals
- one core abstraction:
Pipeline - one step lifecycle:
before,run,after - chainable definitions with minimal ceremony
- structured execution results
- predictable stop-on-failure behavior
Failure behavior
- if
before()fails, the current step stops and later steps do not run - if
run()fails, the current step still attemptsafter() - if
after()fails, the pipeline is marked failed and later steps do not run - all details are available on
PipelineResult
API overview
Pipeline: ordered collection of step instancesStep: base class withbefore(),run(), andafter()PipelineContext: shared input, state, output, and errorPipelineResult: execution report for one run
Development
Run tests from the repository root:
python -m unittest discover -s tests -v
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 pipeline_frame-0.1.1.tar.gz.
File metadata
- Download URL: pipeline_frame-0.1.1.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48308b0999cac064860ad7b861d7f9693e9f00f77d916f6f7eb7d89b5968c667
|
|
| MD5 |
35addf96b5ac7cd358ffc83e93b01a24
|
|
| BLAKE2b-256 |
ce1e748b30e85167a0bd9031b98d5c30ec961803f59bcd9d262a374778eebaae
|
Provenance
The following attestation bundles were made for pipeline_frame-0.1.1.tar.gz:
Publisher:
publish.yml on al6nlee/pipeline-frame
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipeline_frame-0.1.1.tar.gz -
Subject digest:
48308b0999cac064860ad7b861d7f9693e9f00f77d916f6f7eb7d89b5968c667 - Sigstore transparency entry: 1196293362
- Sigstore integration time:
-
Permalink:
al6nlee/pipeline-frame@405f9a2bf0778df2acf7784dda6b049f98d803f5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/al6nlee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@405f9a2bf0778df2acf7784dda6b049f98d803f5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pipeline_frame-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pipeline_frame-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.9 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 |
08390c6638970d66665fab7d516eedc135560231fcc6e72520ee10885071cbad
|
|
| MD5 |
429e0767208da693352cf518aab301a7
|
|
| BLAKE2b-256 |
944c4e604b77d5a8b9b5cb49292683beb9a062860092bccec9cbeaadd066c95c
|
Provenance
The following attestation bundles were made for pipeline_frame-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on al6nlee/pipeline-frame
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipeline_frame-0.1.1-py3-none-any.whl -
Subject digest:
08390c6638970d66665fab7d516eedc135560231fcc6e72520ee10885071cbad - Sigstore transparency entry: 1196293452
- Sigstore integration time:
-
Permalink:
al6nlee/pipeline-frame@405f9a2bf0778df2acf7784dda6b049f98d803f5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/al6nlee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@405f9a2bf0778df2acf7784dda6b049f98d803f5 -
Trigger Event:
push
-
Statement type: