Skip to main content

A pipeline framework for processing data

Project description

Pipeline-Tee

A powerful and flexible Python pipeline processing framework with advanced flow control, visualization, and async support.

Features

  • ๐Ÿ”„ Flexible Pipeline Processing: Build complex data processing pipelines with branching and conditional execution
  • โšก Async Support: Built with asyncio for efficient asynchronous processing
  • ๏ฟฝ๏ฟฝ Visualization: Rich pipeline visualization with graphviz and matplotlib
    • Generate pipeline structure diagrams showing stages and connections
    • Create execution timeline plots with timing information
    • Track stage status with color-coded nodes and status icons
    • Export as PNG, SVG, or PDF files
  • ๐Ÿ”€ Advanced Flow Control: Support for branching, skipping, jumping between stages
  • ๐Ÿ“ Comprehensive Logging: Detailed logging with configurable levels
  • ๐Ÿ” State Tracking: Pipeline state management and execution metrics
  • ๐ŸŽฏ Post-Processing: Add post-processors to modify stage outputs
  • โš ๏ธ Error Handling: Robust error handling and propagation

Requirements

  • Python 3.8+
  • Optional visualization dependencies:
    • graphviz (for pipeline structure diagrams)
    • matplotlib (for execution timeline plots)

Project Structure

ptee/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ ptee/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ pipeline.py          # Core pipeline implementation
โ”‚       โ”œโ”€โ”€ models/
โ”‚       โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚       โ”‚   โ”œโ”€โ”€ stage.py        # Stage models and decisions
โ”‚       โ”‚   โ””โ”€โ”€ visual.py       # Visualization models
โ”‚       โ””โ”€โ”€ utils/
โ”‚           โ”œโ”€โ”€ logging_config.py
โ”‚           โ””โ”€โ”€ visualization.py # Visualization utilities
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_pipeline.py
โ”‚   โ”œโ”€โ”€ test_visual.py
โ”‚   โ””โ”€โ”€ test_models.py
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ complex_pipeline_demo.py
โ”‚   โ””โ”€โ”€ complex_branching_pipeline.py
โ””โ”€โ”€ pyproject.toml

Installation

# Install core package
pip install -e .

# Install visualization dependencies
pip install -e ".[viz]"

Basic Usage

from ptee.pipeline import Pipeline, PipelineStage, StageResult
from ptee.models.stage import StageDecision
from ptee.utils.visualization import save_pipeline_visualization

# Define a custom pipeline stage
class DataProcessingStage(PipelineStage[str, str]):
    async def process(self, data: str) -> StageResult[str]:
        processed_data = data.upper()
        return StageResult(
            success=True,
            data=processed_data,
            decision=StageDecision.CONTINUE
        )

# Create and configure pipeline
pipeline = Pipeline()
pipeline.add_stage("process_data", DataProcessingStage())

# Process data
result = await pipeline.process("hello world")

# Save visualization diagrams
structure_path, timeline_path = save_pipeline_visualization(
    pipeline,
    output_dir="pipeline_viz",
    base_name="my_pipeline",
    format="png"  # or "svg" or "pdf"
)

print(f"Pipeline structure saved to: {structure_path}")
print(f"Execution timeline saved to: {timeline_path}")

Visualization Examples

The pipeline visualization utilities can generate two types of diagrams:

  1. Pipeline Structure (using graphviz):

    • Shows stages and their connections
    • Color-coded nodes based on stage status
    • Status icons (๐Ÿ”„ pending, โšก running, โœ… completed, โญ๏ธ skipped, โŒ failed)
    • Default sequence and conditional branching paths
  2. Execution Timeline (using matplotlib):

    • Shows execution flow over time
    • Color-coded bars for stage duration
    • Start and end times for each stage
    • Status icons and stage names
    • Time-based x-axis

To generate visualizations, use the save_pipeline_visualization function from ptee.utils.visualization. Make sure to install the visualization dependencies with pip install -e ".[viz]".

Advanced Features

Branching and Conditions

from ptee.pipeline import Condition

# Add branching condition
condition = Condition("is_valid", lambda x: len(x) > 5)
stage.add_branch_condition(condition, "validation_stage")

# Add skip condition
stage.add_skip_condition(Condition("skip_empty", lambda x: not x))

Post-Processing

# Add post-processor to a stage
stage.add_post_processor(lambda x: x.strip())

Development

  1. Clone the repository
  2. Install development dependencies:
    python -m pip install -e ".[dev,viz]"
    
  3. Run tests:
    pytest
    

MIT License

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

pipetee-0.1.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

pipetee-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pipetee-0.1.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pipetee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6546988b407bcb43bd6942d51ee63e5c5b5189d2f19ec39e98cf36ddb32b6148
MD5 c2a278bb2a5272b38ba619276ded2cae
BLAKE2b-256 430941e2424c6c5bef74fcecc1b9f46990515dfa1c8807ecf8069f64dacd0b65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pipetee-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pipetee-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1ffa7f8e6c3c5fb47cff6a8f360876fbd1d21dd88d0460a1954bd1abf3fc74e
MD5 694bdea465172b42ac858a059695ee71
BLAKE2b-256 53d6ff0005af269c84e3b5f78de721a9f9ad69ecf3569711f363331b9a77ccd4

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