Skip to content

Commit

Permalink
Ignore disabled extensions in module loader
Browse files Browse the repository at this point in the history
  • Loading branch information
stijn-uva committed Nov 11, 2024
1 parent e96523c commit 9e14db4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/lib/module_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def load_modules(self):
# look for workers and processors in pre-defined folders and datasources

extension_path = Path(config.get('PATH_ROOT'), "extensions")
enabled_extensions = [e for e, s in config.get("extensions.enabled").items() if s["enabled"]]

paths = [Path(config.get('PATH_ROOT'), "processors"),
Path(config.get('PATH_ROOT'), "backend", "workers"),
Expand All @@ -124,6 +125,9 @@ def load_modules(self):
# This skips processors/datasources that were loaded by others and may not yet be captured
pass

if is_extension and len(module_name.split(".")) > 1 and module_name.split(".")[1] not in enabled_extensions:
continue

# try importing
try:
module = importlib.import_module(module_name)
Expand Down Expand Up @@ -221,7 +225,13 @@ def _load_datasource(subdirectory):

# Load extension datasources
# os.walk is used to allow for the possibility of multiple extensions, with nested "datasources" folders
for root, dirs, files in os.walk(Path(config.get('PATH_ROOT'), "extensions"), followlinks=True):
enabled_extensions = [e for e, s in config.get("extensions.enabled").items() if s["enabled"]]
extensions_root = Path(config.get('PATH_ROOT'), "extensions")
for root, dirs, files in os.walk(extensions_root, followlinks=True):
relative_root = Path(root).relative_to(extensions_root)
if relative_root.parts and relative_root.parts[0] not in enabled_extensions:
continue

if "datasources" in dirs:
for subdirectory in Path(root, "datasources").iterdir():
if subdirectory.is_dir():
Expand Down

0 comments on commit 9e14db4

Please sign in to comment.