SimplePipeline
A lightweight Python library for building and executing data pipelines with logging and error handling.
📖 Features
✅ Define data pipelines with processing steps, conditions, and outputs
✅ Support multiple ingests (data sources)
✅ Graceful failure handling with logging
✅ Customizable logging with plug-and-play loggers (FileLogger)
✅ Filter logs by level (INFO, SUCCESS, ERROR)
✅ Visualize the pipeline with an interactive graph
📥 Installation
Prerequisites
Ensure you have Python 3.9+ installed. You can check your Python version with:
python --version
Installing SimplePipeline
To install SimplePipeline, run the following command:
pip install simple-pipelines
📝 Usage
Creating a Pipeline
To create a pipeline, import the SimplePipeline class from the simple_pipelines module:
from simple_pipelines import SimplePipeline
Create a new pipeline instance:
pipeline = SimplePipeline("My Pipeline")
Adding Ingests
Ingests are functions that return data. You can add ingests to your pipeline using the create_ingest method:
def ingest_users():
return pd.DataFrame({
"ID": [1, 2, 3, 4, 5],
"Age": [25, 32, 40, 23, 36],
"Score": [80, 90, 85, 78, 88]
})
pipeline.create_ingest(ingest_users, "Users")
The create_ingest method takes two arguments: the ingest function and a name for the ingest. The ingest function should return a pandas.DataFrame or a dictionary.
Adding Steps
Steps are functions that process data. You can add steps to your pipeline using the pipe method:
def process_users(input, ingests):
df = ingests["Users"].copy()
df["B"] = df["Age"] * 2
return df
pipeline.pipe(process_users, "Process Users")
The pipe method takes two arguments: the step function and a name for the step. The step function should take two arguments: input, which is the output of the previous step, and ingests, which is a dictionary containing all ingests. The step function should return the processed data.
Adding Conditions
Conditions are functions that evaluate whether a step should be executed. You can add conditions to your pipeline using the condition method:
def is_vip(input, ingests):
return input["Purchase_Amount"].sum() > 150
def branch_vip(input, ingests):
input["Classification"] = "VIP"
return input
def branch_regular(input, ingests):
input["Classification"] = "Regular"
return input
pipeline.condition(
conditions={is_vip: branch_vip},
default_branch=branch_regular,
name="Check VIP Status"
)
The condition method takes three arguments: a dictionary of conditions and their corresponding branches, a default branch, and a name for the condition. The conditions should be functions that take two arguments: input, which is the output of the previous step, and ingests, which is a dictionary containing all ingests. The branches should be functions that take two arguments: input, which is the output of the previous step, and ingests, which is a dictionary containing all ingests. The default branch should be a function that takes two arguments: input, which is the output of the previous step, and ingests, which is a dictionary containing all ingests.
Adding Outputs
Outputs are functions that do not return data. You can add outputs to your pipeline using the output method:
def final_output(input):
print("Final Processed Data:")
print(input)
pipeline.output(final_output, "Final Output")
The output method takes two arguments: the output function and a name for the output. The output function should take one argument: input, which is the output of the previous step.
Executing the Pipeline
To execute the pipeline, call the execute method:
pipeline.execute()
The execute method returns the output of the last step, or None if the pipeline fails.
Visualizing the Pipeline
To visualize the pipeline, call the visualize method:
pipeline.visualize()
This will generate an interactive left-to-right visualization of the pipeline using Plotly.
📝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Create a pull request to the main repository.
📝 License
This project is licensed under the MIT License.
Metadata
Release files for simple-pipelines 0.1.4
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 |
|---|---|---|---|---|
| simple_pipelines-0.1.4.tar.gz | 5.8 kB | Without provenance | Details for simple_pipelines-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_pipelines-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for simple_pipelines-0.1.4-py3-none-any.whl |
Total release size: 12.8 kB
Release files / simple_pipelines-0.1.4.tar.gz
| Download URL | simple_pipelines-0.1.4.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b26f76d2abb8de165a5dbbefe3294445cf2c0b6903e842cdee6b60daaff3f1d
|
|
BLAKE2b-256 checksum How to use checksums |
de5e37cd1ae05895215961ab056f4db760fc501d084ef7fedb35c4960c52c41b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Release files / simple_pipelines-0.1.4-py3-none-any.whl
| Download URL | simple_pipelines-0.1.4-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c16109d64df1eaf94f962bb201db39461c2b1536dfd2998b3348fd433ccdba22
|
|
BLAKE2b-256 checksum How to use checksums |
5a4bf5d81d964219c2c13d90a18d2bc02afc6c1e033f59bce9adb1df3a57f8fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.13.2 Linux/6.8.0-1021-azure
|
Security for simple-pipelines 0.1.4
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.