mik-laj commented on a change in pull request #9531: URL: https://github.com/apache/airflow/pull/9531#discussion_r448633985
########## File path: airflow/plugins_manager.py ########## @@ -164,34 +165,31 @@ def load_plugins_from_plugin_directory(): global plugins # pylint: disable=global-statement log.debug("Loading plugins from directory: %s", settings.PLUGINS_FOLDER) - # Crawl through the plugins folder to find AirflowPlugin derivatives - for root, _, files in os.walk(settings.PLUGINS_FOLDER, followlinks=True): # noqa # pylint: disable=too-many-nested-blocks - for f in files: - filepath = os.path.join(root, f) - try: - if not os.path.isfile(filepath): - continue - mod_name, file_ext = os.path.splitext( - os.path.split(filepath)[-1]) - if file_ext != '.py': - continue - - log.debug('Importing plugin module %s', filepath) - - loader = importlib.machinery.SourceFileLoader(mod_name, filepath) - spec = importlib.util.spec_from_loader(mod_name, loader) - mod = importlib.util.module_from_spec(spec) - sys.modules[spec.name] = mod - loader.exec_module(mod) - for mod_attr_value in list(mod.__dict__.values()): - if is_valid_plugin(mod_attr_value): - plugin_instance = mod_attr_value() - plugins.append(plugin_instance) - except Exception as e: # pylint: disable=broad-except - log.exception(e) - path = filepath or str(f) - log.error('Failed to import plugin %s', path) - import_errors[path] = str(e) + for file_path in find_path_from_directory( + settings.PLUGINS_FOLDER, ".airflowignore"): + + if not os.path.isfile(file_path): + continue + mod_name, file_ext = os.path.splitext(os.path.split(file_path)[-1]) + if file_ext != '.py': + continue Review comment: ```suggestion ``` Should this not be part of the find_path_from_directory function? I would like to see that there is no code in the plugins_manager.py file that is responsible for the file selection. Plugins_manager should only load the module. 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: us...@infra.apache.org