Zenaton client library
Project description
Zenaton library for Python
This Zenaton library for Python lets you code and launch workflows using Zenaton platform. You can sign up for an account at https://zenaton/com
DISCLAIMER The Python library is currently in public beta. Please open an issue if you find any bugs.
Requirements
This package has been tested with Python 3.5.
Installation
Install from pip
pip install zenaton
Usage in plain Python
For more detailed examples, please check Zenaton Python examples.
Client Initialization
You will need to export three environment variables: ZENATON_APP_ID
, ZENATON_API_TOKEN
, ZENATON_APP_ENV
. You'll find them here.
Then you can initialize your Zenaton client:
import os
from dotenv import load_dotenv
# LOADING CONFIG FROM .env file
load_dotenv()
app_id = os.getenv('ZENATON_APP_ID')
api_token = os.getenv('ZENATON_API_TOKEN')
app_env = os.getenv('ZENATON_APP_ENV')
Writing Workflows and Tasks
Writing a workflow is as simple as:
class MyWorkflow(Workflow, Zenatonable):
def handle(self):
# Your Workflow implementation
MyTask().execute() # For example
We can create a workflow in workflows/my_workflow.py
.
Note that your workflow implementation should be idempotent. See documentation.
Writing a task is as simple as:
class MyTask(Task, Zenatonable):
def handle(self):
# Your Task implementation
And we can create a task in tasks/my_task.py
.
Launching a workflow
Once your Zenaton client is initialized, you can start a workflow with
MyWorkflow().dispatch()
Lauching a workflow
We can start a workflow from anywhere in our application code with:
MyWorkflow().dispatch()
Worker Installation
Your workflow's tasks will be executed on your worker servers. Please install a Zenaton worker on it:
$ curl https://install.zenaton.com | sh
that you can start and configure with
$ zenaton start && zenaton listen --env=.env --boot=boot.py
where .env
is the env file containing your credentials, and boot.py
is a file that will be included before each task execution - this file should load all workflow classes.
Documentation
Please see https://zenaton.com/documentation for complete documentation.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/zenaton/zenaton-Python. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The package is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the zenaton-Python project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Change Log
0.2.1
Reorganized modules
0.2.0
Full rewriting of the package
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.