Skip to main content

Simple workflows for Python

Project description

Simple worfklows for Python
-------------------------------------

Wofklow engine is a Finite State Machine with memory
It is used to execute set of methods in a specified order.

Here is a simple example of a configuration:

[
check_token_is_wanted, # (run always)
[ # (run conditionally)
check_token_numeric,
translate_numeric,
next_token # (stop processing, continue with next token)
],
[ # (run conditionally)
check_token_proper_name,
translate_proper_name,
next_token # (stop processing, continue with next token)
],
normalize_token, # (only for "normal" tokens)
translate_token,
]

You can probably guess what the processing pipeline does with tokens - the
whole task is made of four steps and the whole configuration is just stored
as a Python list. Every task is implemeted as a function that takes two objects:

* currently processed object
* workflow engine instance

Example:

def next_token(obj, eng):
eng.ContinueNextToken()

There are NO explicit states, conditions, transitions - the job of the engine is
simply to run the tasks one after another. It is the responsibility of the task
to tell the engine what is going to happen next; whether to continue, stop,
jump back, jump forward and few other options.

This is actually a *feature*, I knew that there will be a lot of possible
exceptions and transition states to implement for NLP processing and I also
wanted to make the workflow engine simple and fast -- but it has disadvantages,
you can make more errors and workflow engine will not warn you.

The workflow module comes with many patterns that can be directly used in the
definition of the pipeline, such as IF, IF_NOT, PARALLEL_SPLIT and others.

This version requires Python 2 and many of the workflow patterns (such as IF,
XOR, WHILE) are implemented using lambdas, therefore not suitable for Python 3.

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

workflow-1.01.tar.gz (37.3 kB view hashes)

Uploaded Source

Built Distribution

workflow-1.01-py2.6.egg (70.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page