tirkarthi commented on issue #26936:
URL: https://github.com/apache/airflow/issues/26936#issuecomment-1283854781

   Since Airflow 2.4.0 has autoregister feature enabled by default the top 
level `BaseDag` is registered once dummyA is loaded. Once dummyB is loaded the 
dummyA/dag.py tries to import BaseDag from dummyA which gets autoregistered. 
During autoregister the mod is set to dummyB using 
`current_autoregister_module_name` attribute that is again assigned to the 
BaseDag which leads to incorrect fileloc and source code . 
https://github.com/apache/airflow/blob/a74d523ae1c6152ff4335e9c63ff418a6ae529c4/airflow/models/dagbag.py#L330
   
   Couple of workarounds I can see before fixing this case : 
   
   1. Move initialization of `BaseDag` from dummyA/dag.py to a separate dag 
file so that imports from other files don't trigger this kind of case and also 
helps with better organization.
   2. Set `auto_register` as False in dag wrapper so that this is not triggered 
and assign the dags initialized to variables at top level so that they continue 
to work.
   
   
https://airflow.apache.org/blog/airflow-2.4.0/#auto-register-dags-used-in-a-context-manager-no-more-as-dag-needed


-- 
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