Piperun - Command Pipeline Framework for Python
piperun is a flexible framework for building and executing command pipelines in Python. It provides tools for running shell commands, creating task pipelines, and executing operations in parallel.
Overview
piperun simplifies the process of building complex command workflows by providing:
- Command construction and execution with detailed control
- Sequential pipeline execution
- Parallel processing capabilities
- Integration with Dask for distributed computation
piperun was designed with the following principles in mind:
- Simplicity: Easy to use with intuitive interfaces
- Flexibility: Works with any callable or command
- Composability: Build complex workflows from simple pieces
- Performance: Efficient execution with parallel processing capabilities
- Control: Detailed control over execution flow
Installation
Install piperun using pip:
pip install piperun
Install from source in editable mode:
git clone https://github.com/franioli/piperun.git
cd piperun
pip install -e .
Core Components
Command
The Command class provides an intuitive interface for constructing and executing shell commands:
from piperun import Command
# Create a simple command
cmd = Command("ls -l")
cmd.run()
# Add arguments dynamically
cmd = Command("parallel_stereo")
cmd.extend("image1.tif", "image2.tif", t="rpc", max_level=2)
cmd.run()
Key features:
- Handles both positional and keyword arguments
- Converts Python arguments to command-line format
- Provides execution timing
- Captures command output
- Supports boolean flags and various parameter formats
Pipeline
The Pipeline class enables chaining multiple processing steps:
from piperun import Pipeline, Command
# Create a pipeline
pipeline = Pipeline()
# Add steps
pipeline.add_step(Command("mkdir -p output"))
pipeline.add_step(Command("convert input.jpg output/output.png"))
# Execute all steps
pipeline.run()
Features:
- Sequential execution of steps
- Control for running specific steps or ranges
- Support for any step with a
run()method - Nested pipeline capability
DelayedTask
The DelayedTask class integrates with Dask for delayed execution:
from piperun import DelayedTask
# Create a delayed task
def process_data(x):
return x * 2
task = DelayedTask(process_data, 10)
result = task.compute() # Executes when needed
Features:
- Lazy evaluation of tasks
- Execution timing measurement
- Visualization of task graphs
ParallelBlock
The ParallelBlock class enables concurrent execution of multiple steps:
from piperun import ParallelBlock, Command
# Create commands
commands = [
Command(f"process_file {i}.txt")
for i in range(10)
]
# Run in parallel
with ParallelBlock(commands, workers=4) as block:
block.run()
Features:
- Automatic Dask cluster management
- Configurable worker count
- Support for both Command and DelayedTask objects
Advanced Usage
Pipeline Composition
Pipelines can be composed of various step types, including other pipelines:
# Create nested pipelines
preprocessing = Pipeline([
Command("clean_data input.csv"),
Command("validate_data input.csv")
])
processing = Pipeline([
Command("process_data input.csv output.csv")
])
# Combine pipelines
main_pipeline = Pipeline()
main_pipeline.add_step(preprocessing)
main_pipeline.add_step(processing)
main_pipeline.run()
Parallel Execution with Custom Worker Count
# Run operations in parallel with custom worker count
parallel_tasks = ParallelBlock(workers=8)
for file in input_files:
parallel_tasks.add_step(Command(f"process {file}"))
parallel_tasks.run()
Flow Control in Pipelines
# Run specific pipeline segments
pipeline = Pipeline([...])
# Run only step 3
pipeline.run_step(3)
# Run from step 2 to the end
pipeline.run_from_step(2)
# Run up to step 4 (not including step 4)
pipeline.run_until_step(4)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for piperun 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| piperun-0.2.0.tar.gz | 18.1 kB | With provenance | Details for piperun-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| piperun-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for piperun-0.2.0-py3-none-any.whl |
Total release size: 31.6 kB
Release files / piperun-0.2.0.tar.gz
| Download URL | piperun-0.2.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe6a80194422b81ee7c15e2745c0025efd38cbe3d229aaf4d7b952269b6000d0
|
|
BLAKE2b-256 checksum How to use checksums |
6d2daa451197972ca84a4ab4875980ddf19af8f779125804366df20898dd4a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logRelease files / piperun-0.2.0-py3-none-any.whl
| Download URL | piperun-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46c88f380f87a004c59f2ea0afd169765d35b0d904fc3800b015e7c33d787331
|
|
BLAKE2b-256 checksum How to use checksums |
296dec22a73f122f1061e157735d0a6127aed1eac294dc98eeaf2e97a96551c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logSecurity for piperun 0.2.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for piperun-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2025.
Transparency logA 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.