Skip to main content

A lightweight, general purpose pipeline framework.

Project description

Documentation Status Codacy Badge Travis-CI Build Status Test-coverage PyPI Package latest release

A simplistic, general purpose pipeline framework, which can easily be integrated into existing (analysis) chains and workflows.

Installation

thepipe can be installed via pip:

pip install thepipe

Features

  • Easy to use interface and integration into existing workflows

  • Automatic provenance tracking (set Provenance().outfile to dump it upon program termination)

  • Modules can be either subclasses of Module or bare python functions

  • Data is passed via a simple Python dictionary from module to module (wrapped in a class called Blob which adds some visual candy and error reporting)

  • Integrated hierarchical logging system

  • Colour coded log and print messages (self.log() and self.cprint() in Modules)

  • Performance statistics for the whole pipeline and each module individually

  • Clean exit when interrupting the pipeline with CTRL+C

The Pipeline

Here is a basic example how to create a pipeline, add some modules to it, pass some parameters and drain the pipeline.

Note that pipeline modules can either be vanilla (univariate) Python functions or Classes which derive from thepipe.Module.

import thepipe as tp


class AModule(tp.Module):
    def configure(self):
        self.cprint("Configuring AModule")
        self.max_count = self.get("max_count", default=23)
        self.index = 0

    def process(self, blob):
        self.cprint("This is cycle #%d" % self.index)
        blob['index'] = self.index
        self.index += 1

        if self.index > self.max_count:
            self.log.critical("That's enough...")
            raise StopIteration
        return blob

    def finish(self):
        self.cprint("I'm done!")


def a_function_based_module(blob):
    print("Here is the blob:")
    print(blob)
    return blob


pipe = tp.Pipeline()
pipe.attach(AModule, max_count=5)  # pass any parameters to the module
pipe.attach(a_function_based_module)
pipe.drain()  # without arguments it will drain until a StopIteration is raised

This will produce the following output:

2020-05-26 12:43:12 ++ AModule: Configuring AModule
Pipeline and module initialisation took 0.001s (CPU 0.001s).
2020-05-26 12:43:12 ++ AModule: This is cycle #0
Here is the blob:
Blob (1 entries):
'index' => 0
2020-05-26 12:43:12 ++ AModule: This is cycle #1
Here is the blob:
Blob (1 entries):
'index' => 1
2020-05-26 12:43:12 ++ AModule: This is cycle #2
Here is the blob:
Blob (1 entries):
'index' => 2
2020-05-26 12:43:12 ++ AModule: This is cycle #3
Here is the blob:
Blob (1 entries):
'index' => 3
2020-05-26 12:43:12 ++ AModule: This is cycle #4
Here is the blob:
Blob (1 entries):
'index' => 4
2020-05-26 12:43:12 ++ AModule: This is cycle #5
2020-05-26 12:43:12 CRITICAL ++ AModule: That's enough...
2020-05-26 12:43:12 ++ AModule: I'm done!
============================================================
5 cycles drained in 0.001284s (CPU 0.001475s). Memory peak: 27.01 MB
wall  mean: 0.000070s  medi: 0.000052s  min: 0.000042s  max: 0.000122s  std: 0.000031s
CPU   mean: 0.000070s  medi: 0.000052s  min: 0.000042s  max: 0.000124s  std: 0.000032s

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

thepipe-1.3.3.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

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

thepipe-1.3.3-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file thepipe-1.3.3.tar.gz.

File metadata

  • Download URL: thepipe-1.3.3.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for thepipe-1.3.3.tar.gz
Algorithm Hash digest
SHA256 a8a9e4f81f69bff83e2a69d58c8b9dce35e1b0b5da4da5762f166033880cc638
MD5 0b95f0d530c597d38a1ac59394382c96
BLAKE2b-256 7b29f229622d8d046eadbc29bbeef1c40933985452a379b9e1367c1f8f3e1388

See more details on using hashes here.

File details

Details for the file thepipe-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: thepipe-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for thepipe-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 61b2c5618582248e3c3a42d66aa6af620e4e032f6225a00a425b81122ce0726c
MD5 8170ef08d1342b924a3cadcb4a544efe
BLAKE2b-256 5cb8a171ac0a2e6fd05d3de0d24807fa8f29e65302c7620d35c9cf35bf0bb23a

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