Skip to content

Commit

Permalink
fix: fix plugin import path
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan1248 committed Jan 23, 2025
1 parent e52f76f commit 8c71a95
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions pfdl_scheduler/plugins/plugin_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import sys
import inspect
from typing import List
from pathlib import Path

from pfdl_scheduler.pfdl_base_classes import PFDLBaseClasses

base_classes_registry = {}

PLUGIN_FOLDER_PATH = "./pfdl_scheduler/plugins"


def base_class(existing_class_name):
"""A Decorator to mark a class that will extend an existing class.
Expand Down Expand Up @@ -160,16 +159,18 @@ def load_plugin_modules(self, module_name, module_path):
def load_plugins(self, plugins: List[str]):
"""Recursively load all Python files from plugin folders."""
for plugin_folder in plugins:
plugin_path = os.path.join(PLUGIN_FOLDER_PATH, plugin_folder)

if os.path.isdir(plugin_path):
# Walk through all files in the plugin folder
for root, _, files in os.walk(plugin_path):
for file in files:
if file.endswith(".py"):
module_name = f"{plugin_folder}.{file[:-3]}" # Plugin folder + filename without .py
module_path = os.path.join(root, file)
self.load_plugin_modules(module_name, module_path)
plugin_path = Path(__file__).parent / plugin_folder

if not plugin_path.is_dir():
raise ValueError("given plugin could not be found")

# Walk through all files in the plugin folder
for root, _, files in os.walk(plugin_path):
for file in files:
if file.endswith(".py"):
module_name = f"{plugin_folder}.{file[:-3]}" # Plugin folder + filename without .py
module_path = os.path.join(root, file)
self.load_plugin_modules(module_name, module_path)

def get_final_classes(self):
"""Return a dictionary of final classes after applying plugins."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="pfdl_scheduler",
version="0.9.0",
version="0.9.2",
description="Parser and Scheduler for Production Flow Description Language (PFDL) files.",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 8c71a95

Please sign in to comment.