Skip to main content

Pyppo is a small flow based programming micro framework

Project description

Pyppo is a simple flow base programming micro framework for Python.

Examples

Simple pipeline

This is an example of a very simple pipeline. Simply pass a list functions to be executed at the pipeline execution.

obj = []

def do_something(obj):
    obj.append(1)
    return obj

def do_something_else(obj):
    obj.append(2)
    return obj

consume(pipeline([obj], [do_something, do_something_else]))

print(obj)
[1, 2]

Fork pipeline

This example shows a fork of a pipeline. fork is essentially another pipeline steps except it acceptes a list of function branches.

obj = []
def first_step(obj):
    obj.append(1)
    return obj

def branch_add_two(obj):
    obj.append(2)
    return obj

def branch_add_four(obj):
    obj.append(4)
    return obj

pipeline([obj], first_step, fork([branch_add_two], [branch_add_four]))

Validate pipeline steps

You can also validate pipeline steps by providing a validate function to the validate_with decorator as shown on the following example

validation = lambda entry: 'x' in entry

def add_x_to_entry(entry):
    # should add 'x' key to entry dictionary but didn't
    return entry

@validate_with(validation)
def increment_1_on_x_key(entry):
    entry['x'] += 1
    return entry

entry = {}
# consume will saise a StepValidationError
consume(pipeline([entry], [add_x_to_entry, increment_1_on_x_key]))

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

Pyppo-0.1.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file Pyppo-0.1.tar.gz.

File metadata

  • Download URL: Pyppo-0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Pyppo-0.1.tar.gz
Algorithm Hash digest
SHA256 c829e4470a392f70394b30f8090a429b4c9302cf1402b525610c474794526954
MD5 64ed7cf7b8162612696cc4cd8b9e05e7
BLAKE2b-256 a10527a1787d0aa95e6a69de95690b03ae4d4c23bd5b9cf036513950be5c7c9d

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