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.
-------------------------------------
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
Release history Release notifications | RSS feed
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 details)
Built Distribution
workflow-1.01-py2.6.egg
(70.4 kB
view details)
File details
Details for the file workflow-1.01.tar.gz
.
File metadata
- Download URL: workflow-1.01.tar.gz
- Upload date:
- Size: 37.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c4e6c025a0f71d1786b7439dae6b21dc7dcf5e347a57e944ef60669a59eb1d8 |
|
MD5 | 1aa206c79ba6dcc736d570cc65650437 |
|
BLAKE2b-256 | 555877d587dd5496966c7dec28053b7ff9e3ffb8e1dc689e1da87dbd20a45d76 |
File details
Details for the file workflow-1.01-py2.6.egg
.
File metadata
- Download URL: workflow-1.01-py2.6.egg
- Upload date:
- Size: 70.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5909ef2f3acd3dd16e91bfd0592fa29003f11d37bd0a8c68d54e4b29fb0c17f |
|
MD5 | 55f47cd5b7b9186bcdbaff1e88b760e7 |
|
BLAKE2b-256 | eb80dd6fe000272599ce04ce849e1a2a176c2164abcf9c94b316f6abe1eb1819 |