airflowairflow-scheduler

How can I programmatically access the cron schedules for my Airflow DAGs?


I am trying to build a custom UI built around the executions of airflow tasks. One piece of information I need is the cron schedule of each DAG.

I cannot find this in any of the tables used by the Airflow scheduler. Am I missing something obvious?

Without writing a crawler to parse DAG python files themselves, where can I find the cron schedules for my DAGs (by database connection, api call, or anything else that I can programmatically access)?


Solution

  • Instantiate a airflow.models.DagBag object, all the DAG objects, and their schedule_interval (which has their scheduling information), is available from the dags dictionary attribute on the DagBag object.

    from airflow import models
    dag_bag = models.DagBag()
    for dag in dag_bag.dags.values():
        print(dag.schedule_interval)