Skip to main content

picles.plumber

A simple data transformation pipeline based on python’s iteration protocol that runs on python versions 2.7, 3.3 and 3.4.

+----------+      +-------------+      +-------------+      +--------+      +----------+
| Producer | ---> | Transformer | ---> | Transformer | ---> | Tester | ---> | Consumer |
+----------+      +-------------+      +-------------+      +--------+      +----------+

A pipeline model expects 4 types of filters:

  • Producer: starting point, outbound only;

  • Transformer: input, processing, output;

  • Tester: input, discard or pass-thru;

  • Consumer: ending point, inbound only.

import plumber

@plumber.filter
def upper(data):
    return data.upper()

ppl = plumber.Pipeline(upper)
output = ppl.run("Hey Jude, don't make it bad")

print(''.join(output))
"HEY JUDE, DON'T MAKE IT BAD"

Since the design is based on python’s iteration protocol, both producers and consumers are ordinary iterable objects. Transformers are implemented as callables that accept a single argument, perform the processing and return the result.

Input data may also be checked against some preconditions in order to decide if the transformation should happen or be by-passed. For example:

import plumber

def is_vowel(data):
    if data not in 'aeiou':
        raise plumber.UnmetPrecondition()

@plumber.filter
@plumber.precondition(is_vowel)
def upper(data):
    return data.upper()

ppl = plumber.Pipeline(upper)
output = ppl.run("Hey Jude, don't make it bad")

print(''.join(output))
"hEy jUdE, dOn't mAkE It bAd"

Prefetching

If you think the pipes are taking too long to move data forward, you can use a prefetching feature. To use it, just define the upper limit of items to be pre fetched.

Using the same example as above:

ppl = plumber.Pipeline(stripper, upper)
transformed_data = ppl.run([" I am the Great Cornholio!", "Hey Jude, don't make it bad "],
                           prefetch=2)

for td in transformed_data:
    print(td)

I AM THE GREAT CORNHOLIO!
"HEY JUDE, DON'T MAKE IT BAD"

By default the prefetching mechanism is thread-based, so be careful with cpu-bound pipelines.

Installation

Pypi (recommended):

$ pip install picles.plumber

Source code (development version):

$ git clone https://github.com/picleslivre/plumber.git && cd plumber && python setup.py install

Use license

This project is licensed under FreeBSD 2-clause. See LICENSE for more details.

Metadata

Release files for picles.plumber 0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picles.plumber 0.11
File Size Uploaded Provenance Actions
picles.plumber-0.11.tar.gz 4.9 kB Without provenance Details for picles.plumber-0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for picles.plumber 0.11
File Interpreter ABI Platform Actions
picles.plumber-0.11-py2.py3-none-any.whl Python 3, Python 2 none any Details for picles.plumber-0.11-py2.py3-none-any.whl

Total release size: 11.9 kB

Release files / picles.plumber-0.11.tar.gz

Download URL picles.plumber-0.11.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dfeebfc1b37fb384846a3c2650814aed0803ad4a360a8e7195f0fc9e0c5b9a89
BLAKE2b-256 checksum
How to use checksums
0d3c932f2464d9ae4664c73f20791412a2a88d55d0f4524ce818d8635f60ef0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / picles.plumber-0.11-py2.py3-none-any.whl

Download URL picles.plumber-0.11-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cebb5ed132f43b33be0fa14bf2ffadb2aaf14b9f26af90441840e576ba6e0ffe
BLAKE2b-256 checksum
How to use checksums
19cd7445ba7b97c8ac6fd934f7cda7ca5d0ad905ab4925d06629bd5f1211c0dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for picles.plumber 0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page