Honor native ComfyUI node function contract
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user