jscheffl commented on code in PR #39999:
URL: https://github.com/apache/airflow/pull/39999#discussion_r1676374829
##########
airflow/plugins_manager.py:
##########
@@ -262,28 +264,38 @@ def load_plugins_from_plugin_directory():
"""Load and register Airflow Plugins from plugins directory."""
global import_errors
log.debug("Loading plugins from directory: %s", settings.PLUGINS_FOLDER)
+ files = find_path_from_directory(settings.PLUGINS_FOLDER, ".airflowignore")
+ plugin_search_locations: list[tuple[str, Generator[str, None, None]]] =
[("", files)]
- for file_path in find_path_from_directory(settings.PLUGINS_FOLDER,
".airflowignore"):
- path = Path(file_path)
- if not path.is_file() or path.suffix != ".py":
- continue
- mod_name = path.stem
+ if conf.getboolean("core", "LOAD_EXAMPLES"):
+ log.debug("Note: Loading plugins from examples as well: %s",
settings.PLUGINS_FOLDER)
+ from airflow.example_dags import plugins
- try:
- loader = importlib.machinery.SourceFileLoader(mod_name, file_path)
- 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)
- log.debug("Importing plugin module %s", file_path)
-
- for mod_attr_value in (m for m in mod.__dict__.values() if
is_valid_plugin(m)):
- plugin_instance = mod_attr_value()
- plugin_instance.source = PluginsDirectorySource(file_path)
- register_plugin(plugin_instance)
- except Exception as e:
- log.exception("Failed to import plugin %s", file_path)
- import_errors[file_path] = str(e)
+ example_plugins_folder = next(iter(plugins.__path__))
Review Comment:
Yes, exactly. I made it like this to prevent mypy and other linter
complaints and did not want to loop over an array with a single element.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]