Skip to main content

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.5] - 2018/10/17

Object Serialization (including circular structures)

[0.2.4] - 2018/09/26

Enhanced WithDuration & WithTimestamp classes

[0.2.3] - 2018/09/21

Minor enhancements (including the workflow find() method)

[0.2.2] - 2018/09/19

New version scheme management

[0.2.1] - 2018/09/17

Reorganized modules

[0.2.0] - 2018/09/14

Full rewriting of the package

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zenaton-0.2.5.tar.gz (20.1 kB view hashes)

Uploaded Source

Built Distribution

zenaton-0.2.5-py3-none-any.whl (29.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page