sfini
Create, run and manage AWS Step Functions easily. Pronounced "SFIN-ee".
This package aims to provide a user-friendly interface into defining and
running Step Functions. Things you can do in sfini to interact with AWS Step
Functions:
- Implement and register activities
- Define and register state machines
- Start, track and stop executions
- Run workers for activities
- Get information for registered activities and state machines
- De-register state machines and activities
Note: this is not a tool to convert Python code into a Step Functions state machine. For that, see pyawssfn.
Getting started
Prerequisites
- AWS (Amazon Web Services) account, with access to Step Functions
- AWS IAM (Identity and Access Management) credentials
Installation
pip install sfini
Usage
Documentation
Check the documentation or use the built-in help:
pydoc sfini
import sfini
help(sfini)
AWS Step Functions
AWS Step Functions (SFN) is a workflow-management service, providing the ability to coordinate tasks in a straight-forward fashion. Further documentation can be found in the AWS documentation.
Usage of Step Functions consists of two types: state-machines and activities. A state-machine is a graph of operations which defines a workflow of an application, comprised of multiple types of "states", or stages of the workflow. An activity processes input to an output, and is used to process a task "state" in the state-machine (multiple task states can have the same activity assigned it.
Once a state-machine is defined and registered (along with the used
activities), you run executions of that state-machine on different inputs to
run the workflow. sfini allows you to start, stop and get the history of
these executions.
State-machines support conditional branching (and therefore loops), retries (conditional and unconditional), exception-catching, external AWS service support for running tasks, parallel execution and input/output processing. External services including AWS Lambda, so you don't have to deploy your own activity runners.
Once state-machines and activities are defined and registered, you can view and update their details in the SFN web console.
Role ARN
Every state-machine needs a role ARN (Amazon Resource Name). This is an AWS IAM role ARN which allows the state-machine to process state executions. See AWS Step Functions documentation for more information.
Example
More examples found in the documentation.
import sfini
# Define activities
activities = sfini.ActivityRegistration(prefix="test")
@activities.activity("addActivity")
def add_activity(data):
return data["a"] + data["b"]
# Define state-machine
add = sfini.Task("add", add_activity)
sm = sfini.construct_state_machine("testAdding", add)
# Register state-machine and activities
activities.register()
sm.register()
# Start activity worker
worker = sfini.Worker(add_activity)
worker.start()
# Start execution
execution = sm.start_execution(execution_input={"a": 3, "b": 42})
print(execution.name)
# testAdding_2019-05-13T19-07_0354d790
# Wait for execution and print output
execution.wait()
print(execution.output)
# 45
print(execution.format_history())
# ExecutionStarted [1] @ 2019-06-23 20:03:52.817000+10:00
# TaskStateEntered [2] @ 2019-06-23 20:03:52.840000+10:00:
# name: add
# ActivityScheduled [3] @ 2019-06-23 20:03:52.840000+10:00:
# resource: arn:aws:states:us-west-2:ACCID:activity:testaddActivity
# ActivityStarted [4] @ 2019-06-23 20:03:53.954000+10:00:
# worker: hostname-3a4fb480
# ActivitySucceeded [5] @ 2019-06-23 20:03:55.028000+10:00
# TaskStateExited [6] @ 2019-06-23 20:03:55.028000+10:00:
# name: add
# ExecutionSucceeded [7] @ 2019-06-23 20:03:55.028000+10:00
# Output: 45
# Stop activity workers
worker.end()
worker.join()
# Deregister state-machine and activities
activities.deregister()
sm.deregister()
Metadata
Release files for sfini 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sfini-0.1.0.tar.gz | 25.6 kB | Without provenance | Details for sfini-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sfini-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sfini-0.1.0-py3-none-any.whl |
Total release size: 56.2 kB
Release files / sfini-0.1.0.tar.gz
| Download URL | sfini-0.1.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94e908b5222467ed20739be5f091273c85c0452b893573c712cdd36b1091260c
|
|
BLAKE2b-256 checksum How to use checksums |
dc9ba9eca1d2743fa425028d28dee3456da6f9f0576308bf9c68c92a07e93b8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / sfini-0.1.0-py3-none-any.whl
| Download URL | sfini-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35de0e1fa281094805bdd5792dedd8354b348e6d0b80111738297414e2c6bcb8
|
|
BLAKE2b-256 checksum How to use checksums |
174a523ad21a99f0391751dd4495e87f13c17f9dbb6a77c394680479fc1ba6bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for sfini 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.