From f3f42692aa17c937a0578a47aabd1dfa86b8da1f Mon Sep 17 00:00:00 2001 From: wyyyz1937365497 Date: Thu, 5 Mar 2026 19:30:54 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(plugins):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=8F=AF=E8=B0=83=E7=94=A8=E5=85=A5=E5=8F=A3=E7=82=B9=E4=BB=A5?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E5=BE=AA=E7=8E=AF=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在插件注册表中添加对函数入口点的支持,通过检测并调用可调用对象来避免循环导入问题。 这使得入口点可以作为函数定义,而不是直接的类实例,从而提高模块间的解耦性。 ``` --- nerfstudio/plugins/registry.py | 5 +++++ nerfstudio/plugins/registry_dataparser.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/nerfstudio/plugins/registry.py b/nerfstudio/plugins/registry.py index f50550f74..380fab25f 100644 --- a/nerfstudio/plugins/registry.py +++ b/nerfstudio/plugins/registry.py @@ -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" diff --git a/nerfstudio/plugins/registry_dataparser.py b/nerfstudio/plugins/registry_dataparser.py index 6b1e34a0f..1d7011356 100644 --- a/nerfstudio/plugins/registry_dataparser.py +++ b/nerfstudio/plugins/registry_dataparser.py @@ -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"