fix: load comfy_extras nodes even when server.py import fails
server.py cannot load due to a ComfyUI internal module shadowing bug (comfy/utils.py file shadows utils/ package). Decouple init_extra_nodes() from server.py loading so NODE_CLASS_MAPPINGS still gets populated from comfy_extras (UpscaleModelLoader, etc.) even without full PromptServer setup. Also fix app.py to re-read from cached sys.modules[nodes] after import_custom_nodes() instead of using stale initial copy. Fixes the upscale-model-loader runtime e2e test.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import copy
|
||||
import sys
|
||||
|
||||
from typing import TextIO
|
||||
|
||||
@@ -57,6 +58,13 @@ class ExportApplication:
|
||||
}
|
||||
if self.needs_init_custom_nodes or missing_node_types:
|
||||
self.custom_node_importer()
|
||||
# Re-read from the cached "nodes" module in sys.modules after
|
||||
# import_custom_nodes() populates it with extras (comfy_extras,
|
||||
# custom node directories, etc.). The original dict is a stale copy.
|
||||
nodes_mod = sys.modules.get("nodes")
|
||||
if nodes_mod is not None:
|
||||
fresh_mappings = getattr(nodes_mod, "NODE_CLASS_MAPPINGS", {})
|
||||
self.node_class_mappings = fresh_mappings
|
||||
self.base_node_class_mappings = copy.deepcopy(self.node_class_mappings)
|
||||
|
||||
load_order = LoadOrderDeterminer(
|
||||
|
||||
@@ -261,7 +261,14 @@ def import_custom_nodes() -> None:
|
||||
server_mod = _load_module("server", os.path.join(comfyui_path, "server.py"))
|
||||
|
||||
if execution_mod is None or server_mod is None:
|
||||
log.debug("import_custom_nodes: could not load required modules")
|
||||
log.debug(
|
||||
"import_custom_nodes: could not load execution/server modules. "
|
||||
"Proceeding without full PromptServer/PromptQueue setup."
|
||||
)
|
||||
# Even without server, we can still populate NODE_CLASS_MAPPINGS from
|
||||
# comfy_extras and built-in extra nodes.
|
||||
if nodes_mod is not None and hasattr(nodes_mod, "init_extra_nodes"):
|
||||
asyncio.run(nodes_mod.init_extra_nodes())
|
||||
return
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
|
||||
Reference in New Issue
Block a user