Airflow unpause dag programmatically?

后端 未结 4 837
醉话见心
醉话见心 2020-12-16 18:26

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

4条回答
  •  一个人的身影
    2020-12-16 18:54

    I created the following function to do so if anyone else runs into this issue:

    import airflow.settings
    from airflow.models import DagModel
    def unpause_dag(dag):
        """
        A way to programatically unpause a DAG.
        :param dag: DAG object
        :return: dag.is_paused is now False
        """
        session = airflow.settings.Session()
        try:
            qry = session.query(DagModel).filter(DagModel.dag_id == dag.dag_id)
            d = qry.first()
            d.is_paused = False
            session.commit()
        except:
            session.rollback()
        finally:
            session.close()
    

提交回复
热议问题