Airflow unpause dag programmatically?

Viewed 14847

I have a dag that we'll deploy to multiple different airflow instances and in our airflow.cfg we have dags_are_paused_at_creation = True but for this specific dag we want it to be turned on without having to do so manually by clicking on the UI. Is there a way to do it programmatically?

8 Answers

I think you are looking for unpause ( not pause)

airflow unpause DAG_ID
airflow pause dag_id.

has been discontinued.

You will have to use:

airflow dags pause dag_id

You can do this using in the python operator of any dag to pause and unpause the dags programatically . This is the best approch i found instead of using cli just pass the list of dags and rest is take care

from airflow.models import DagModel
dag_id = "dag_name"
dag = DagModel.get_dagmodel(dag_id)
dag.set_is_paused(is_paused=False)

And just if you want to check if it is paused or not it will return boolean

dag.is_paused()
Related