Lightweight Python library for data pipelines
Project description
Litepipe
Lightweight Python module for building modules using syntax similar to Apache Beam.
Pipelines can be created using two classes provided in this package - Pipeline
and Transform
.
A Pipeline
is a one or more Transforms
which are essentially functions cast as a Transform
class so that they
can be easily chained together.
Once a Pipeline
is defined, inputs can be passed through using the run
functionality.
The output of the final step in the pipeline is returned from the run
function.
As mentioned above Transform
is basically a wrapper class for a function with an overloaded __rshift__
method.
This allows Transforms
to be chained together using a syntax like
transform_one >> transform_two
This package was born from my curiosity to how packages like Apache Beam and Apache Airflow use the greater than operator to chain functions.
Installation Instructions
pip install litepipe
Example Pipeline
Creating Transforms
Transforms can be easily created using multiple syntax
By first defining a function and passing it as a parameter to the Transform class
def add_two(x: int):
return x + 2
add_two_transfrom = Transform(add_two)
By passing a lambda function as a parameter
add_transform = Transform(lambda x: x + 2)
Wrapping the function with a decorator function that can be imported from the Transform module
@t
def print_and_divide(input, divider=4):
print(f"Input: {input} will be divided by {divider}")
return input / divider
Example Pipeline
add_transform = Transform(lambda x: x + 2)
hello_int = Transform(lambda x: f'Hello, {x}')
pipeline = Pipeline(add_transform >> hello_int)
result = pipeline.run(5)
# output - 'Hello, 7'
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
File details
Details for the file litepipe-1.0.0a5.tar.gz
.
File metadata
- Download URL: litepipe-1.0.0a5.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c8a3cd22f123007ae179816913eb99df10ad5720f8136b59ce31a6e426a686c |
|
MD5 | 61048c043bda362940e98953e20df57a |
|
BLAKE2b-256 | eebce9d6a3b2154a66e6a4b363d928bd1f1e79b35e189a25b08012eafda1d86c |
File details
Details for the file litepipe-1.0.0a5-py3-none-any.whl
.
File metadata
- Download URL: litepipe-1.0.0a5-py3-none-any.whl
- Upload date:
- Size: 4.0 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 | 5bbb0766640c7972c8e28e29888bdbfb3534d877437f046bedc6259ab27aa4ae |
|
MD5 | 9c136154341768974297c5b49f04fb34 |
|
BLAKE2b-256 | 2926ae8121eb4f56398fb0b548c19ec69cd150c2c8d769075eb7d85c5ae75335 |