j-y-matsubara commented on a change in pull request #9531: URL: https://github.com/apache/airflow/pull/9531#discussion_r448456168
########## File path: airflow/plugins_manager.py ########## @@ -164,34 +165,34 @@ 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) + ignore_list_file = ".airflowignore" + + for file_path in find_path_from_directory( # pylint: disable=too-many-nested-blocks + str(settings.PLUGINS_FOLDER), str(ignore_list_file)): + + try: + 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: No.... I fixed! ########## File path: airflow/plugins_manager.py ########## @@ -164,34 +165,34 @@ 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) + ignore_list_file = ".airflowignore" + + for file_path in find_path_from_directory( # pylint: disable=too-many-nested-blocks + str(settings.PLUGINS_FOLDER), str(ignore_list_file)): + + try: + 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: No.... I fixed ---------------------------------------------------------------- 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