Add support for dynamic local services module

- Introduced a check in `load_service_from_path` to ensure the `local_services` module is created in `sys.modules` if it doesn't exist, facilitating proper relative and absolute imports for service plugins.
- This enhancement improves the loading mechanism for local service plugins, ensuring smoother integration and functionality.
This commit is contained in:
agessaman
2026-03-08 12:51:32 -07:00
parent 6b4e6351c4
commit 6df2da5083
+4
View File
@@ -6,6 +6,7 @@ Handles scanning, loading, and registering service plugins
import os
import sys
import types
import importlib
import importlib.util
import inspect
@@ -143,6 +144,9 @@ class ServicePluginLoader:
def load_service_from_path(self, file_path: Path) -> Optional[BaseServicePlugin]:
"""Load a single service plugin from a file path (e.g. local/service_plugins/my_service.py)."""
# Ensure parent package exists so relative/absolute imports of "local_services" work
if "local_services" not in sys.modules:
sys.modules["local_services"] = types.ModuleType("local_services")
stem = file_path.stem
module_name = f"local_services.{stem}"
try: