Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark files to Airflow such that it does not try to import them as DAG

Tags:

airflow

I have the following structure


airflow/
   |_dags/
      |_projects/
             |_utils/
             |_my_project/
                     |_tasks/
                          |_taskone.py

where utils contains several utils-files.

The issue is that airflow tries to import (just) one of the utils-files. I read somewhere, that Airflow treats files which contains the words dag and airflow in the same file (not filename!) as a DAG.

Since one of my utils-function util1 has an absolute path e.g airflow/dags/projects/utils specified in it, I guess that is why util1 is trying to be imported as a DAG (which clearly fails).

Is there a way to mark Airflow not to try import a specific file, like util1?

like image 371
CutePoison Avatar asked Jan 23 '26 19:01

CutePoison


1 Answers

You can place a file named .airflowignore and list what files/folders Airflow will ignore while processing DAGs. You can read about it in the documentation:

You can also provide an .airflowignore file inside your DAG_FOLDER, or any of its subfolders, which describes files for the loader to ignore. It covers the directory it's in plus all subfolders underneath it, and should be one regular expression per line, with # indicating comments.

like image 75
Elad Kalif Avatar answered Jan 25 '26 12:01

Elad Kalif



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!