potiuk commented on a change in pull request #6596: [AIRFLOW-6004] Untangle 
Executors class to avoid cyclic imports
URL: https://github.com/apache/airflow/pull/6596#discussion_r352342525
 
 

 ##########
 File path: airflow/__init__.py
 ##########
 @@ -44,23 +44,8 @@
 
 settings.initialize()
 
-login = None  # type: Optional[Callable]
+from airflow.plugins_manager import integrate_plugins
 
-from airflow import executors
-from airflow import hooks
-from airflow import macros
-from airflow import operators
-from airflow import sensors
+login: Optional[Callable] = None
 
-
-class AirflowMacroPlugin:
-    # pylint: disable=missing-docstring
-    def __init__(self, namespace):
-        self.namespace = namespace
-
-
-operators._integrate_plugins()  # pylint: disable=protected-access
-sensors._integrate_plugins()  # pylint: disable=protected-access
-hooks._integrate_plugins()  # pylint: disable=protected-access
-executors._integrate_plugins()  # pylint: disable=protected-access
-macros._integrate_plugins()  # pylint: disable=protected-access
+integrate_plugins()
 
 Review comment:
   Hey @ashb, @mik-laj @feluelle -> I realised that I can have the change much 
simpler if I already incorporate some of the plugins_manager change to simplify 
dependencies. I moved out all the code from __init__ methods of the 
operators/sensors/hooks/executors/macros and moved the plugin initialization 
part to plugins_manager(). It made the whole untangling way better and simpler. 
Just look at the resulting airflow.__init__()  code . It is really reasonable 
and you can understand what's going on there.
   
   I have removed the imports for executors/operators/hooks/macros/sensors - I 
am not hundred percent if this is OK when it comes to backwards compatibility 
(someone could use them as 'airflow.operators' after  'import airflow' but I 
think that was not the intention. I can bring them back if you think it's too 
invasive (there is no __init__ code there so no impact on cyclic dependencies) 
or make a note in UPDATING.md
   
   WDYT?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to