Skip to main content

PipeCo 🔗

Type-safe, composable data pipelines built on Pydantic

PipeCo is a lightweight Python framework for building robust data processing pipelines with compile-time type checking. Define your steps with clear input/output contracts, and PipeCo ensures they connect correctly.

✨ Features

  • Type Safety: Pydantic-based validation at every step boundary
  • Compile-Time Checks: Catches type mismatches before execution
  • Clean Abstractions: Simple Step base class for building reusable components
  • Registry System: Register and discover steps by name
  • Context Sharing: Pass loggers, resources, and cache between steps
  • Easy Composition: Chain steps together with confidence

📦 Installation

pip install pipeco

Or with uv:

uv add pipeco

🚀 Quick Start

1. Define Your Data Models

from pipeco import BaseModel

class InputData(BaseModel):
    text: str

class ProcessedData(BaseModel):
    upper_text: str
    length: int

2. Create Pipeline Steps

from pipeco import Step, Context, register

@register("uppercase")
class UppercaseStep(Step[InputData, ProcessedData, Nothing]):
    input_model = InputData
    output_model = ProcessedData
    config_model = Nothing
    
    def process(self, data: InputData, ctx: Context) -> ProcessedData:
        return ProcessedData(
            upper_text=data.text.upper(),
            length=len(data.text)
        )

3. Build and Run Your Pipeline

from pipeco import Pipeline, get_step

# Create pipeline
pipeline = Pipeline(steps=[
    get_step("uppercase")()
])

# Run it
result = pipeline.run(InputData(text="hello world"))
print(result.upper_text)  # "HELLO WORLD"
print(result.length)       # 11

📚 Core Concepts

Step

The Step class is the building block of pipelines. Each step:

  • Declares its input type (I), output type (O), and configuration type (C)
  • Implements the process() method for business logic
  • Automatically validates inputs and outputs using Pydantic

Pipeline

The Pipeline chains steps together and:

  • Verifies type compatibility at initialization (compile-time checking)
  • Validates data at each step boundary (runtime checking)
  • Passes context through all steps

Context

The Context object flows through your pipeline, providing:

  • Logger: Centralized logging
  • Resources: Shared objects (DB connections, API clients, etc.)
  • Cache: Data sharing between non-adjacent steps

Registry

Use @register() to make steps discoverable by name:

from pipeco import get_step

StepClass = get_step("step-name")
step_instance = StepClass(config)

🎯 Example: CSV Processing

See examples/pipelines.py for a complete example that:

  1. Reads a CSV file
  2. Transforms the data
  3. Saves the result
pipeline = Pipeline(steps=[
    CSVPathToDict(),
    ChangeFavoriteFood(),
    SaveDictToCSV({"save_path": "output.csv"})
])

pipeline.run(ExampleCSVModel(csv_path="input.csv"))

🛡️ Type Safety

PipeCo catches mismatches early:

# This raises TypeError at pipeline creation:
Pipeline(steps=[
    StepA(),  # outputs TypeX
    StepB(),  # expects TypeY (incompatible!)
])

📖 API Reference

Step[I, O, C]

Base class for pipeline steps.

  • process(data: I, ctx: Context) -> O: Override this method

Pipeline

  • __init__(steps: list[Step]): Create pipeline with type checking
  • run(data: BaseModel, ctx: Context | None) -> BaseModel: Execute pipeline

Context

  • logger: logging.Logger instance
  • resources: Shared resources dict
  • cache: Data cache dict

@register(name: str)

Decorator to register step classes.

get_step(name: str) -> type[Step]

Retrieve registered step class by name.

🤝 Contributing

Contributions welcome! This is a lightweight framework designed to stay simple.

📄 License

See LICENSE file for details.

🔗 Links

Metadata

Release files for pipeco 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipeco 0.1.3
File Size Uploaded Provenance Actions
pipeco-0.1.3.tar.gz 4.9 kB Without provenance Details for pipeco-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pipeco 0.1.3
File Interpreter ABI Platform Actions
pipeco-0.1.3-py3-none-any.whl Python 3 none any Details for pipeco-0.1.3-py3-none-any.whl

Total release size: 10.5 kB

Release files / pipeco-0.1.3.tar.gz

Download URL pipeco-0.1.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
62f375b71c52dec8637e61b58e7b80548b0c07afb44db7aa9a6a9fee880b8402
BLAKE2b-256 checksum
How to use checksums
bc746dc4b07cd75b683df327d10fcb4301afb8eedf1aed0e2cf7034948ec6117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / pipeco-0.1.3-py3-none-any.whl

Download URL pipeco-0.1.3-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86e9dc5af62a9855390e48e4144b68eee5adfccaa8a548df444d274068e5b8dd
BLAKE2b-256 checksum
How to use checksums
13ae7d77e45d3ac151c5dd68e57607fe8eaebb7bce3f8f6b759d299ea9e33bad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Security for pipeco 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page