Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DagNotFound Error when Testing DAG in Airflow CLI

I’m getting the error: airflow.exceptions.DagNotFound: Dag id test_task not found in DagModel when trying to run a dag via airflow trigger_dag test_dag.

DAG is listed correctly when running airflow list_dags. I have also checked to make sure the $AIRFLOW_HOME directory is correctly set to where the dag is. Only way I can get it to work is by running a specific task such as airflow test test_dag test_task. Running python dags/test_dag.py shows no errors.

Code in the dag file itself, after imports:

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime(2015, 6, 1),
    'email': ['[email protected]'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
}

dag = DAG(
  dag_id='test_dag'
  default_args=default_args, 
  schedule_interval=timedelta(days=1)
)

like image 540
Gabriel Avatar asked Jun 27 '26 15:06

Gabriel


1 Answers

You need to use the dag_id parameter:

dag = DAG(
    dag_id='test_dag', 
    default_args=default_args, 
    schedule_interval=timedelta(days=1)
)
like image 50
amoskaliov Avatar answered Jun 30 '26 05:06

amoskaliov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!