JMLizano commented on PR #28822:
URL: https://github.com/apache/airflow/pull/28822#issuecomment-1528647036

   Hi, I was about to create a bug report related to this but then I saw this 
PR, so probably better to include it here.
   
   The issue appears when activating both dags persistence and git-sync. When 
you have a DAG inside a package, that is importing some other module from the 
package, like:
   
   ```python
   from mypackage.lib.mylib import lib_method
   ```
   
   the import will fail at DAG execution time if both git-sync and dag 
persistence are enabled. The DAG is still displayed in the Web UI, and airflow 
list it as correctly imported (i.e. it is displayed in the output of `airflow 
dags list`).
   When you try to execute the DAG, it will fail right away, without any log 
output since it fails before even starting the execution, but if you check the 
worker logs you will see a message like this:
   
   ```bash
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/models/dagbag.py", 
line 339, in parse
       loader.exec_module(new_module)
     File "<frozen importlib._bootstrap_external>", line 728, in exec_module
     File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
     File "/opt/airflow/dags/repo/dags/mypackage/mydags/mydag.py", line 6, in 
<module>
       from mypackage.lib.mylib import lib_method
   ModuleNotFoundError: No module named 'mypackage'
   ```
   
   If you disable dags persistence then everything works as expected.
   
   I have created a repository that reproduces the issue: 
https://github.com/JMLizano/explore-airflow-chart-issue
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to