kaxil commented on issue #51816:
URL: https://github.com/apache/airflow/issues/51816#issuecomment-2980867342

   > So: detecting when we have top-level dag code, at least in the `python 
mydagfile.py` case:
   > 
   > def __getattr__(name):
   >     if name == "SUPERVISOR_COMMS" and "__main__" in sys.modules:
   >         import traceback
   > 
   >         frames = [
   >             frame
   >             for (frame, lnum) in traceback.walk_stack(None)
   >             if not frame.f_code.co_filename.startswith("<frozen 
importlib.")
   >         ]
   >         if sys.modules["__main__"].__file__ == 
frames[-1].f_code.co_filename:
   >             raise RuntimeError("Top level API access here")
   > 
   >     raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
   > (Put this in `airflow/sdk/execution_time/task_runner.py`. It won't help 
for cases in unit tests where someone imports the dag. But that could be 
handled in other cases)
   > 
   
   aah 💡 .
   
   
   > So now back to the main question: can we "just" make it set up an 
in-process API server there to try and ask the local DB in that case? Are there 
any security risks of doing that?
   
   Unsure right -- need to think it through
   


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