Skip to main content

A tiny, typed, sequential pipeline engine for Python

Project description

lilpipe

A tiny, typed, sequential pipeline engine for Python.

PyPI Python Version CI Coverage License

lilpipe is a lightweight, Pydantic-powered library for building and running sequential workflows in Python. Designed for simplicity and type safety, it’s ideal for data processing, scientific workflows (e.g., ligand-binding assays), and any task requiring a clear, linear sequence of steps. With built-in caching, retries, and composable steps, lilpipe offers a minimal yet robust solution for Python developers who want type-safe pipelines without the complexity of graph-based or distributed systems.

Features

  • Sequential Workflows: Run steps in a fixed order, perfect for linear tasks like data processing or lab assays.
  • Pydantic-Powered: Leverage Pydantic for type-safe, validated configuration and state, integrating seamlessly with FastAPI or data science stacks.
  • Smart Caching: Skip unchanged steps using fingerprint-based hashing, saving time in iterative workflows.
  • Retries and Control: Support re-running pipelines (needs_rerun) and early termination (abort_pass, abort_run) for flexible control.
  • Composable Steps: Nest workflows with CompositeStep for modular, reusable pipelines.
  • Lightweight: Minimal dependencies (just Pydantic), ensuring easy installation and low overhead.
  • Bio-Inspired: Born from ligand-binding assay (LBA) analysis, with potential for lab-specific extensions.
  • Robust Testing: 100% test coverage, linted with ruff, and typed with mypy.

Installation

Install lilpipe via pip:

pip install lilpipe

Requires Python 3.13+ and Pydantic 2.11.7+.

Usage Example

Below is an example showing a pipeline for processing lab data (e.g., LBA) and a generic data-cleaning pipeline, using Step, CompositeStep, and PipelineContext.

from lilpipe import Step, CompositeStep, Pipeline, PipelineContext

# Define steps for a bio-inspired pipeline
class LoadData(Step):
    name = "load_data"
    def logic(self, ctx: PipelineContext) -> PipelineContext:
        ctx.data = [1.0, 2.0, 3.0]  # Simulated assay data
        return ctx

class Calibrate(Step):
    name = "calibrate"
    fingerprint_keys = ("data",)
    def logic(self, ctx: PipelineContext) -> PipelineContext:
        ctx.calibrated = [x * 1.5 for x in ctx.data]  # Calibration factor
        return ctx

class Validate(Step):
    name = "validate"
    def logic(self, ctx: PipelineContext) -> PipelineContext:
        if any(x < 0 for x in ctx.calibrated):
            ctx.needs_rerun = True  # Trigger retry if invalid
        return ctx

# Nested steps for modularity
composite = CompositeStep("process", children=[Calibrate(), Validate()])

# Create and run the pipeline
pipeline = Pipeline([LoadData(), composite], name="lba_pipeline", max_loops=3)
ctx = PipelineContext()
pipeline.run(ctx)

print(ctx.calibrated)  # Output: [1.5, 3.0, 4.5]
print(ctx.step_meta)  # Inspect timing, cache hits, etc.

# Generic example: Data cleaning
class CleanData(Step):
    name = "clean"
    fingerprint_keys = ("input",)
    def logic(self, ctx: PipelineContext) -> PipelineContext:
        ctx.output = [x for x in ctx.input if x is not None]
        return ctx

ctx = PipelineContext(input=[1, None, 3])
CleanData().run(ctx)
print(ctx.output)  # Output: [1, 3]

Try the full example in our Jupyter notebook.

Why lilpipe?

lilpipe is designed for users who need simple, sequential pipelines without the overhead of complex workflow libraries. Unlike other tools that focus on directed acyclic graphs (DAGs), parallel execution, or distributed systems, lilpipe prioritizes:

  • Simplicity: Linear workflows with a clear, predictable order.
  • Type Safety: Pydantic-based configuration for robust, validated state.
  • Lightweight Design: Minimal dependencies and easy setup.
  • Bio-Friendly: Tailored for lab workflows (e.g., LBA), but flexible for any sequential task.

Choose lilpipe for type-safe, sequential pipelines in Python-centric projects, especially in data science or bio/lab applications, where graph-based or heavy orchestration tools are unnecessary.

License

Licensed under the Apache 2.0 License.

Contact

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

lilpipe-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

lilpipe-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file lilpipe-0.1.0.tar.gz.

File metadata

  • Download URL: lilpipe-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lilpipe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66f4c423e9ba746f1beff814951e69b4e1cc930300ae15202e85517dc66c1a3a
MD5 96758a2bba6be202ce87b5a10f7ef025
BLAKE2b-256 14766329306385acd59a5acb6797ec6e1c667abdf1d364414e7e0c71a4225593

See more details on using hashes here.

File details

Details for the file lilpipe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lilpipe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lilpipe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27f4bf6587c49dbaf414bf4d04dd7479c08102fedc5c21415562b00b189d8013
MD5 8bdb868a5e5ab83ab58643bfccce8a7a
BLAKE2b-256 fdddc5c538183cbfb6745d4080176f997f4eba5993f4ee09b2ae540506dd7c1a

See more details on using hashes here.

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