Celery Director
Project description
Director is a simple and rapid framework used to manage tasks and build workflows using Celery.
The objective is to make Celery easier to use by providing :
- a WebUI, an API and a CLI to manage and execute the workflows,
- a WebUI to track the tasks states,
- a YAML syntax used to combine tasks into workflows,
- the ability to periodically launch a whole workflow,
- and many others.
See how to use Director with the quickstart and guides in the documentation.
Installation
Install the latest version of Director with pip (requires at least Python 3.7
):
pip install celery-director
Usage
Write your code in Python
# tasks/orders.py
from director import task
from .utils import Order, Mail
@task(name="ORDER_PRODUCT")
def order_product(*args, **kwargs):
order = Order(
user=kwargs["payload"]["user"],
product=kwargs["payload"]["product"]
).save()
return {"id": order.id}
@task(name="SEND_MAIL")
def send_mail(*args, **kwargs):
order_id = args[0]["id"]
mail = Mail(
title=f"Your order #{order_id} has been received",
user=kwargs["payload"]["user"]
)
mail.send()
Build your workflows in YAML
# workflows.yml
product.ORDER:
tasks:
- ORDER_PRODUCT
- SEND_MAIL
Run it
You can simply test your workflow in local :
$ director workflow run product.ORDER '{"user": 1234, "product": 1000}'
And run it in production using the director API :
$ curl --header "Content-Type: application/json" \
--request POST \
--data '{"project": "product", "name": "ORDER", "payload": {"user": 1234, "product": 1000}}' \
http://localhost:8000/api/workflows
Read the documentation to try the quickstart and see advanced usages of Celery Director.
Project layout
.env # The configuration file.
workflows.yml # The workflows definition.
tasks/
example.py # A file containing some tasks.
... # Other files containing other tasks.
Commands
director init [path]
- Create a new project.director celery [worker|beat|flower]
- Start Celery daemons.director webserver
- Start the webserver.director workflow [list|show|run]
- Manage your project workflows.
License
See https://github.com/ovh/celery-director/blob/master/LICENSE
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.
Source Distribution
Built Distribution
File details
Details for the file celery-director-0.9.0.tar.gz
.
File metadata
- Download URL: celery-director-0.9.0.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459bcdd452511b74b185488a3708481422edb8e926bdcc515345e99233683174 |
|
MD5 | 3dd6e305cc102096c8808f6c84f7d7c4 |
|
BLAKE2b-256 | 1941d30e050c4d35ef01457acdb964cfadbf901cbd0776344d7424e3980001b9 |
File details
Details for the file celery_director-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: celery_director-0.9.0-py3-none-any.whl
- Upload date:
- Size: 58.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a031e9a3c4d3b7057e1edc335e9b8c4a5d526f31102ad3ec4285f73e03f90c36 |
|
MD5 | 3d3edc9e4ddca56cd4d137ad3ddd2d38 |
|
BLAKE2b-256 | 9b595ec4042cf51c9032a4e39f933f48ab5ee526c94ab03ff15ed3b9af1008e3 |