Fokko closed pull request #4153: [AIRFLOW-3308] Fix plugins import
URL: https://github.com/apache/incubator-airflow/pull/4153
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/__init__.py b/airflow/__init__.py
index 9d071a347c..d010fe4c74 100644
--- a/airflow/__init__.py
+++ b/airflow/__init__.py
@@ -79,3 +79,16 @@ class AirflowViewPlugin(BaseView):
 class AirflowMacroPlugin(object):
     def __init__(self, namespace):
         self.namespace = namespace
+
+
+from airflow import operators  # noqa: E402
+from airflow import sensors  # noqa: E402
+from airflow import hooks  # noqa: E402
+from airflow import executors  # noqa: E402
+from airflow import macros  # noqa: E402
+
+operators._integrate_plugins()
+sensors._integrate_plugins()  # noqa: E402
+hooks._integrate_plugins()
+executors._integrate_plugins()
+macros._integrate_plugins()
diff --git a/airflow/operators/__init__.py b/airflow/operators/__init__.py
index 114d189da1..968b87b272 100644
--- a/airflow/operators/__init__.py
+++ b/airflow/operators/__init__.py
@@ -16,3 +16,12 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+
+def _integrate_plugins():
+    """Integrate plugins to the context"""
+    import sys
+    from airflow.plugins_manager import operators_modules
+    for operators_module in operators_modules:
+        sys.modules[operators_module.__name__] = operators_module
+        globals()[operators_module._name] = operators_module
diff --git a/airflow/sensors/__init__.py b/airflow/sensors/__init__.py
index b7f8352944..fe51779131 100644
--- a/airflow/sensors/__init__.py
+++ b/airflow/sensors/__init__.py
@@ -17,3 +17,12 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+
+
+def _integrate_plugins():
+    """Integrate plugins to the context"""
+    import sys
+    from airflow.plugins_manager import sensors_modules
+    for sensors_module in sensors_modules:
+        sys.modules[sensors_module.__name__] = sensors_module
+        globals()[sensors_module._name] = sensors_module


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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