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.1.tar.gz (9.8 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.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lilpipe-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 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.1.tar.gz
Algorithm Hash digest
SHA256 b850e5b2992d4db619249e0ca75ab17e5280433be3a8ae4a576f3f253cf1ee73
MD5 072fc026f0bf596bf39a33078028ba0d
BLAKE2b-256 fd7996121c8d821585c0161d4ac46d41b44f9459b1eada29b2c43d57217df167

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lilpipe-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae625f3cb1d60bd3d6d771fa25af25d3e32b188a634225909a877e95f87b14a
MD5 efa4b129f8d89908ebe2a6454413a000
BLAKE2b-256 a4988e5e0c344fa3eecb2a9e2595cc51b3041a4d04a13dc2a19f571c73625b6b

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