Skip to content

Commit 5a5a37d

Browse files
committedFeb 28, 2025
fixed: robust initial caching
comfyanonymous/ComfyUI#7003 (comment) modified: store `db_mode` setting to `config.ini` ltdrdata#1582 (comment) remove: fetch updates / skip updates - 'updates' filter will trigger fetching ltdrdata#1584 added: support for `disable_front` or `DISABLE_COMFYUI_MANAGER_FRONT`
1 parent 0d487bc commit 5a5a37d

7 files changed

+62
-91
lines changed
 

‎__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
sys.path.append(os.path.join(os.path.dirname(__file__), "glob"))
88
import manager_server # noqa: F401
99
import share_3rdparty # noqa: F401
10-
WEB_DIRECTORY = "js"
10+
import cm_global
11+
12+
if not cm_global.disable_front and not 'DISABLE_COMFYUI_MANAGER_FRONT' in os.environ:
13+
WEB_DIRECTORY = "js"
1114
else:
1215
print("\n[ComfyUI-Manager] !! cli-only-mode is enabled !!\n")
1316

‎glob/cm_global.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,6 @@ def add_on_revision_detected(k, f):
112112
variables['cm.on_revision_detected_handler'].append((k, f))
113113

114114

115-
error_dict = {}
115+
error_dict = {}
116+
117+
disable_front = False

‎glob/manager_core.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from node_package import InstalledNodePackage
4343

4444

45-
version_code = [3, 27, 2]
45+
version_code = [3, 27, 3]
4646
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
4747

4848

@@ -1614,7 +1614,8 @@ def write_config():
16141614
'security_level': get_config()['security_level'],
16151615
'skip_migration_check': get_config()['skip_migration_check'],
16161616
'always_lazy_install': get_config()['always_lazy_install'],
1617-
'network_mode': get_config()['network_mode']
1617+
'network_mode': get_config()['network_mode'],
1618+
'db_mode': get_config()['db_mode'],
16181619
}
16191620

16201621
directory = os.path.dirname(manager_config_path)
@@ -1654,6 +1655,7 @@ def get_bool(key, default_value):
16541655
'always_lazy_install': get_bool('always_lazy_install', False),
16551656
'network_mode': default_conf.get('network_mode', 'public').lower(),
16561657
'security_level': default_conf.get('security_level', 'normal').lower(),
1658+
'db_mode': default_conf.get('db_mode', 'cache').lower(),
16571659
}
16581660

16591661
except Exception:
@@ -1677,6 +1679,7 @@ def get_bool(key, default_value):
16771679
'always_lazy_install': False,
16781680
'network_mode': 'public', # public | private | offline
16791681
'security_level': 'normal', # strong | normal | normal- | weak
1682+
'db_mode': 'cache', # local | cache | remote
16801683
}
16811684

16821685

‎glob/manager_server.py

+31-13
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ def set_component_policy(mode):
190190
def set_update_policy(mode):
191191
core.get_config()['update_policy'] = mode
192192

193+
def set_db_mode(mode):
194+
core.get_config()['db_mode'] = mode
195+
193196
def print_comfyui_version():
194197
global comfy_ui_hash
195198
global comfyui_tag
@@ -816,7 +819,7 @@ async def fetch_customnode_list(request):
816819
"""
817820
provide unified custom node list
818821
"""
819-
if "skip_update" in request.rel_url.query and request.rel_url.query["skip_update"] == "true":
822+
if request.rel_url.query.get("skip_update", '').lower() == "true":
820823
skip_update = True
821824
else:
822825
skip_update = False
@@ -833,7 +836,7 @@ async def fetch_customnode_list(request):
833836
core.populate_github_stats(node_packs, await json_obj_github)
834837
core.populate_favorites(node_packs, await json_obj_extras)
835838

836-
check_state_of_git_node_pack(node_packs, False, do_update_check=not skip_update)
839+
check_state_of_git_node_pack(node_packs, not skip_update, do_update_check=not skip_update)
837840

838841
for v in node_packs.values():
839842
populate_markdown(v)
@@ -1455,6 +1458,18 @@ async def preview_method(request):
14551458
return web.Response(status=200)
14561459

14571460

1461+
@routes.get("/manager/db_mode")
1462+
async def db_mode(request):
1463+
if "value" in request.rel_url.query:
1464+
set_db_mode(request.rel_url.query['value'])
1465+
core.write_config()
1466+
else:
1467+
return web.Response(text=core.get_config()['db_mode'], status=200)
1468+
1469+
return web.Response(status=200)
1470+
1471+
1472+
14581473
@routes.get("/manager/policy/component")
14591474
async def component_policy(request):
14601475
if "value" in request.rel_url.query:
@@ -1681,20 +1696,23 @@ def confirm_try_install(sender, custom_node_url, msg):
16811696
async def default_cache_update():
16821697
channel_url = core.get_config()['channel_url']
16831698
async def get_cache(filename):
1684-
if core.get_config()['default_cache_as_channel_url']:
1685-
uri = f"{channel_url}/{filename}"
1686-
else:
1687-
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
1699+
try:
1700+
if core.get_config()['default_cache_as_channel_url']:
1701+
uri = f"{channel_url}/{filename}"
1702+
else:
1703+
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
16881704

1689-
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
1690-
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
1705+
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
1706+
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
16911707

1692-
json_obj = await manager_util.get_data(uri, True)
1708+
json_obj = await manager_util.get_data(uri, True)
16931709

1694-
with manager_util.cache_lock:
1695-
with open(cache_uri, "w", encoding='utf-8') as file:
1696-
json.dump(json_obj, file, indent=4, sort_keys=True)
1697-
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
1710+
with manager_util.cache_lock:
1711+
with open(cache_uri, "w", encoding='utf-8') as file:
1712+
json.dump(json_obj, file, indent=4, sort_keys=True)
1713+
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
1714+
except:
1715+
logging.error(f"[ComfyUI-Manager] Failed to initial fetching: {filename}")
16981716

16991717
if core.get_config()['network_mode'] != 'offline':
17001718
a = get_cache("custom-node-list.json")

‎js/comfyui-manager.js

+11-71
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ document.head.appendChild(docStyle);
227227

228228
var update_comfyui_button = null;
229229
var switch_comfyui_button = null;
230-
var fetch_updates_button = null;
231230
var update_all_button = null;
232231
var restart_stop_button = null;
233232
var update_policy_combo = null;
@@ -653,57 +652,6 @@ async function switchComfyUI() {
653652
}
654653
}
655654

656-
657-
async function fetchUpdates(update_check_checkbox) {
658-
let prev_text = fetch_updates_button.innerText;
659-
fetch_updates_button.innerText = "Fetching updates...";
660-
fetch_updates_button.disabled = true;
661-
fetch_updates_button.style.backgroundColor = "gray";
662-
663-
try {
664-
var mode = manager_instance.datasrc_combo.value;
665-
666-
const response = await api.fetchApi(`/customnode/fetch_updates?mode=${mode}`);
667-
668-
if (response.status != 200 && response.status != 201) {
669-
show_message('Failed to fetch updates.');
670-
return false;
671-
}
672-
673-
if (response.status == 201) {
674-
show_message("There is an updated extension available.<BR><BR><P><B>NOTE:<BR>Fetch Updates is not an update.<BR>Please update from <button id='cm-install-customnodes-button'>Install Custom Nodes</button> </B></P>");
675-
676-
const button = document.getElementById('cm-install-customnodes-button');
677-
button.addEventListener("click",
678-
async function() {
679-
app.ui.dialog.close();
680-
681-
if(!CustomNodesManager.instance) {
682-
CustomNodesManager.instance = new CustomNodesManager(app, self);
683-
}
684-
await CustomNodesManager.instance.show(CustomNodesManager.ShowMode.UPDATE);
685-
}
686-
);
687-
688-
update_check_checkbox.checked = false;
689-
}
690-
else {
691-
show_message('All extensions are already up-to-date with the latest versions.');
692-
}
693-
694-
return true;
695-
}
696-
catch (exception) {
697-
show_message(`Failed to update custom nodes / ${exception}`);
698-
return false;
699-
}
700-
finally {
701-
fetch_updates_button.disabled = false;
702-
fetch_updates_button.innerText = prev_text;
703-
fetch_updates_button.style.backgroundColor = "";
704-
}
705-
}
706-
707655
async function onQueueStatus(event) {
708656
const isElectron = 'electronAPI' in window;
709657

@@ -816,8 +764,7 @@ async function onQueueStatus(event) {
816764
api.addEventListener("cm-queue-status", onQueueStatus);
817765

818766

819-
async function updateAll(update_comfyui, manager_dialog) {
820-
let prev_text = update_all_button.innerText;
767+
async function updateAll(update_comfyui) {
821768
update_all_button.innerText = "Updating...";
822769

823770
set_inprogress_mode();
@@ -900,14 +847,6 @@ class ManagerMenuDialog extends ComfyDialog {
900847
() => switchComfyUI()
901848
});
902849

903-
fetch_updates_button =
904-
$el("button.cm-button", {
905-
type: "button",
906-
textContent: "Fetch Updates",
907-
onclick:
908-
() => fetchUpdates(this.update_check_checkbox)
909-
});
910-
911850
restart_stop_button =
912851
$el("button.cm-button-red", {
913852
type: "button",
@@ -921,7 +860,7 @@ class ManagerMenuDialog extends ComfyDialog {
921860
type: "button",
922861
textContent: "Update All Custom Nodes",
923862
onclick:
924-
() => updateAll(false, self)
863+
() => updateAll(false)
925864
});
926865
}
927866
else {
@@ -930,7 +869,7 @@ class ManagerMenuDialog extends ComfyDialog {
930869
type: "button",
931870
textContent: "Update All",
932871
onclick:
933-
() => updateAll(true, self)
872+
() => updateAll(true)
934873
});
935874
}
936875

@@ -1037,12 +976,6 @@ class ManagerMenuDialog extends ComfyDialog {
1037976

1038977
let self = this;
1039978

1040-
this.update_check_checkbox = $el("input",{type:'checkbox', id:"skip_update_check"},[])
1041-
const uc_checkbox_text = $el("label",{for:"skip_update_check"},[" Skip update check"])
1042-
uc_checkbox_text.style.color = "var(--fg-color)";
1043-
uc_checkbox_text.style.cursor = "pointer";
1044-
this.update_check_checkbox.checked = true;
1045-
1046979
// db mode
1047980
this.datasrc_combo = document.createElement("select");
1048981
this.datasrc_combo.setAttribute("title", "Configure where to retrieve node/model information. If set to 'local,' the channel is ignored, and if set to 'channel (remote),' it fetches the latest information each time the list is opened.");
@@ -1051,6 +984,14 @@ class ManagerMenuDialog extends ComfyDialog {
1051984
this.datasrc_combo.appendChild($el('option', { value: 'local', text: 'DB: Local' }, []));
1052985
this.datasrc_combo.appendChild($el('option', { value: 'remote', text: 'DB: Channel (remote)' }, []));
1053986

987+
api.fetchApi('/manager/db_mode')
988+
.then(response => response.text())
989+
.then(data => { this.datasrc_combo.value = data; });
990+
991+
this.datasrc_combo.addEventListener('change', function (event) {
992+
api.fetchApi(`/manager/db_mode?value=${event.target.value}`);
993+
});
994+
1054995
// preview method
1055996
let preview_combo = document.createElement("select");
1056997
preview_combo.setAttribute("title", "Configure how latent variables will be decoded during preview in the sampling process.");
@@ -1170,7 +1111,6 @@ class ManagerMenuDialog extends ComfyDialog {
11701111
});
11711112

11721113
return [
1173-
$el("div", {}, [this.update_check_checkbox, uc_checkbox_text]),
11741114
$el("br", {}, []),
11751115
this.datasrc_combo,
11761116
channel_combo,

‎js/custom-nodes-manager.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export class CustomNodesManager {
676676
"invalid-installation": ["reinstall"],
677677
}
678678

679-
if (!manager_instance.update_check_checkbox.checked) {
679+
if (!installGroups.updatable) {
680680
installGroups.enabled = installGroups.enabled.filter(it => it !== "try-update");
681681
}
682682

@@ -1809,11 +1809,16 @@ export class CustomNodesManager {
18091809
this.showStatus(`Loading custom nodes (${mode}) ...`);
18101810

18111811
const skip_update = this.show_mode === ShowMode.UPDATE ? "" : "&skip_update=true";
1812+
1813+
if(this.show_mode === ShowMode.UPDATE) {
1814+
infoToast('Fetching updated information. This may take some time if many custom nodes are installed.');
1815+
}
1816+
18121817
const res = await fetchData(`/customnode/getlist?mode=${mode}${skip_update}`);
18131818
if (res.error) {
18141819
this.showError("Failed to get custom node list.");
18151820
this.hideLoading();
1816-
return
1821+
return;
18171822
}
18181823

18191824
const { channel, node_packs } = res.data;

‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-manager"
33
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
4-
version = "3.27.2"
4+
version = "3.27.3"
55
license = { file = "LICENSE.txt" }
66
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"]
77

0 commit comments

Comments
 (0)
Please sign in to comment.