GitHub Read the Docs Travis (.org) PyPI PyPI - Python Version

WfEpy (Workflow Engine for Python) is Python library for creating workflows and automating processes. It is designed to be as simple as possible so developers can focus on tasks logic, not how to execute workflow, store state, etc.


Basic features

The library provides the following features:

  • Workflow defined in code, via decorators
  • Flat workflow structure
  • Visualisation features (via graphviz)
  • Partial execution model (workflow can be triggered multiple times until final completion)
  • Allows long running tasks (can be weeks/months or more) without persistent processes
  • No scheduler included, but can be triggered by cron
  • Serialization / deserialization included
  • Multiple start and end points are supported

The library adds some restrictions:

  • Workflow functions must return boolean, where:
    • True means the task has completed and workflow can be advanced
    • False means the task is still waiting (e.g. for user input)
  • Workflow functions carry around a context object (normally a dict)


The workflow is defined via decorators attached to functions, such as:

def start(context):

def make_coffee(context):

def drink_coffee(context):

def end(context):

A function can be followed by multiple functions:

def make_coffee(context):

A function can be conditionally followed by another function:

# only make foam when we've been requested 'cappucino'
@wfepy.followed_by('make_foam', lambda context:'cappucino'))
# always add milk
def make_coffee(context):

Execution model

WfEpy does not provide any scheduler, but can be triggered by cron. It works on a partial-execution model, meaning it can be triggered multiple times.

The workflow is attempted on every execution, but will only end when at least one of the end points have been reached. If the workflow can’t be ended during an execution, then the state (including user data and currently-waiting tasks) is exported/serialized for the next attempt.

import coffee_workflow

wf = wfepy.Workflow()

runner = wf.create_runner()
if restore_state:


This simple design provides many options on workflow execution and customization. Most workflow libraries out there require external dependencies like databases, message bus/queue systems etc. Our library requires no such things, just python and its package dependencies.


Install it using pip

pip3 install wfepy

or clone repository

git clone
cd wfepy

and install Python package including dependencies

python3 install