From 5ee63e284b2ea9d53fb9a289f9e6043258737ee1 Mon Sep 17 00:00:00 2001 From: "kosinkadink1@gmail.com" Date: Thu, 10 Jul 2025 01:53:27 -0500 Subject: [PATCH] Renamed 'node' to 'cls' in PreviewImage/Mask --- comfy_api/v3/ui.py | 18 +++++++++--------- comfy_extras/nodes_v3_test.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/comfy_api/v3/ui.py b/comfy_api/v3/ui.py index ed2f5d555..ac2a9b15b 100644 --- a/comfy_api/v3/ui.py +++ b/comfy_api/v3/ui.py @@ -27,7 +27,7 @@ class SavedResult: } class PreviewImage(_UIOutput): - def __init__(self, image: Image.Type, animated: bool=False, node: ComfyNodeV3=None, **kwargs): + def __init__(self, image: Image.Type, animated: bool=False, cls: ComfyNodeV3=None, **kwargs): output_dir = folder_paths.get_temp_directory() type = "temp" prefix_append = "_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for x in range(5)) @@ -41,13 +41,13 @@ class PreviewImage(_UIOutput): i = 255. * image.cpu().numpy() img = PILImage.fromarray(np.clip(i, 0, 255).astype(np.uint8)) metadata = None - if not args.disable_metadata and node is not None: + if not args.disable_metadata and cls is not None: metadata = PngInfo() - if node.hidden.prompt is not None: - metadata.add_text("prompt", json.dumps(node.hidden.prompt)) - if node.hidden.extra_pnginfo is not None: - for x in node.hidden.extra_pnginfo: - metadata.add_text(x, json.dumps(node.hidden.extra_pnginfo[x])) + if cls.hidden.prompt is not None: + metadata.add_text("prompt", json.dumps(cls.hidden.prompt)) + if cls.hidden.extra_pnginfo is not None: + for x in cls.hidden.extra_pnginfo: + metadata.add_text(x, json.dumps(cls.hidden.extra_pnginfo[x])) filename_with_batch_num = filename.replace("%batch_num%", str(batch_number)) file = f"{filename_with_batch_num}_{counter:05}_.png" @@ -66,9 +66,9 @@ class PreviewImage(_UIOutput): } class PreviewMask(PreviewImage): - def __init__(self, mask: PreviewMask.Type, animated: bool=False, node: ComfyNodeV3=None, **kwargs): + def __init__(self, mask: PreviewMask.Type, animated: bool=False, cls: ComfyNodeV3=None, **kwargs): preview = mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])).movedim(1, -1).expand(-1, -1, -1, 3) - super().__init__(preview, animated, node, **kwargs) + super().__init__(preview, animated, cls, **kwargs) # class UILatent(_UIOutput): # def __init__(self, values: list[SavedResult | dict], **kwargs): diff --git a/comfy_extras/nodes_v3_test.py b/comfy_extras/nodes_v3_test.py index 6f2d21895..426a5e3f8 100644 --- a/comfy_extras/nodes_v3_test.py +++ b/comfy_extras/nodes_v3_test.py @@ -105,7 +105,7 @@ class V3TestNode(io.ComfyNodeV3): if hasattr(cls, "doohickey"): raise Exception("The 'cls' variable leaked state on class properties between runs!") cls.doohickey = "LOLJK" - return io.NodeOutput(some_int, image, ui=ui.PreviewImage(image)) + return io.NodeOutput(some_int, image, ui=ui.PreviewImage(image, cls=cls)) class V3LoraLoader(io.ComfyNodeV3):