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.1.0.tar.gz
.
File metadata
- Download URL: litepipe-1.1.0.tar.gz
- Upload date:
- Size: 3.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 | c6bc2d24d86bc0ad97851578169d4791cac8c8ae9cdc1bf0133c6fb5ae65931c |
|
MD5 | ab66f878993644e7c119ad806a63a702 |
|
BLAKE2b-256 | 356cae139243bcfc9a46706389a2f7d2a4c3a3c212b0ed20cf4df3d9853c49a3 |
File details
Details for the file litepipe-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: litepipe-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 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 | 6903e7c107011054fe9ccd2eed5960adaa7218f72ab0a12518ebd3287b1311a5 |
|
MD5 | 882a85ab9a778c28f82028e62597645f |
|
BLAKE2b-256 | 40bba4ab93f6f7b2e1b5523599c546ee2e47aa0dfa493f957595598fa93137ac |