ovh / celery-director

Simple and rapid framework to build workflows with Celery
https://ovh.github.io/celery-director/
BSD 3-Clause "New" or "Revised" License
534 stars 58 forks source link

feat: Add per-task queue routing #155

Closed henri42 closed 2 years ago

henri42 commented 2 years ago

Add the possibility to route task individually in a workflow.

example.ETL:
  tasks:
    - [EXTRACT, queue1]
    - [TRANSFORM, queue2]
    - LOAD

In the following case, the task-level queue overrides the workflow-level queue for the task where a queue is defined.

example.ETL:
  tasks:
    - EXTRACT
    - [TRANSFORM, queue2] # task-level
    - LOAD
  queue: queue1 # workflow-level
CodePint commented 2 years ago

related: https://github.com/ovh/celery-director/pull/134

ncrocfer commented 2 years ago

Hi @henri42,

First of all thank you for this PR, it brings an interesting feature in Celery Director ! Unfortunately after a few tests I see it doesn't work for all the cases.

For instance everything is working for a simple ETL example: Capture d’écran 2022-07-15 à 16 49 07

But it doesn't work when a group of tasks is executed:

image

I think you can update the builder to support it, but for me the syntax you choose is a bit confusing. The users will think it's a group of tasks, while it's just an array of 2 elements with the task and its queue.

The best is to provide another syntax, for instance using the queue key:

example.ETL:
  tasks:
    - EXTRACT
    - TRANSFORM
    - LOAD
  queue:
    default: q1
    customs:
      EXTRACT: q2

Note this is just an example, I just wrote it quickly so I'm not sure about the final syntax ;) Also note if you do that you have to continue to support the current syntax, namely:

  queue: q1

is the same as:

  queue:
    default: q1
henri42 commented 2 years ago

Thanks for your feedback ! Indeed this syntax can be confusing. I chose it to keep readability but it might be better with the syntax you suggested. I will work on this new syntax and handle task-level queues for the tasks in groups.

henri42 commented 2 years ago

Thanks ! That's done.