Skip to main content
=======================================================
py_swf
=======================================================

.. image:: https://travis-ci.org/Yelp/pyswf.svg?branch=master
:target: https://travis-ci.org/Yelp/pyswf

.. image:: https://coveralls.io/repos/github/Yelp/pyswf/badge.svg?branch=master
:target: https://coveralls.io/github/Yelp/pyswf?branch=master

.. image:: https://readthedocs.org/projects/py-swf/badge/?version=latest
:target: http://py-swf.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://img.shields.io/pypi/v/py-swf.svg
:target: https://pypi.python.org/pypi/py-swf/

py_swf is a library that provides a pythonic way to interact with the boto3 SWF client. It provides a thin client above boto3 and tries to provide the same API as boto3's SWF client. This library tries to group the API calls into SWF's framework of deciders, activity runners, and a client that can initiate and terminate workflows. More information on inputs to boto3 can be found in the boto3 :class:`~SWF.Client` class.

The library provides 4 clients:
- A client that allows starting and force-termination of workflows.
- A client that can poll for decision tasks and respond to decision tasks.
- A client that can poll for activity tasks and respond to activity tasks.
- A client that can perform registration of workflows in SWF.

Consumers of this library are expected to write their own daemons that enact business logic.

Example daemon that listens on decision tasks

.. code-block:: python

import boto3
from py_swf.config_definitions import DecisionConfig
from py_swf.clients.decision import DecisionClient

boto_client = boto3.Session(...).client('swf')
decision_config = DecisionConfig(...)

client = DecisionClient(decision_config, boto_client)

while True:
task = client.poll()

... = perform_decision_task(task)

client.finish_decision_with_activity(
task.task_token,
...
)

The heart of the daemon is the :class:`~py_swf.clients.decision.DecisionClient`. You must provide a valid bare boto3 client, and :class:`~py_swf.config_definitions.DecisionConfig` which represents common SWF inputs, such as domain, and some timeouts.

Likewise, you must implement an activity runner:

.. code-block:: python

import boto3
from py_swf.config_definitions import ActivityTaskConfig
from py_swf.clients.activity_task import ActivityTaskClient

boto_client = boto3.Session(...).client('swf')
activity_task_config = ActivityTaskConfig(...)

client = ActivityTaskClient(decision_config, boto_client)

while True:
task = client.poll()

result = perform_activity_task(task.input)

client.finish(
task_token=task.task_token,
result=result,
)

Activity task runners are very similar to deciders. However, they don't have any information of the workflow, and only perform one task given an input and responds with an output.



Documentation
-------------

The full documentation is at http://py-swf.readthedocs.io/en/latest/



History
-------

1.3.0 (2016-12-12)
++++++++++++++++++

* WorkflowClient now supports count open or closed workflows by filter. Filter includes start time, close time, workflow type, tag, workflow id and close status.

1.1.0 (2016-10-03)
++++++++++++++++++

* Update botocore version to 1.4.46

1.0.0 (2016-09-09)
++++++++++++++++++

* Initial release of py_swf


Release files for py-swf 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-swf 1.3.0
File Size Uploaded
py-swf-1.3.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-swf 1.3.0
File Interpreter ABI Platform
py_swf-1.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 24.9 kB

Release files / py-swf-1.3.0.tar.gz

Download URL py-swf-1.3.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
210a9879c268917ecc2431786790319c51875fba00652555ec9249e31690d48c
BLAKE2b-256 checksum
How to use checksums
a0582807b5bc6801b6b7c7cdfc2846e376cae67ab2649186c3eebb9bcbb704e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / py_swf-1.3.0-py2.py3-none-any.whl

Download URL py_swf-1.3.0-py2.py3-none-any.whl
Size 14.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f91bbc4bead0392b7e4e9eb9eef495a55b06c90dcba33990cde04456720c1072
BLAKE2b-256 checksum
How to use checksums
e3cfaad367ed3c0c5de18eba8a75c2c66d70b6e0e0a00c96bc59da9174ef901b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page