Skip to main content

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 attempts after()
  • 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 instances
  • Step: base class with before(), run(), and after()
  • PipelineContext: shared input, state, output, and error
  • PipelineResult: execution report for one run

Development

Run tests from the repository root:

python -m unittest discover -s tests -v

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

pipeline_frame-0.1.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipeline_frame-0.1.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

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

Hashes for pipeline_frame-0.1.1.tar.gz
Algorithm Hash digest
SHA256 48308b0999cac064860ad7b861d7f9693e9f00f77d916f6f7eb7d89b5968c667
MD5 35addf96b5ac7cd358ffc83e93b01a24
BLAKE2b-256 ce1e748b30e85167a0bd9031b98d5c30ec961803f59bcd9d262a374778eebaae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipeline_frame-0.1.1.tar.gz:

Publisher: publish.yml on al6nlee/pipeline-frame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pipeline_frame-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08390c6638970d66665fab7d516eedc135560231fcc6e72520ee10885071cbad
MD5 429e0767208da693352cf518aab301a7
BLAKE2b-256 944c4e604b77d5a8b9b5cb49292683beb9a062860092bccec9cbeaadd066c95c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipeline_frame-0.1.1-py3-none-any.whl:

Publisher: publish.yml on al6nlee/pipeline-frame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page