From 585cc0d99100342d7514305b216263fe6ccffa70 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 4 Jan 2025 03:07:36 +0900 Subject: [PATCH] fixed: invalid skipping of pip dependencies installation if ==, ~= removed: useless badge related code --- glob/manager_core.py | 23 ++++++- glob/manager_server.py | 15 ----- js/comfyui-manager.js | 139 +---------------------------------------- prestartup_script.py | 8 +++ pyproject.toml | 2 +- 5 files changed, 32 insertions(+), 155 deletions(-) diff --git a/glob/manager_core.py b/glob/manager_core.py index 856ae64a..e583aa02 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -36,7 +36,7 @@ import manager_downloader from node_package import InstalledNodePackage -version_code = [3, 3, 6] +version_code = [3, 3, 7] version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') @@ -263,6 +263,27 @@ def is_installed(name): print(f"[ComfyUI-Manager] skip black listed pip installation: '{name}'") return True + pkg = manager_util.get_installed_packages().get(name.lower()) + if pkg is None: + return False # update if not installed + + if match is None: + return True # don't update if version is not specified + + if match.group(2) in ['>', '>=']: + if manager_util.StrictVersion(pkg) < manager_util.StrictVersion(match.group(3)): + return False + elif manager_util.StrictVersion(pkg) > manager_util.StrictVersion(match.group(3)): + print(f"[SKIP] Downgrading pip package isn't allowed: {name.lower()} (cur={pkg})") + + if match.group(2) == '==': + if manager_util.StrictVersion(pkg) < manager_util.StrictVersion(match.group(3)): + return False + + if match.group(2) == '~=': + if manager_util.StrictVersion(pkg) == manager_util.StrictVersion(match.group(3)): + return False + return name.lower() in manager_util.get_installed_packages() diff --git a/glob/manager_server.py b/glob/manager_server.py index 7678185f..79690692 100644 --- a/glob/manager_server.py +++ b/glob/manager_server.py @@ -153,10 +153,6 @@ def set_preview_method(method): set_preview_method(core.get_config()['preview_method']) -def set_badge_mode(mode): - core.get_config()['badge_mode'] = mode - - def set_default_ui_mode(mode): core.get_config()['default_ui'] = mode @@ -1153,17 +1149,6 @@ async def preview_method(request): return web.Response(status=200) -@routes.get("/manager/badge_mode") -async def badge_mode(request): - if "value" in request.rel_url.query: - set_badge_mode(request.rel_url.query['value']) - core.write_config() - else: - return web.Response(text=core.get_config()['badge_mode'], status=200) - - return web.Response(status=200) - - @routes.get("/manager/default_ui") async def default_ui_mode(request): if "value" in request.rel_url.query: diff --git a/js/comfyui-manager.js b/js/comfyui-manager.js index b5a6aa15..0fd3f90c 100644 --- a/js/comfyui-manager.js +++ b/js/comfyui-manager.js @@ -103,24 +103,6 @@ docStyle.innerHTML = ` vertical-align: middle; } -#cm-channel-badge { - color: white; - background-color: #AA0000; - width: 220px; - height: 23px; - font-size: 13px; - border-radius: 5px; - left: 5px; - top: 5px; - align-content: center; - justify-content: center; - text-align: center; - font-weight: bold; - float: left; - vertical-align: middle; - position: relative; -} - #custom-nodes-grid a { color: #5555FF; font-weight: bold; @@ -244,7 +226,6 @@ var update_comfyui_button = null; var switch_comfyui_button = null; var fetch_updates_button = null; var update_all_button = null; -var badge_mode = "none"; let share_option = 'all'; // copied style from https://github.com/pythongosssss/ComfyUI-Custom-Scripts @@ -426,14 +407,6 @@ const style = ` } `; - - -async function init_badge_mode() { - api.fetchApi('/manager/badge_mode') - .then(response => response.text()) - .then(data => { badge_mode = data; }) -} - async function init_share_option() { api.fetchApi('/manager/share_option') .then(response => response.text()) @@ -450,7 +423,6 @@ async function init_notice(notice) { }) } -await init_badge_mode(); await init_share_option(); async function fetchNicknames() { @@ -517,65 +489,6 @@ function getNickname(node, nodename) { } } -function drawBadge(node, orig, restArgs) { - let ctx = restArgs[0]; - const r = orig?.apply?.(node, restArgs); - - if (!node.flags.collapsed && badge_mode != 'none' && node.constructor.title_mode != LiteGraph.NO_TITLE) { - let text = ""; - if (badge_mode.startsWith('id_nick')) - text = `#${node.id} `; - - let nick = node.getNickname(); - if (nick) { - if (nick == 'ComfyUI') { - if(badge_mode.endsWith('hide')) { - nick = ""; - } - else { - nick = "🦊" - } - } - - if (nick.length > 25) { - text += nick.substring(0, 23) + ".."; - } - else { - text += nick; - } - } - - if (text != "") { - let fgColor = "white"; - let bgColor = "#0F1F0F"; - let visible = true; - - ctx.save(); - ctx.font = "12px sans-serif"; - const sz = ctx.measureText(text); - ctx.fillStyle = bgColor; - ctx.beginPath(); - ctx.roundRect(node.size[0] - sz.width - 12, -LiteGraph.NODE_TITLE_HEIGHT - 20, sz.width + 12, 20, 5); - ctx.fill(); - - ctx.fillStyle = fgColor; - ctx.fillText(text, node.size[0] - sz.width - 6, -LiteGraph.NODE_TITLE_HEIGHT - 6); - ctx.restore(); - - if (node.has_errors) { - ctx.save(); - ctx.font = "bold 14px sans-serif"; - const sz2 = ctx.measureText(node.type); - ctx.fillStyle = 'white'; - ctx.fillText(node.type, node.size[0] / 2 - sz2.width / 2, node.size[1] / 2); - ctx.restore(); - } - } - } - return r; -} - - async function updateComfyUI() { let prev_text = update_comfyui_button.innerText; update_comfyui_button.innerText = "Updating ComfyUI..."; @@ -1069,32 +982,9 @@ class ManagerMenuDialog extends ComfyDialog { api.fetchApi(`/manager/preview_method?value=${event.target.value}`); }); - // nickname - let badge_combo = ""; - if(is_legacy_front()) { - badge_combo = document.createElement("select"); - badge_combo.setAttribute("title", "Configure the content to be displayed on the badge at the top right corner of the node. The ID is the identifier of the node. If 'hide built-in' is selected, both unknown nodes and built-in nodes will be omitted, making them indistinguishable"); - badge_combo.className = "cm-menu-combo"; - badge_combo.appendChild($el('option', { value: 'none', text: 'Badge: None' }, [])); - badge_combo.appendChild($el('option', { value: 'nick', text: 'Badge: Nickname' }, [])); - badge_combo.appendChild($el('option', { value: 'nick_hide', text: 'Badge: Nickname (hide built-in)' }, [])); - badge_combo.appendChild($el('option', { value: 'id_nick', text: 'Badge: #ID Nickname' }, [])); - badge_combo.appendChild($el('option', { value: 'id_nick_hide', text: 'Badge: #ID Nickname (hide built-in)' }, [])); - - api.fetchApi('/manager/badge_mode') - .then(response => response.text()) - .then(data => { badge_combo.value = data; badge_mode = data; }); - - badge_combo.addEventListener('change', function (event) { - api.fetchApi(`/manager/badge_mode?value=${event.target.value}`); - badge_mode = event.target.value; - app.graph.setDirtyCanvas(true); - }); - } - // channel let channel_combo = document.createElement("select"); - channel_combo.setAttribute("title", "Configure the channel for retrieving data from the Custom Node list (including missing nodes) or the Model list. Note that the badge utilizes local information."); + channel_combo.setAttribute("title", "Configure the channel for retrieving data from the Custom Node list (including missing nodes) or the Model list."); channel_combo.className = "cm-menu-combo"; api.fetchApi('/manager/channel_url_list') .then(response => response.json()) @@ -1218,7 +1108,6 @@ class ManagerMenuDialog extends ComfyDialog { this.datasrc_combo, channel_combo, preview_combo, - badge_combo, default_ui_combo, share_combo, component_policy_combo, @@ -1663,32 +1552,6 @@ app.registerExtension({ this._addExtraNodeContextMenu(nodeType, app); }, - async nodeCreated(node, app) { - if(is_legacy_front()) { - if(!node.badge_enabled) { - node.getNickname = function () { return getNickname(node, node.comfyClass.trim()) }; - let orig = node.onDrawForeground; - if(!orig) - orig = node.__proto__.onDrawForeground; - - node.onDrawForeground = function (ctx) { - drawBadge(node, orig, arguments) - }; - node.badge_enabled = true; - } - } - }, - - async loadedGraphNode(node, app) { - if(is_legacy_front()) { - if(!node.badge_enabled) { - const orig = node.onDrawForeground; - node.getNickname = function () { return getNickname(node, node.type.trim()) }; - node.onDrawForeground = function (ctx) { drawBadge(node, orig, arguments) }; - } - } - }, - _addExtraNodeContextMenu(node, app) { const origGetExtraMenuOptions = node.prototype.getExtraMenuOptions; node.prototype.cm_menu_added = true; diff --git a/prestartup_script.py b/prestartup_script.py index 81753c3f..be78264b 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -437,6 +437,14 @@ def is_installed(name): elif manager_util.StrictVersion(pkg) > manager_util.StrictVersion(match.group(3)): print(f"[SKIP] Downgrading pip package isn't allowed: {name.lower()} (cur={pkg})") + if match.group(2) == '==': + if manager_util.StrictVersion(pkg) < manager_util.StrictVersion(match.group(3)): + return False + + if match.group(2) == '~=': + if manager_util.StrictVersion(pkg) == manager_util.StrictVersion(match.group(3)): + return False + return True # prevent downgrade diff --git a/pyproject.toml b/pyproject.toml index 63e31dd9..e69bebb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-manager" description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI." -version = "3.3.6" +version = "3.3.7" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]