Metadata-Version: 2.4
Name: pipeline-frame
Version: 0.1.0
Summary: A lightweight in-memory pipeline framework built around before, run, and after.
Project-URL: Homepage, https://github.com/al6nlee/pipeline-frame
Project-URL: Repository, https://github.com/al6nlee/pipeline-frame
Author-email: alan <al6nlee@gmail.com>
Keywords: pipeline,pipeline-frame,workflow
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# 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:

```python
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:

```text
A.before()
A.run()
A.after()
B.before()
B.run()
B.after()
```

If you want to keep an explicit pipeline name, you can also write:

```python
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:

```bash
python -m unittest discover -s tests -v
```
