Skip to main content

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)

pval = pipeline.run(5)
print(pval.result)
# 'Hello, 7'

Pipelines return a Pval object which can be chained directly to transforms to create new pipelines.

add_transform = Transform(lambda x: x + 2)
pipeline = Pipeline(add_transform >> add_transform)

pval = pipeline.run(2)
# pval.result - 6

second_pval = pval >> add_transform
# second_pval.result - 8

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litepipe-2.0.1b1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litepipe-2.0.1b1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file litepipe-2.0.1b1.tar.gz.

File metadata

  • Download URL: litepipe-2.0.1b1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for litepipe-2.0.1b1.tar.gz
Algorithm Hash digest
SHA256 c3d56a1811f297f2e09cab68d696bf8722e95353dfe77920054ada7c0cb82a46
MD5 b8fe4d1338df8c779d8b900761d525dc
BLAKE2b-256 09fbc4e055170975f4c5dc45fbdb059689e6282c851cd675207dce2c1f4a84ba

See more details on using hashes here.

File details

Details for the file litepipe-2.0.1b1-py3-none-any.whl.

File metadata

  • Download URL: litepipe-2.0.1b1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for litepipe-2.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 a95287dba1bc5ea23872e1985f03a2cee1fd42d322fb4f05af8eb9a279cb034d
MD5 a770af93d5d03adce59d41ddd72be0df
BLAKE2b-256 cb0823ad9a63146fe2db46d41c7527056e7d9b69ffe6925c819b0d712832fc12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page