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.1.tar.gz (3.9 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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litepipe-2.0.1.tar.gz
  • Upload date:
  • Size: 3.9 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.1.tar.gz
Algorithm Hash digest
SHA256 21806a4cc042c945d64202ee1edfd5a3ff8065484bc782c2c83c7e85cf3a9d68
MD5 e5796bbe02948e79ec5ed6226da11aa7
BLAKE2b-256 7f8ae93b9408e3dff79718c23946984b4bdf7f72bae87cb8fdd969515cd212a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: litepipe-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae0be22e344032e2a740111f7825cbfada79160b7663167119eef0fae7664f5b
MD5 e3df1bd7546ef0f19745d3f3a5e2e98d
BLAKE2b-256 b716a6abb35c6073725dafdbe31c48ce1d175569622a1e50df7599b3b0b46149

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