From 137630197b390a3f1c23553aa7e62987277d4f30 Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Tue, 12 Dec 2023 17:41:30 +0900 Subject: [PATCH 1/5] feat: terminal log node --- __init__.py | 24 ++++++++++++- js/terminal.js | 80 ++++++++++++++++++++++++++++++++++++++++++++ prestartup_script.py | 32 ++++++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 js/terminal.js diff --git a/__init__.py b/__init__.py index 3bac1292..f645b7db 100644 --- a/__init__.py +++ b/__init__.py @@ -20,7 +20,7 @@ import nodes import torch -version = "V1.11.5" +version = "V1.12" print(f"### Loading: ComfyUI-Manager ({version})") @@ -1517,6 +1517,28 @@ async def install_model(request): return web.Response(status=400) +class ManagerTerminalHook: + def write_stderr(self, msg): + server.PromptServer.instance.send_sync("manager-terminal-feedback", {"data": msg}) + + def write_stdout(self, msg): + server.PromptServer.instance.send_sync("manager-terminal-feedback", {"data": msg}) + + +manager_terminal_hook = ManagerTerminalHook() + + +@server.PromptServer.instance.routes.get("/manager/terminal") +async def terminal_mode(request): + if "mode" in request.rel_url.query: + if request.rel_url.query['mode'] == 'true': + sys.__comfyui_manager_terminal_hook.add_hook('cm', manager_terminal_hook) + else: + sys.__comfyui_manager_terminal_hook.remove_hook('cm') + + return web.Response(status=200) + + @server.PromptServer.instance.routes.get("/manager/preview_method") async def preview_method(request): if "value" in request.rel_url.query: diff --git a/js/terminal.js b/js/terminal.js new file mode 100644 index 00000000..1e0428c4 --- /dev/null +++ b/js/terminal.js @@ -0,0 +1,80 @@ +import {app} from "../../scripts/app.js"; +import {ComfyWidgets} from "../../scripts/widgets.js"; +// Node that add notes to your project + +let terminal_node; + +app.registerExtension({ + name: "Comfy.Manager.Terminal", + + registerCustomNodes() { + class TerminalNode { + color = "#222222"; + bgcolor = "#000000"; + groupcolor = LGraphCanvas.node_colors.black.groupcolor; + constructor() { + if(terminal_node) { + try { + terminal_node.widgets[0].value = 'The output of this node is disabled because another terminal node has appeared.'; + node.widgets[1].value = terminal_node.widgets[1].value; + } + catch {} + } + + terminal_node = this; + this.logs = []; + + if (!this.properties) { + this.properties = {}; + this.properties.text=""; + } + + ComfyWidgets.STRING(this, "", ["", {default:this.properties.text, multiline: true}], app) + ComfyWidgets.BOOLEAN(this, "mode", ["", {default:true, label_on:'Logging', label_off:'Stop'}], app) + ComfyWidgets.INT(this, "lines", ["", {default:500, min:10, max:10000, steps:1}], app) + + Object.defineProperty(this.widgets[1], 'value', { + set: (v) => { + api.fetchApi(`/manager/terminal?mode=${v}`, {}); + this._value = v; + }, + get: () => { + return this._value; + } + }); + + this.serialize_widgets = false; + this.isVirtualNode = true; + } + } + + // Load default visibility + LiteGraph.registerNodeType( + "Terminal Log //CM", + Object.assign(TerminalNode, { + title_mode: LiteGraph.NORMAL_TITLE, + title: "Terminal Log (Manager)", + collapsable: true, + }) + ); + + TerminalNode.category = "utils"; + }, +}); + + +import { api } from "../../scripts/api.js"; + +function terminalFeedback(event) { + if(terminal_node) { + terminal_node.logs.push(event.detail.data); + if(terminal_node.logs.length > terminal_node.widgets[2].value) { + terminal_node.logs.shift(); + if(terminal_node.logs[0] == '' || terminal_node.logs[0] == '\n') + terminal_node.logs.shift(); + } + terminal_node.widgets[0].value = [...terminal_node.logs].reverse().join('').trim(); + } +} + +api.addEventListener("manager-terminal-feedback", terminalFeedback); diff --git a/prestartup_script.py b/prestartup_script.py index 4dc4d104..a227ff6d 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -33,6 +33,36 @@ restore_snapshot_path = os.path.join(startup_script_path, "restore-snapshot.json git_script_path = os.path.join(comfyui_manager_path, "git_helper.py") +class TerminalHook: + def __init__(self): + self.hooks = {} + + def add_hook(self, k, v): + self.hooks[k] = v + + def remove_hook(self, k): + if k in self.hooks: + del self.hooks[k] + + def write_stderr(self, msg): + for v in self.hooks.values(): + try: + v.write_stderr(msg) + except Exception: + pass + + def write_stdout(self, msg): + for v in self.hooks.values(): + try: + v.write_stdout(msg) + except Exception: + pass + + +terminal_hook = TerminalHook() +sys.__comfyui_manager_terminal_hook = terminal_hook + + def handle_stream(stream, prefix): stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace') for msg in stream: @@ -157,9 +187,11 @@ try: if self.is_stdout: original_stdout.write(message) original_stdout.flush() + terminal_hook.write_stderr(message) else: original_stderr.write(message) original_stderr.flush() + terminal_hook.write_stdout(message) def flush(self): log_file.flush() From b0b6b476575b355e45fc01b910b865e230c7016b Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Tue, 12 Dec 2023 17:44:43 +0900 Subject: [PATCH 2/5] update DB --- custom-node-list.json | 10 ++++++++++ extension-node-map.json | 12 +++++++++++- node_db/dev/custom-node-list.json | 10 ++++++++++ node_db/new/extension-node-map.json | 12 +++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/custom-node-list.json b/custom-node-list.json index 6588853d..933e701e 100644 --- a/custom-node-list.json +++ b/custom-node-list.json @@ -3310,6 +3310,16 @@ "install_type": "git-clone", "description": "[PoC] This extension implements [a/DemoFusion](https://ruoyidu.github.io/demofusion/demofusion.html)." }, + { + "author": "spacepxl", + "title": "ComfyUI-Image-Filters", + "reference": "https://github.com/spacepxl/ComfyUI-Image-Filters", + "files": [ + "https://github.com/spacepxl/ComfyUI-Image-Filters" + ], + "install_type": "git-clone", + "description": "Image and matte filtering nodes for ComfyUI `image/filters/*`" + }, { "author": "Ser-Hilary", "title": "SDXL_sizing", diff --git a/extension-node-map.json b/extension-node-map.json index ae40c96e..4f73401c 100644 --- a/extension-node-map.json +++ b/extension-node-map.json @@ -3798,7 +3798,6 @@ ], "https://github.com/knuknX/ComfyUI-Image-Tools": [ [ - "ImageBatchSqueezeProcessor", "ImageBgRemoveProcessor", "ImageStandardResizeProcessor", "SingleImagePathLoader", @@ -4893,6 +4892,17 @@ "title_aux": "ComfyUI-HQ-Image-Save" } ], + "https://github.com/spacepxl/ComfyUI-Image-Filters": [ + [ + "AlphaClean", + "EnhanceDetail", + "GuidedFilterAlpha", + "RemapRange" + ], + { + "title_aux": "ComfyUI-Image-Filters" + } + ], "https://github.com/spinagon/ComfyUI-seam-carving": [ [ "SeamCarving" diff --git a/node_db/dev/custom-node-list.json b/node_db/dev/custom-node-list.json index 935b6ca9..0f3cb658 100644 --- a/node_db/dev/custom-node-list.json +++ b/node_db/dev/custom-node-list.json @@ -1,5 +1,15 @@ { "custom_nodes": [ + { + "author": "spacepxl", + "title": "ComfyUI-Image-Filters", + "reference": "https://github.com/spacepxl/ComfyUI-Image-Filters", + "files": [ + "https://github.com/spacepxl/ComfyUI-Image-Filters" + ], + "install_type": "git-clone", + "description": "Image and matte filtering nodes for ComfyUI `image/filters/*`" + }, { "author": "talesofai", "title": "comfyui-supersave [WIP]", diff --git a/node_db/new/extension-node-map.json b/node_db/new/extension-node-map.json index ae40c96e..4f73401c 100644 --- a/node_db/new/extension-node-map.json +++ b/node_db/new/extension-node-map.json @@ -3798,7 +3798,6 @@ ], "https://github.com/knuknX/ComfyUI-Image-Tools": [ [ - "ImageBatchSqueezeProcessor", "ImageBgRemoveProcessor", "ImageStandardResizeProcessor", "SingleImagePathLoader", @@ -4893,6 +4892,17 @@ "title_aux": "ComfyUI-HQ-Image-Save" } ], + "https://github.com/spacepxl/ComfyUI-Image-Filters": [ + [ + "AlphaClean", + "EnhanceDetail", + "GuidedFilterAlpha", + "RemapRange" + ], + { + "title_aux": "ComfyUI-Image-Filters" + } + ], "https://github.com/spinagon/ComfyUI-seam-carving": [ [ "SeamCarving" From ff671b1d4e45d09b12dbd21cab44f77ceb53d0d9 Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Tue, 12 Dec 2023 17:56:31 +0900 Subject: [PATCH 3/5] fix: terminal log node --- __init__.py | 2 +- js/terminal.js | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/__init__.py b/__init__.py index f645b7db..7eeece06 100644 --- a/__init__.py +++ b/__init__.py @@ -20,7 +20,7 @@ import nodes import torch -version = "V1.12" +version = "V1.12.1" print(f"### Loading: ComfyUI-Manager ({version})") diff --git a/js/terminal.js b/js/terminal.js index 1e0428c4..091959fa 100644 --- a/js/terminal.js +++ b/js/terminal.js @@ -3,6 +3,7 @@ import {ComfyWidgets} from "../../scripts/widgets.js"; // Node that add notes to your project let terminal_node; +let log_mode = false; app.registerExtension({ name: "Comfy.Manager.Terminal", @@ -13,15 +14,6 @@ app.registerExtension({ bgcolor = "#000000"; groupcolor = LGraphCanvas.node_colors.black.groupcolor; constructor() { - if(terminal_node) { - try { - terminal_node.widgets[0].value = 'The output of this node is disabled because another terminal node has appeared.'; - node.widgets[1].value = terminal_node.widgets[1].value; - } - catch {} - } - - terminal_node = this; this.logs = []; if (!this.properties) { @@ -33,18 +25,27 @@ app.registerExtension({ ComfyWidgets.BOOLEAN(this, "mode", ["", {default:true, label_on:'Logging', label_off:'Stop'}], app) ComfyWidgets.INT(this, "lines", ["", {default:500, min:10, max:10000, steps:1}], app) + let self = this; Object.defineProperty(this.widgets[1], 'value', { set: (v) => { api.fetchApi(`/manager/terminal?mode=${v}`, {}); - this._value = v; + log_mode = v; }, get: () => { - return this._value; + return log_mode; } }); this.serialize_widgets = false; this.isVirtualNode = true; + + if(terminal_node) { + try { + terminal_node.widgets[0].value = 'The output of this node is disabled because another terminal node has appeared.'; + } + catch {} + } + terminal_node = this; } } From 954aa8a6d0e772a3d2d111ec0753a5163c879e1d Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Tue, 12 Dec 2023 18:43:08 +0900 Subject: [PATCH 4/5] update DB --- custom-node-list.json | 10 ++++++++++ extension-node-map.json | 3 +++ node_db/dev/custom-node-list.json | 10 ---------- node_db/new/custom-node-list.json | 20 ++++++++++++++++++++ node_db/new/extension-node-map.json | 3 +++ 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/custom-node-list.json b/custom-node-list.json index 933e701e..91e802c9 100644 --- a/custom-node-list.json +++ b/custom-node-list.json @@ -3068,6 +3068,16 @@ "install_type": "git-clone", "description": "This is an Extension for ComfyUI, which helps formatting texts." }, + { + "author": "Haoming02", + "title": "ComfyUI Clear Screen", + "reference": "https://github.com/Haoming02/comfyui-clear-screen", + "files": [ + "https://github.com/Haoming02/comfyui-clear-screen" + ], + "install_type": "git-clone", + "description": "This is an Extension for ComfyUI, which adds a button, CLS, to clear the console window." + }, { "author": "bedovyy", "title": "ComfyUI_NAIDGenerator", diff --git a/extension-node-map.json b/extension-node-map.json index 4f73401c..4df51383 100644 --- a/extension-node-map.json +++ b/extension-node-map.json @@ -4060,6 +4060,7 @@ "Segs Mask ForEach", "SegsMaskCombine", "SegsToCombinedMask", + "SetDefaultImageForSEGS", "SubtractMask", "SubtractMaskForEach", "TiledKSamplerProvider", @@ -4729,6 +4730,8 @@ "ShowLayer", "ShowTextForGPT", "SmoothMask", + "SpeechRecognition", + "SpeechSynthesis", "SplitLongMask", "SvgImage", "TextImage", diff --git a/node_db/dev/custom-node-list.json b/node_db/dev/custom-node-list.json index 0f3cb658..935b6ca9 100644 --- a/node_db/dev/custom-node-list.json +++ b/node_db/dev/custom-node-list.json @@ -1,15 +1,5 @@ { "custom_nodes": [ - { - "author": "spacepxl", - "title": "ComfyUI-Image-Filters", - "reference": "https://github.com/spacepxl/ComfyUI-Image-Filters", - "files": [ - "https://github.com/spacepxl/ComfyUI-Image-Filters" - ], - "install_type": "git-clone", - "description": "Image and matte filtering nodes for ComfyUI `image/filters/*`" - }, { "author": "talesofai", "title": "comfyui-supersave [WIP]", diff --git a/node_db/new/custom-node-list.json b/node_db/new/custom-node-list.json index dabbfdc6..6cc61478 100644 --- a/node_db/new/custom-node-list.json +++ b/node_db/new/custom-node-list.json @@ -1,5 +1,25 @@ { "custom_nodes": [ + { + "author": "spacepxl", + "title": "ComfyUI-Image-Filters", + "reference": "https://github.com/spacepxl/ComfyUI-Image-Filters", + "files": [ + "https://github.com/spacepxl/ComfyUI-Image-Filters" + ], + "install_type": "git-clone", + "description": "Image and matte filtering nodes for ComfyUI `image/filters/*`" + }, + { + "author": "Haoming02", + "title": "ComfyUI Clear Screen", + "reference": "https://github.com/Haoming02/comfyui-clear-screen", + "files": [ + "https://github.com/Haoming02/comfyui-clear-screen" + ], + "install_type": "git-clone", + "description": "This is an Extension for ComfyUI, which adds a button, CLS, to clear the console window." + }, { "author": "deroberon", "title": "demofusion-comfyui", diff --git a/node_db/new/extension-node-map.json b/node_db/new/extension-node-map.json index 4f73401c..4df51383 100644 --- a/node_db/new/extension-node-map.json +++ b/node_db/new/extension-node-map.json @@ -4060,6 +4060,7 @@ "Segs Mask ForEach", "SegsMaskCombine", "SegsToCombinedMask", + "SetDefaultImageForSEGS", "SubtractMask", "SubtractMaskForEach", "TiledKSamplerProvider", @@ -4729,6 +4730,8 @@ "ShowLayer", "ShowTextForGPT", "SmoothMask", + "SpeechRecognition", + "SpeechSynthesis", "SplitLongMask", "SvgImage", "TextImage", From 3d39819527cea9d6a61c1438e19ceddb5014ca90 Mon Sep 17 00:00:00 2001 From: "dr.lt.data" Date: Tue, 12 Dec 2023 18:55:49 +0900 Subject: [PATCH 5/5] update DB --- custom-node-list.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-node-list.json b/custom-node-list.json index 91e802c9..7c40bde1 100644 --- a/custom-node-list.json +++ b/custom-node-list.json @@ -2374,7 +2374,7 @@ "https://github.com/drustan-hawk/primitive-types" ], "install_type": "git-clone", - "description": "A text-to-speech plugin used under ComfyUI. It utilizes the Microsoft Speech TTS interface to convert text content into MP3 format audio files." + "description": "This repository contains typed primitives for ComfyUI. The motivation for these primitives is that the standard primitive node cannot be routed." }, { "author": "shadowcz007",