mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-10 22:54:30 +08:00
feat: free model/cache feature on new style menu.
This commit is contained in:
parent
3e456756d8
commit
87fc538fd1
@ -23,7 +23,7 @@ sys.path.append(glob_path)
|
|||||||
import cm_global
|
import cm_global
|
||||||
from manager_util import *
|
from manager_util import *
|
||||||
|
|
||||||
version = [2, 44, 3]
|
version = [2, 45]
|
||||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,23 @@ import { SnapshotManager } from "./snapshot.js";
|
|||||||
|
|
||||||
var docStyle = document.createElement('style');
|
var docStyle = document.createElement('style');
|
||||||
docStyle.innerHTML = `
|
docStyle.innerHTML = `
|
||||||
|
.comfy-toast {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
z-index: 1000;
|
||||||
|
transition: opacity 0.5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comfy-toast-fadeout {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
#cm-manager-dialog {
|
#cm-manager-dialog {
|
||||||
width: 1000px;
|
width: 1000px;
|
||||||
height: 520px;
|
height: 520px;
|
||||||
@ -1288,18 +1305,43 @@ app.registerExtension({
|
|||||||
separator.style.width = "100%";
|
separator.style.width = "100%";
|
||||||
menu.append(separator);
|
menu.append(separator);
|
||||||
|
|
||||||
// new style Manager button
|
try {
|
||||||
app.menu?.saveButton.element.after(new(await import("../../scripts/ui/components/button.js")).ComfyButton({
|
// new style Manager button
|
||||||
icon: "puzzle",
|
app.menu?.saveButton.element.after(new(await import("../../scripts/ui/components/button.js")).ComfyButton({
|
||||||
action: () => {
|
icon: "puzzle",
|
||||||
if(!manager_instance)
|
action: () => {
|
||||||
setManagerInstance(new ManagerMenuDialog());
|
if(!manager_instance)
|
||||||
manager_instance.show();
|
setManagerInstance(new ManagerMenuDialog());
|
||||||
},
|
manager_instance.show();
|
||||||
tooltip: "ComfyUI Manager",
|
},
|
||||||
content: "ComfyUI Manager",
|
tooltip: "ComfyUI Manager",
|
||||||
classList: "comfyui-button comfyui-menu-mobile-collapse primary"
|
content: "ComfyUI Manager",
|
||||||
}).element);
|
classList: "comfyui-button comfyui-menu-mobile-collapse primary"
|
||||||
|
}).element);
|
||||||
|
|
||||||
|
// unload models button into new style Manager button
|
||||||
|
let cmGroup = new (await import("../../scripts/ui/components/buttonGroup.js")).ComfyButtonGroup(
|
||||||
|
new(await import("../../scripts/ui/components/button.js")).ComfyButton({
|
||||||
|
icon: "vacuum-outline",
|
||||||
|
action: () => {
|
||||||
|
free_models();
|
||||||
|
},
|
||||||
|
tooltip: "Unload Models"
|
||||||
|
}).element,
|
||||||
|
new(await import("../../scripts/ui/components/button.js")).ComfyButton({
|
||||||
|
icon: "vacuum",
|
||||||
|
action: () => {
|
||||||
|
free_models(true);
|
||||||
|
},
|
||||||
|
tooltip: "Unload Whole Cache"
|
||||||
|
}).element
|
||||||
|
);
|
||||||
|
|
||||||
|
app.menu?.settingsGroup.element.before(cmGroup.element);
|
||||||
|
}
|
||||||
|
catch(exception) {
|
||||||
|
log.console('ComfyUI is outdated. New style menu based features are disabled.');
|
||||||
|
}
|
||||||
|
|
||||||
// old style Manager button
|
// old style Manager button
|
||||||
const managerButton = document.createElement("button");
|
const managerButton = document.createElement("button");
|
||||||
@ -1311,7 +1353,6 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
menu.append(managerButton);
|
menu.append(managerButton);
|
||||||
|
|
||||||
|
|
||||||
const shareButton = document.createElement("button");
|
const shareButton = document.createElement("button");
|
||||||
shareButton.id = "shareButton";
|
shareButton.id = "shareButton";
|
||||||
shareButton.textContent = "Share";
|
shareButton.textContent = "Share";
|
||||||
|
|||||||
48
js/common.js
48
js/common.js
@ -1,5 +1,6 @@
|
|||||||
import { app } from "../../scripts/app.js";
|
import { app } from "../../scripts/app.js";
|
||||||
import { api } from "../../scripts/api.js";
|
import { api } from "../../scripts/api.js";
|
||||||
|
import { $el, ComfyDialog } from "../../scripts/ui.js";
|
||||||
|
|
||||||
export function show_message(msg) {
|
export function show_message(msg) {
|
||||||
app.ui.dialog.show(msg);
|
app.ui.dialog.show(msg);
|
||||||
@ -30,6 +31,15 @@ export function setManagerInstance(obj) {
|
|||||||
manager_instance = obj;
|
manager_instance = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function showToast(message, duration = 3000) {
|
||||||
|
const toast = $el("div.comfy-toast", {textContent: message});
|
||||||
|
document.body.appendChild(toast);
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.classList.add("comfy-toast-fadeout");
|
||||||
|
setTimeout(() => toast.remove(), 500);
|
||||||
|
}, duration);
|
||||||
|
}
|
||||||
|
|
||||||
function isValidURL(url) {
|
function isValidURL(url) {
|
||||||
if(url.includes('&'))
|
if(url.includes('&'))
|
||||||
return false;
|
return false;
|
||||||
@ -106,18 +116,34 @@ export async function install_via_git_url(url, manager_dialog) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function free_models() {
|
export async function free_models(free_execution_cache) {
|
||||||
let res = await api.fetchApi(`/free`, {
|
try {
|
||||||
method: 'POST',
|
let mode = "";
|
||||||
headers: { 'Content-Type': 'application/json' },
|
if(free_execution_cache) {
|
||||||
body: '{"unload_models": true}'
|
mode = '{"unload_models": true, "free_memory": true}';
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
mode = '{"unload_models": true}';
|
||||||
|
}
|
||||||
|
|
||||||
if(res.status == 200) {
|
let res = await api.fetchApi(`/free`, {
|
||||||
show_message('Models have been unloaded.')
|
method: 'POST',
|
||||||
}
|
headers: { 'Content-Type': 'application/json' },
|
||||||
else {
|
body: mode
|
||||||
show_message('Unloading of models failed.<BR><BR>Installed ComfyUI may be an outdated version.')
|
});
|
||||||
|
|
||||||
|
if (res.status == 200) {
|
||||||
|
if(free_execution_cache) {
|
||||||
|
showToast("'Models' and 'Execution Cache' have been unloaded.", 3000);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showToast("Models' have been unloaded.", 3000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showToast('Unloading of models failed. Installed ComfyUI may be an outdated version.', 5000);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
showToast('An error occurred while trying to unload models.', 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "comfyui-manager"
|
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."
|
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
||||||
version = "2.44.3"
|
version = "2.45"
|
||||||
license = "LICENSE"
|
license = "LICENSE"
|
||||||
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user