feat(plugins): 支持可调用入口点以避免循环导入

在插件注册表中添加对函数入口点的支持,通过检测并调用可调用对象来避免循环导入问题。
这使得入口点可以作为函数定义,而不是直接的类实例,从而提高模块间的解耦性。
```
This commit is contained in:
wyyyz1937365497 committed 2026-03-05 19:30:54 +08:00
1 parent 50e0e3c70c
commit f3f42692aa
2 files changed
+10

No files matched your search

+5
View File
@@ -41,6 +41,11 @@ def discover_methods() -> t.Tuple[t.Dict[str, TrainerConfig], t.Dict[str, str]]:
discovered_entry_points = entry_points(group="nerfstudio.method_configs")
for name in discovered_entry_points.names:
spec = discovered_entry_points[name].load()
# Support callable (function) entry points to avoid circular imports
if callable(spec):
spec = spec()
if not isinstance(spec, MethodSpecification):
CONSOLE.print(
f"[bold yellow]Warning: Could not entry point {spec} as it is not an instance of MethodSpecification"
@@ -57,6 +57,11 @@ def discover_dataparsers() -> t.Tuple[t.Dict[str, DataParserConfig], t.Dict[str,
discovered_entry_points = entry_points(group="nerfstudio.dataparser_configs")
for name in discovered_entry_points.names:
spec = discovered_entry_points[name].load()
# Support callable (function) entry points to avoid circular imports
if callable(spec):
spec = spec()
if not isinstance(spec, DataParserSpecification):
CONSOLE.print(
f"[bold yellow]Warning: Could not entry point {spec} as it is not an instance of DataParserSpecification"