From 7807449e6dcc01cfdb7f0eb818569184c8b41af2 Mon Sep 17 00:00:00 2001 From: Mel Massadian Date: Sun, 21 Apr 2024 16:59:26 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20debug=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also properly print to console now... --- nodes/debug.py | 7 +++++-- web/comfy_shared.js | 12 +++++++----- web/debug.js | 3 +-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nodes/debug.py b/nodes/debug.py index d51e8f1..e3cc769 100644 --- a/nodes/debug.py +++ b/nodes/debug.py @@ -47,6 +47,8 @@ def process_list(anything): text.append( f"List of Tensors: {first_element.shape} (x{len(anything)})" ) + else: + text.append(f"Array: {anything}") return {"text": text} @@ -90,7 +92,7 @@ class MTB_Debug: CATEGORY = "mtb/debug" OUTPUT_NODE = True - def do_debug(self, output_to_console, **kwargs): + def do_debug(self, output_to_console: bool, **kwargs): output = { "ui": {"b64_images": [], "text": []}, # "result": ("A"), @@ -103,7 +105,8 @@ class MTB_Debug: bool: process_bool, } if output_to_console: - print("bouh!") + for k, v in kwargs.items(): + print(f"{k}: {v}") for anything in kwargs.values(): processor = processors.get(type(anything), process_text) diff --git a/web/comfy_shared.js b/web/comfy_shared.js index e71f7cc..a33d747 100644 --- a/web/comfy_shared.js +++ b/web/comfy_shared.js @@ -45,16 +45,18 @@ export class LocalStorageManager { } clear() { - Object.keys(localStorage) - .filter((k) => k.startsWith(this.namespace + ':')) - .forEach((k) => localStorage.removeItem(k)) + for (const key of Object.keys(localStorage).filter((k) => + k.startsWith(`${this.namespace}:`), + )) { + localStorage.removeItem(key) + } } } // - log utilities function createLogger(emoji, color, consoleMethod = 'log') { - return function (message, ...args) { + return (message, ...args) => { if (window.MTB?.DEBUG) { console[consoleMethod]( `%c${emoji} ${message}`, @@ -147,7 +149,7 @@ export function getWidgetType(config) { // Special handling for COMBO so we restrict links based on the entries let type = config?.[0] let linkType = type - if (type instanceof Array) { + if (Array.isArray(type)) { type = 'COMBO' linkType = linkType.join(',') } diff --git a/web/debug.js b/web/debug.js index 92128f9..0a00387 100644 --- a/web/debug.js +++ b/web/debug.js @@ -52,7 +52,7 @@ app.registerExtension({ //- infer type if (link_info) { const fromNode = this.graph._nodes.find( - (otherNode) => otherNode.id == link_info.origin_id, + (otherNode) => otherNode.id === link_info.origin_id, ) const type = fromNode.outputs[link_info.origin_slot].type this.inputs[index].type = type @@ -83,7 +83,6 @@ app.registerExtension({ this.widgets.length = 1 } let widgetI = 1 - if (message.text) { for (const txt of message.text) { const w = this.addCustomWidget(