Skip to content

Commit 60106ca

Browse files
committed
fix: fix plugin import path
1 parent e52f76f commit 60106ca

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

pfdl_scheduler/plugins/plugin_loader.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
import sys
1313
import inspect
1414
from typing import List
15+
from pathlib import Path
1516

1617
from pfdl_scheduler.pfdl_base_classes import PFDLBaseClasses
1718

1819
base_classes_registry = {}
1920

20-
PLUGIN_FOLDER_PATH = "./pfdl_scheduler/plugins"
21-
2221

2322
def base_class(existing_class_name):
2423
"""A Decorator to mark a class that will extend an existing class.
@@ -160,16 +159,18 @@ def load_plugin_modules(self, module_name, module_path):
160159
def load_plugins(self, plugins: List[str]):
161160
"""Recursively load all Python files from plugin folders."""
162161
for plugin_folder in plugins:
163-
plugin_path = os.path.join(PLUGIN_FOLDER_PATH, plugin_folder)
164-
165-
if os.path.isdir(plugin_path):
166-
# Walk through all files in the plugin folder
167-
for root, _, files in os.walk(plugin_path):
168-
for file in files:
169-
if file.endswith(".py"):
170-
module_name = f"{plugin_folder}.{file[:-3]}" # Plugin folder + filename without .py
171-
module_path = os.path.join(root, file)
172-
self.load_plugin_modules(module_name, module_path)
162+
plugin_path = Path(__file__).parent / plugin_folder
163+
164+
if not plugin_path.is_dir():
165+
raise ValueError("given plugin could not be found")
166+
167+
# Walk through all files in the plugin folder
168+
for root, _, files in os.walk(plugin_path):
169+
for file in files:
170+
if file.endswith(".py"):
171+
module_name = f"{plugin_folder}.{file[:-3]}" # Plugin folder + filename without .py
172+
module_path = os.path.join(root, file)
173+
self.load_plugin_modules(module_name, module_path)
173174

174175
def get_final_classes(self):
175176
"""Return a dictionary of final classes after applying plugins."""

0 commit comments

Comments
 (0)