Honor native ComfyUI node function contract
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-10-14 15:07:44 +00:00
parent 2a804f7194
commit 39e6734ff4
2 changed files with 38 additions and 3 deletions
+29 -1
View File
@@ -38,6 +38,34 @@ def _native_node(name: str):
return None
def _call_native(node_class, kwargs: dict[str, Any]):
"""Invoke a ComfyUI node through its declared FUNCTION contract.
ComfyUI node classes do not have a universal Python method name. The live
MiniMax node currently declares its executor through ``FUNCTION`` rather
than exposing a method named ``upscale``.
"""
instance = node_class()
declared = getattr(node_class, "FUNCTION", None)
candidates = []
if isinstance(declared, str) and declared:
candidates.append(declared)
candidates.extend(("execute", "run", "process", "sample", "upscale"))
seen = set()
for name in candidates:
if name in seen:
continue
seen.add(name)
method = getattr(instance, name, None)
if callable(method):
return method(**kwargs)
raise RuntimeError(
"MMH3UltimateUpscale exposes no callable ComfyUI FUNCTION method "
f"(declared={declared!r})"
)
def _one(value: Any, name: str) -> Any:
"""Unwrap ComfyUI list inputs while rejecting ambiguous values."""
@@ -259,7 +287,7 @@ class H3ContinuumTiledLatentUpscalePerClip:
}
if negatives[index - 1] is not None:
kwargs["negative"] = negatives[index - 1]
result = native().upscale(**kwargs)
result = _call_native(native, kwargs)
if not isinstance(result, (tuple, list)) or not result:
raise RuntimeError(f"native upscale returned no output for clip {index}")
output = result[0]