[KVConnector]: prioritize external connector over internal registry (#38301)
Signed-off-by: baoloongmao <baoloongmao@tencent.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
This commit is contained in:
@@ -107,12 +107,11 @@ class KVConnectorFactory:
|
|||||||
if connector_name is None:
|
if connector_name is None:
|
||||||
raise ValueError("Connector name is not set in KVTransferConfig")
|
raise ValueError("Connector name is not set in KVTransferConfig")
|
||||||
compat_sig = False
|
compat_sig = False
|
||||||
if connector_name in cls._registry:
|
connector_module_path = kv_transfer_config.kv_connector_module_path
|
||||||
connector_cls = cls._registry[connector_name]()
|
if connector_module_path is not None and not connector_module_path:
|
||||||
else:
|
raise ValueError("kv_connector_module_path cannot be an empty string.")
|
||||||
connector_module_path = kv_transfer_config.kv_connector_module_path
|
if connector_module_path:
|
||||||
if connector_module_path is None:
|
# External module path takes priority over internal registry.
|
||||||
raise ValueError(f"Unsupported connector type: {connector_name}")
|
|
||||||
connector_module = importlib.import_module(connector_module_path)
|
connector_module = importlib.import_module(connector_module_path)
|
||||||
try:
|
try:
|
||||||
connector_cls = getattr(connector_module, connector_name)
|
connector_cls = getattr(connector_module, connector_name)
|
||||||
@@ -128,6 +127,10 @@ class KVConnectorFactory:
|
|||||||
"Please update to include kv_cache_config as the second argument.",
|
"Please update to include kv_cache_config as the second argument.",
|
||||||
connector_cls.__name__,
|
connector_cls.__name__,
|
||||||
)
|
)
|
||||||
|
elif connector_name in cls._registry:
|
||||||
|
connector_cls = cls._registry[connector_name]()
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unsupported connector type: {connector_name}")
|
||||||
return connector_cls, compat_sig
|
return connector_cls, compat_sig
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user