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:
-
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
-
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
- Clone the repository
- Install development dependencies:
python -m pip install -e ".[dev,viz]"
- Run tests:
pytest
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6546988b407bcb43bd6942d51ee63e5c5b5189d2f19ec39e98cf36ddb32b6148
|
|
| MD5 |
c2a278bb2a5272b38ba619276ded2cae
|
|
| BLAKE2b-256 |
430941e2424c6c5bef74fcecc1b9f46990515dfa1c8807ecf8069f64dacd0b65
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1ffa7f8e6c3c5fb47cff6a8f360876fbd1d21dd88d0460a1954bd1abf3fc74e
|
|
| MD5 |
694bdea465172b42ac858a059695ee71
|
|
| BLAKE2b-256 |
53d6ff0005af269c84e3b5f78de721a9f9ad69ecf3569711f363331b9a77ccd4
|