GithubHelp home page GithubHelp logo

ambientlighter / celery-director Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ovh/celery-director

0.0 1.0 0.0 1.78 MB

Simple and rapid framework to build workflows with Celery

Home Page: https://ovh.github.io/celery-director/

License: BSD 3-Clause "New" or "Revised" License

Python 78.40% Mako 0.43% JavaScript 6.22% CSS 1.27% HTML 13.46% Shell 0.21%

celery-director's Introduction

Celery Director logo

Build status Python versions License Code style: black

Celery Director


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 to track the tasks states,
  • an API and a CLI to manage and execute the workflows,
  • 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 Python 3.6 at least):

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

celery-director's People

Contributors

anthonyolea avatar ismailrei avatar maximecaruchet avatar ncrocfer avatar paweldudzinski avatar tedmk avatar ziirish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.