A utility package for chaining and pipeline operations with enhanced logging and timing.
Project description
ChainPipe
ChainPipe is a Python package designed to facilitate efficient and modular handling of operations in a chain or pipeline manner. It provides two primary classes, Chain and Pipeline, which allow for sequential and independent operation executions respectively, with enhanced capabilities for logging and timing.
Features
- Chain: Manage a sequence of operations where the output of one operation is the input to the next.
- Pipeline: Execute a sequence of independent operations.
- Timer: Utility for timing operations, useful for performance analysis.
- Logger: Enhanced logging capabilities to track operation execution and errors.
Installation
Install ChainPipe using pip:
'pip install ChainPipe'
Or, if you want to install from source:
'git clone https://github.com/ayman3000/ChainPipe.git cd ChainPipe python setup.py install'
Usage
Below are quick examples on how to use the Chain and Pipeline classes:
Chain Example
from chainpipe.chain import Chain
def multiply_by_two(x):
return x * 2
def add_five(x):
return x + 5
chain = Chain() | multiply_by_two | add_five
result = chain.execute(3)
print("Result:", result)
Additional Chain Example Using add_operation
from chainpipe.chain import Chain
def multiply_by_three(x):
return x * 3
def subtract_two(x):
return x - 2
chain = Chain()
chain.add_operation(multiply_by_three)
chain.add_operation(subtract_two)
result = chain.execute(4)
print("Result:", result)
Pipeline Example
from chainpipe.pipeline import Pipeline
def initialize_system():
print("System initialized")
def perform_checks():
print("Checks performed")
pipeline = Pipeline() | initialize_system | perform_checks
pipeline.execute()
Additional Pipeline Example Using add_operation
from chainpipe.pipeline import Pipeline
def load_configuration():
print("Configuration loaded")
def start_services():
print("Services started")
pipeline = Pipeline()
pipeline.add_operation(load_configuration)
pipeline.add_operation(start_services)
pipeline.execute()
Contributing
Contributions are welcome! Please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Contact
For any questions or feedback, please reach out to ayman3000@gmail.com.
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 ChainPipe-0.1.1.tar.gz.
File metadata
- Download URL: ChainPipe-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
678693a737fc8e7f669b779c388bba31ec40d44b93adbd5e008580d538f2d3bb
|
|
| MD5 |
0d5c04f22adbf4b13afd0ff1a853b107
|
|
| BLAKE2b-256 |
b2d0a461f0bd9237754ac178d05a4c8cb44a55d41ca1df5526ab70f5c7ec11b3
|
File details
Details for the file ChainPipe-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ChainPipe-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe66a67b6790516664beca744a5bbd4cdd0fe20b6cac835800dcc80dd6b667ae
|
|
| MD5 |
c77abf4c672f7630cc68011f2693c69e
|
|
| BLAKE2b-256 |
18e887665db918808bcc4aa295f3f8b6486122f1d5b9e8c8738b06e8f5e806e8
|