Skip to content

how to specify celery queue dynamic by parmater before dag run #14987

Answered by turbaszek
SaithZhang asked this question in Q&A
Discussion options

You must be logged in to vote

Templating does not work as it happen at the moment of execution, so it's already on worker. I would suggest experimenting with cluster policies https://airflow.apache.org/docs/apache-airflow/stable/concepts.html#cluster-policy

def task_policy(task: BaseOperator):
  task.queue = task.dag.conf.get("key4", defaul_queue)

or if you use it for all task in DAG

def dag_policy(dag: DAG):
  queue = dag.conf.get("key4", default_queue)
  for task in dag.tasks:
     task.queue = queue

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@SaithZhang
Comment options

@SaithZhang
Comment options

@turbaszek
Comment options

Answer selected by SaithZhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants