'Get List of all the dags in python

I have a list of dags that are hosted on Airflow. I want to get the name of the dags in a AWS lambda function so that I can use the names and trigger the dag using experimental API. I am stuck on getting the names of the dag. Any help would be appreciated



Solution 1:[1]

All Airflow-CLI commands for the various various are listed on this URL - https://airflow.apache.org/docs/apache-airflow/stable/usage-cli.html

In the latest version you could do

airflow list_dags

Solution 2:[2]

This command will shows all DAGS include disabled dags as well

airflow dag_list

Solution 3:[3]

Since Airflow 2.0, the airflow list_dags command is now:

airflow dags list [-h] [-o table, json, yaml, plain] [-S SUBDIR] [-v]

with the following named arguments:

-o, --output

  • Possible choices: table, json, yaml, plain
  • Output format. Allowed values: json, yaml, plain, table (default: table)
  • Default: “table”

-S, --subdir

  • File location or directory from which to look for the dag. Defaults to ‘[AIRFLOW_HOME]/dags’ where [AIRFLOW_HOME] is the value you set for ‘AIRFLOW_HOME’ config you set in ‘airflow.cfg’
  • Default: “[AIRFLOW_HOME]/dags”

-v, --verbose

  • Make logging output more verbose
  • Default: False

See:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 floating_hammer
Solution 2 Data_explorer
Solution 3