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.0.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.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litepipe-2.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 50e4536247cd91862225d8ac6575ef370b1c83ac5ff8eef5b2ee1e965658f490
MD5 bde56af1b51f049efdd7833f6d734d95
BLAKE2b-256 919e2daaa6cfadab3cf5bd104e21e1d9f906d180520bd74dcc7ec23301b8ef91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: litepipe-2.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3870ea22c5be5e3dfca0c1b6590104f76a0690b23a73ea922dffd1e03bee7e4b
MD5 8bbddab9ea94e96fb219b56a86110512
BLAKE2b-256 59c8fb3c1737bf944ebbb1556df3affa953198f5a33bc921f20f687047ec65b1

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