fixed: robust initial caching

https://github.com/comfyanonymous/ComfyUI/issues/7003#issuecomment-2690687621

modified: store `db_mode` setting to `config.ini`
https://github.com/ltdrdata/ComfyUI-Manager/issues/1582#issuecomment-2687332355

remove: fetch updates / skip updates
- 'updates' filter will trigger fetching
https://github.com/ltdrdata/ComfyUI-Manager/issues/1584

added: support for `disable_front` or `DISABLE_COMFYUI_MANAGER_FRONT`
This commit is contained in:
Dr.Lt.Data 2025-03-01 01:06:17 +09:00
parent 0d487bc14f
commit 5a5a37dfee
7 changed files with 62 additions and 91 deletions

View File

@ -7,7 +7,10 @@ if not os.path.exists(cli_mode_flag):
sys.path.append(os.path.join(os.path.dirname(__file__), "glob"))
import manager_server # noqa: F401
import share_3rdparty # noqa: F401
WEB_DIRECTORY = "js"
import cm_global
if not cm_global.disable_front and not 'DISABLE_COMFYUI_MANAGER_FRONT' in os.environ:
WEB_DIRECTORY = "js"
else:
print("\n[ComfyUI-Manager] !! cli-only-mode is enabled !!\n")

View File

@ -112,4 +112,6 @@ def add_on_revision_detected(k, f):
variables['cm.on_revision_detected_handler'].append((k, f))
error_dict = {}
error_dict = {}
disable_front = False

View File

@ -42,7 +42,7 @@ import manager_downloader
from node_package import InstalledNodePackage
version_code = [3, 27, 2]
version_code = [3, 27, 3]
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
@ -1614,7 +1614,8 @@ def write_config():
'security_level': get_config()['security_level'],
'skip_migration_check': get_config()['skip_migration_check'],
'always_lazy_install': get_config()['always_lazy_install'],
'network_mode': get_config()['network_mode']
'network_mode': get_config()['network_mode'],
'db_mode': get_config()['db_mode'],
}
directory = os.path.dirname(manager_config_path)
@ -1654,6 +1655,7 @@ def read_config():
'always_lazy_install': get_bool('always_lazy_install', False),
'network_mode': default_conf.get('network_mode', 'public').lower(),
'security_level': default_conf.get('security_level', 'normal').lower(),
'db_mode': default_conf.get('db_mode', 'cache').lower(),
}
except Exception:
@ -1677,6 +1679,7 @@ def read_config():
'always_lazy_install': False,
'network_mode': 'public', # public | private | offline
'security_level': 'normal', # strong | normal | normal- | weak
'db_mode': 'cache', # local | cache | remote
}

View File

@ -190,6 +190,9 @@ def set_component_policy(mode):
def set_update_policy(mode):
core.get_config()['update_policy'] = mode
def set_db_mode(mode):
core.get_config()['db_mode'] = mode
def print_comfyui_version():
global comfy_ui_hash
global comfyui_tag
@ -816,7 +819,7 @@ async def fetch_customnode_list(request):
"""
provide unified custom node list
"""
if "skip_update" in request.rel_url.query and request.rel_url.query["skip_update"] == "true":
if request.rel_url.query.get("skip_update", '').lower() == "true":
skip_update = True
else:
skip_update = False
@ -833,7 +836,7 @@ async def fetch_customnode_list(request):
core.populate_github_stats(node_packs, await json_obj_github)
core.populate_favorites(node_packs, await json_obj_extras)
check_state_of_git_node_pack(node_packs, False, do_update_check=not skip_update)
check_state_of_git_node_pack(node_packs, not skip_update, do_update_check=not skip_update)
for v in node_packs.values():
populate_markdown(v)
@ -1455,6 +1458,18 @@ async def preview_method(request):
return web.Response(status=200)
@routes.get("/manager/db_mode")
async def db_mode(request):
if "value" in request.rel_url.query:
set_db_mode(request.rel_url.query['value'])
core.write_config()
else:
return web.Response(text=core.get_config()['db_mode'], status=200)
return web.Response(status=200)
@routes.get("/manager/policy/component")
async def component_policy(request):
if "value" in request.rel_url.query:
@ -1681,20 +1696,23 @@ cm_global.register_api('cm.try-install-custom-node', confirm_try_install)
async def default_cache_update():
channel_url = core.get_config()['channel_url']
async def get_cache(filename):
if core.get_config()['default_cache_as_channel_url']:
uri = f"{channel_url}/{filename}"
else:
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
try:
if core.get_config()['default_cache_as_channel_url']:
uri = f"{channel_url}/{filename}"
else:
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
json_obj = await manager_util.get_data(uri, True)
json_obj = await manager_util.get_data(uri, True)
with manager_util.cache_lock:
with open(cache_uri, "w", encoding='utf-8') as file:
json.dump(json_obj, file, indent=4, sort_keys=True)
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
with manager_util.cache_lock:
with open(cache_uri, "w", encoding='utf-8') as file:
json.dump(json_obj, file, indent=4, sort_keys=True)
logging.info(f"[ComfyUI-Manager] default cache updated: {uri}")
except:
logging.error(f"[ComfyUI-Manager] Failed to initial fetching: {filename}")
if core.get_config()['network_mode'] != 'offline':
a = get_cache("custom-node-list.json")

View File

@ -227,7 +227,6 @@ document.head.appendChild(docStyle);
var update_comfyui_button = null;
var switch_comfyui_button = null;
var fetch_updates_button = null;
var update_all_button = null;
var restart_stop_button = null;
var update_policy_combo = null;
@ -653,57 +652,6 @@ async function switchComfyUI() {
}
}
async function fetchUpdates(update_check_checkbox) {
let prev_text = fetch_updates_button.innerText;
fetch_updates_button.innerText = "Fetching updates...";
fetch_updates_button.disabled = true;
fetch_updates_button.style.backgroundColor = "gray";
try {
var mode = manager_instance.datasrc_combo.value;
const response = await api.fetchApi(`/customnode/fetch_updates?mode=${mode}`);
if (response.status != 200 && response.status != 201) {
show_message('Failed to fetch updates.');
return false;
}
if (response.status == 201) {
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>");
const button = document.getElementById('cm-install-customnodes-button');
button.addEventListener("click",
async function() {
app.ui.dialog.close();
if(!CustomNodesManager.instance) {
CustomNodesManager.instance = new CustomNodesManager(app, self);
}
await CustomNodesManager.instance.show(CustomNodesManager.ShowMode.UPDATE);
}
);
update_check_checkbox.checked = false;
}
else {
show_message('All extensions are already up-to-date with the latest versions.');
}
return true;
}
catch (exception) {
show_message(`Failed to update custom nodes / ${exception}`);
return false;
}
finally {
fetch_updates_button.disabled = false;
fetch_updates_button.innerText = prev_text;
fetch_updates_button.style.backgroundColor = "";
}
}
async function onQueueStatus(event) {
const isElectron = 'electronAPI' in window;
@ -816,8 +764,7 @@ async function onQueueStatus(event) {
api.addEventListener("cm-queue-status", onQueueStatus);
async function updateAll(update_comfyui, manager_dialog) {
let prev_text = update_all_button.innerText;
async function updateAll(update_comfyui) {
update_all_button.innerText = "Updating...";
set_inprogress_mode();
@ -900,14 +847,6 @@ class ManagerMenuDialog extends ComfyDialog {
() => switchComfyUI()
});
fetch_updates_button =
$el("button.cm-button", {
type: "button",
textContent: "Fetch Updates",
onclick:
() => fetchUpdates(this.update_check_checkbox)
});
restart_stop_button =
$el("button.cm-button-red", {
type: "button",
@ -921,7 +860,7 @@ class ManagerMenuDialog extends ComfyDialog {
type: "button",
textContent: "Update All Custom Nodes",
onclick:
() => updateAll(false, self)
() => updateAll(false)
});
}
else {
@ -930,7 +869,7 @@ class ManagerMenuDialog extends ComfyDialog {
type: "button",
textContent: "Update All",
onclick:
() => updateAll(true, self)
() => updateAll(true)
});
}
@ -1037,12 +976,6 @@ class ManagerMenuDialog extends ComfyDialog {
let self = this;
this.update_check_checkbox = $el("input",{type:'checkbox', id:"skip_update_check"},[])
const uc_checkbox_text = $el("label",{for:"skip_update_check"},[" Skip update check"])
uc_checkbox_text.style.color = "var(--fg-color)";
uc_checkbox_text.style.cursor = "pointer";
this.update_check_checkbox.checked = true;
// db mode
this.datasrc_combo = document.createElement("select");
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 {
this.datasrc_combo.appendChild($el('option', { value: 'local', text: 'DB: Local' }, []));
this.datasrc_combo.appendChild($el('option', { value: 'remote', text: 'DB: Channel (remote)' }, []));
api.fetchApi('/manager/db_mode')
.then(response => response.text())
.then(data => { this.datasrc_combo.value = data; });
this.datasrc_combo.addEventListener('change', function (event) {
api.fetchApi(`/manager/db_mode?value=${event.target.value}`);
});
// preview method
let preview_combo = document.createElement("select");
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 {
});
return [
$el("div", {}, [this.update_check_checkbox, uc_checkbox_text]),
$el("br", {}, []),
this.datasrc_combo,
channel_combo,

View File

@ -676,7 +676,7 @@ export class CustomNodesManager {
"invalid-installation": ["reinstall"],
}
if (!manager_instance.update_check_checkbox.checked) {
if (!installGroups.updatable) {
installGroups.enabled = installGroups.enabled.filter(it => it !== "try-update");
}
@ -1809,11 +1809,16 @@ export class CustomNodesManager {
this.showStatus(`Loading custom nodes (${mode}) ...`);
const skip_update = this.show_mode === ShowMode.UPDATE ? "" : "&skip_update=true";
if(this.show_mode === ShowMode.UPDATE) {
infoToast('Fetching updated information. This may take some time if many custom nodes are installed.');
}
const res = await fetchData(`/customnode/getlist?mode=${mode}${skip_update}`);
if (res.error) {
this.showError("Failed to get custom node list.");
this.hideLoading();
return
return;
}
const { channel, node_packs } = res.data;

View File

@ -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.27.2"
version = "3.27.3"
license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"]