Skip to content

Commit

Permalink
mono - remove special lazy handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
cobycloud committed Jan 4, 2025
1 parent 243ec15 commit 4366ebc
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions pkgs/swarmauri/swarmauri/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ def find_spec(self, fullname, path=None, target=None):
logger.debug(f"Found external module mapping: {fullname} -> {external_module_path}")
return ModuleSpec(fullname, self)

# Attempt to register the plugin without loading
if fullname in PluginCitizenshipRegistry.total_registry():
resource_path = fullname
type_info = get_plugin_type_info(resource_path)
if type_info:
# Do not load the module yet; registration already handled
logger.debug(f"Plugin '{fullname}' is registered for lazy loading.")
return ModuleSpec(fullname, self)
# If lazy, then we need to add LazyLoader
external_module_path = PluginCitizenshipRegistry.get_external_module_path(fullname)
if external_module_path:
# If we detect lazy strategy, then we utilize LazyLoader
logger.debug(f"Found external module mapping: {fullname} -> {external_module_path}")
return ModuleSpec(fullname, importlib.util.LazyLoader(self))

logger.debug(f"Module '{fullname}' not found. Returning None.")
return None
Expand Down Expand Up @@ -77,14 +75,6 @@ def create_module(self, spec):
sys.modules[spec.name] = module
return module

# Handle lazy-loaded plugins
if spec.name in PluginCitizenshipRegistry.total_registry():
module_path = PluginCitizenshipRegistry.total_registry()[spec.name]
logger.debug(f"Lazy loading module '{spec.name}' from '{module_path}'")
module = importlib.import_module(module_path)
sys.modules[spec.name] = module
return module

logger.error(f"Cannot create module '{spec.name}'. Raising ImportError.")
raise ImportError(f"Cannot create module {spec.name}")

Expand Down

0 comments on commit 4366ebc

Please sign in to comment.