update worker manager and worker to support plugin registry
This commit is contained in:
@@ -6,6 +6,7 @@ Backends are discovered from their owning plugins and instantiated from config.
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import importlib.util
|
||||
import inspect
|
||||
import re
|
||||
from typing import Any, Dict, Optional, Type
|
||||
@@ -119,6 +120,16 @@ def _discover_plugin_backend_class(backend_type: str) -> Optional[Type[BackendBa
|
||||
return resolved
|
||||
|
||||
|
||||
def _plugin_module_exists(plugin_name: str) -> bool:
|
||||
normalized = _normalize_backend_type(plugin_name)
|
||||
if not normalized:
|
||||
return False
|
||||
try:
|
||||
return importlib.util.find_spec(f"plugins.{normalized}") is not None
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def _resolve_backend_class(backend_type: str) -> Optional[Type[BackendBase]]:
|
||||
normalized = _normalize_backend_type(backend_type)
|
||||
if not normalized:
|
||||
@@ -200,7 +211,11 @@ class BackendRegistry:
|
||||
continue
|
||||
backend_cls = _resolve_backend_class(backend_type)
|
||||
if backend_cls is None:
|
||||
if backend_type not in _PROVIDER_ONLY_BACKEND_NAMES and not self._suppress_debug:
|
||||
if (
|
||||
backend_type not in _PROVIDER_ONLY_BACKEND_NAMES
|
||||
and not self._suppress_debug
|
||||
and not _plugin_module_exists(backend_type)
|
||||
):
|
||||
debug(f"[BackendRegistry] Unknown backend type '{raw_backend_type}'")
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user