airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] XD-DENG closed pull request #3649: [AIRFLOW-2808] Fix Plugin Duplication Checking
Date Wed, 15 Aug 2018 05:32:39 GMT
XD-DENG closed pull request #3649: [AIRFLOW-2808] Fix Plugin Duplication Checking
URL: https://github.com/apache/incubator-airflow/pull/3649
 
 
   

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/plugins_manager.py b/airflow/plugins_manager.py
index 735f2de1e8..00200f66f1 100644
--- a/airflow/plugins_manager.py
+++ b/airflow/plugins_manager.py
@@ -28,6 +28,7 @@
 import os
 import re
 import sys
+from collections import Counter
 
 from airflow import configuration
 from airflow.utils.log.logging_mixin import LoggingMixin
@@ -90,8 +91,7 @@ def validate(cls):
                         issubclass(obj, AirflowPlugin) and
                         obj is not AirflowPlugin):
                     obj.validate()
-                    if obj not in plugins:
-                        plugins.append(obj)
+                    plugins.append(obj)
 
         except Exception as e:
             log.exception(e)
@@ -119,7 +119,12 @@ def make_module(name, objects):
 flask_blueprints = []
 menu_links = []
 
+uniq_plugin_modules = []
+
 for p in plugins:
+
+    uniq_plugin_modules.append(p.name)
+
     operators_modules.append(
         make_module('airflow.operators.' + p.name, p.operators + p.sensors))
     sensors_modules.append(
@@ -133,3 +138,9 @@ def make_module(name, objects):
     admin_views.extend(p.admin_views)
     flask_blueprints.extend(p.flask_blueprints)
     menu_links.extend(p.menu_links)
+
+plugins_counter = Counter(uniq_plugin_modules)
+if max(plugins_counter.values()) > 1:
+    log.warn("There are duplicated plugin files for method(s) %s.",
+             [p[0] for p in plugins_counter.items() if p[1] > 1])
+    log.warn("Among duplicated plugins of each method, only one to be loaded.")


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message