Skip to main content

Python pipeline library developed by STYLIGHT.

https://travis-ci.org/stylight/python-paipa.svg?branch=master

Installation

pip install paipa

Overview

What it does:

  • process stuff one step at a time

  • allows class based and function based steps

  • can scale steps independent of each other (manually)

  • don’t ever do deadlocks

  • never expose the developer to the concept of a thread (if she doesn’t like to)

  • run in finite batches where all threads are terminated at the end

  • run in continuous mode while being fed through a queue

  • automatically rate limit each step to minimize memory usage

  • terminate the pipeline in case of an Exception and propagate the error to the developer

What it explicitly doesn’t do (if it doesn’t, it’s not a bug!):

  • pipelines with multiple different parents. Multiple parents of the same type are handled automatically though.

  • auto-scale threads

  • bake bread

What it shouldn’t do (if it does, it’s a bug!):

  • confuse the user/developer

  • hang on termination

  • hog resources

Features

The lib allows for threaded pipelines as well as so-called co-routine pipelines. The main use-case is limiting peak memory usage when doing complex operations on large-ish data-sets.

>>> pipeline = paipa.Pipeline(
...     (DownloadImage, 4),
...     (StoreDatabase, 1),
... )
>>> pipeline.run()

This example will create 5 threads, 4 for downloading images, one for storing stuff to the database. The ouputs of all DownloadImage steps will be forwared to the one StoreDatabase thread via a Queue.

Thread startup and tear-down is handled by the library and doesn’t concern the programmer at all. All (known) failure cases lead to either a re-spawning of the failed thread or a controlled shutdown of the system. In no case the system should block and do nothing, if it does then it’s definitely a bug and needs to be reported.

Pipeline ingestion can be done via a separate thread or by consuming an iterable. In the case of using an iterable, an ingestion thread is created which consumes the iterable in a controled manner.

The whole pipeline can also be run in the background like this:

>>> pl = pipeline.run_forever(background=True)
>>> # do some other stuff
>>> pl.stop()  # this waits for the system to complete and do a shutdown

Co-Routine Pipelines

>>> def remove_odd(iterable):
...     for entry in iterable:
...         if entry % 2 == 0:
...             yield entry
>>> steps = [remove_odd] # Arbitrary many steps supported
>>> gen = combine_pipeline(range(100), steps)
>>> print(sum(gen))
2450

This will create nested generators which do the relevant processing. The individual steps only need to support the iterator protocol and don’t necessarily need to be generators. Memory usage may make using generators appealing though.

Download files

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

Source Distribution

paipa-0.3.1.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

paipa-0.3.1-py2.7-linux-x86_64.egg (229.2 kB view details)

Uploaded Egg

File details

Details for the file paipa-0.3.1.tar.gz.

File metadata

  • Download URL: paipa-0.3.1.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for paipa-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8eac674601e631322a00058fc8baa800a092ef06510095605aa51f34672521b5
MD5 7e2e2bb2fabac91ef881d328b6fc3eb6
BLAKE2b-256 041479e073a4c95ae1eddc155cbc49e49edf85197362362ac85836fee0f9072f

See more details on using hashes here.

File details

Details for the file paipa-0.3.1-py2.7-linux-x86_64.egg.

File metadata

File hashes

Hashes for paipa-0.3.1-py2.7-linux-x86_64.egg
Algorithm Hash digest
SHA256 3c27732a7b39d5ebef12f27b559a0b3767a27cbef3ea3d117d473b66c209bf9b
MD5 47939a4b6945d1d69c249e8bd318fd86
BLAKE2b-256 bdc87f4419b1317ccfc14970a80149e405dbaf1122f1b715ba2eb6b491fbf1aa

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

1 file

0.3.2

1 file

This release

0.3.1 This release

2 files

0.3.0

1 file

0.2.1

1 file

0.2.0

1 file

0.1.1

1 file

0.1.0

1 file

0.0.2

1 file

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