mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-14 16:44:27 +08:00
improve: better model downloading
improve: now skip_update_check is default
This commit is contained in:
parent
7bda42f1d9
commit
aab2fd5399
21
__init__.py
21
__init__.py
@ -33,7 +33,7 @@ sys.path.append('../..')
|
|||||||
from torchvision.datasets.utils import download_url
|
from torchvision.datasets.utils import download_url
|
||||||
|
|
||||||
# ensure .js
|
# ensure .js
|
||||||
print("### Loading: ComfyUI-Manager (V0.18.2)")
|
print("### Loading: ComfyUI-Manager (V0.19)")
|
||||||
|
|
||||||
comfy_ui_required_revision = 1240
|
comfy_ui_required_revision = 1240
|
||||||
comfy_ui_revision = "Unknown"
|
comfy_ui_revision = "Unknown"
|
||||||
@ -302,7 +302,7 @@ import zipfile
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
def get_model_path(data):
|
def get_model_dir(data):
|
||||||
if data['save_path'] != 'default':
|
if data['save_path'] != 'default':
|
||||||
base_model = os.path.join(folder_paths.models_dir, data['save_path'])
|
base_model = os.path.join(folder_paths.models_dir, data['save_path'])
|
||||||
else:
|
else:
|
||||||
@ -330,8 +330,13 @@ def get_model_path(data):
|
|||||||
elif model_type == "embeddings":
|
elif model_type == "embeddings":
|
||||||
base_model = folder_paths.folder_names_and_paths["embeddings"][0][0]
|
base_model = folder_paths.folder_names_and_paths["embeddings"][0][0]
|
||||||
else:
|
else:
|
||||||
base_model = None
|
base_model = "etc"
|
||||||
|
|
||||||
|
return base_model
|
||||||
|
|
||||||
|
|
||||||
|
def get_model_path(data):
|
||||||
|
base_model = get_model_dir(data)
|
||||||
return os.path.join(base_model, data['filename'])
|
return os.path.join(base_model, data['filename'])
|
||||||
|
|
||||||
|
|
||||||
@ -933,14 +938,24 @@ async def install_model(request):
|
|||||||
|
|
||||||
res = False
|
res = False
|
||||||
|
|
||||||
|
try:
|
||||||
if model_path is not None:
|
if model_path is not None:
|
||||||
print(f"Install model '{json_data['name']}' into '{model_path}'")
|
print(f"Install model '{json_data['name']}' into '{model_path}'")
|
||||||
|
|
||||||
|
if json_data['url'].startswith('https://github.com') or json_data['url'].startswith('https://huggingface.co'):
|
||||||
|
model_dir = get_model_dir(json_data)
|
||||||
|
download_url(json_data['url'], model_dir)
|
||||||
|
return web.json_response({}, content_type='application/json')
|
||||||
|
else:
|
||||||
res = download_url_with_agent(json_data['url'], model_path)
|
res = download_url_with_agent(json_data['url'], model_path)
|
||||||
else:
|
else:
|
||||||
print(f"Model installation error: invalid model type - {json_data['type']}")
|
print(f"Model installation error: invalid model type - {json_data['type']}")
|
||||||
|
|
||||||
if res:
|
if res:
|
||||||
return web.json_response({}, content_type='application/json')
|
return web.json_response({}, content_type='application/json')
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[ERROR] {e}")
|
||||||
|
pass
|
||||||
|
|
||||||
return web.Response(status=400)
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
|||||||
@ -111,6 +111,7 @@ async function install_custom_node(target, caller, mode) {
|
|||||||
async function updateComfyUI() {
|
async function updateComfyUI() {
|
||||||
update_comfyui_button.innerText = "Updating ComfyUI...";
|
update_comfyui_button.innerText = "Updating ComfyUI...";
|
||||||
update_comfyui_button.disabled = true;
|
update_comfyui_button.disabled = true;
|
||||||
|
update_comfyui_button.style.backgroundColor = "gray";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await api.fetchApi('/comfyui_manager/update_comfyui');
|
const response = await api.fetchApi('/comfyui_manager/update_comfyui');
|
||||||
@ -140,12 +141,14 @@ async function updateComfyUI() {
|
|||||||
finally {
|
finally {
|
||||||
update_comfyui_button.disabled = false;
|
update_comfyui_button.disabled = false;
|
||||||
update_comfyui_button.innerText = "Update ComfyUI";
|
update_comfyui_button.innerText = "Update ComfyUI";
|
||||||
|
update_comfyui_button.style.backgroundColor = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUpdates() {
|
async function fetchUpdates(update_check_checkbox) {
|
||||||
fetch_updates_button.innerText = "Fetching updates...";
|
fetch_updates_button.innerText = "Fetching updates...";
|
||||||
fetch_updates_button.disabled = true;
|
fetch_updates_button.disabled = true;
|
||||||
|
fetch_updates_button.style.backgroundColor = "gray";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var mode = "url";
|
var mode = "url";
|
||||||
@ -163,6 +166,7 @@ async function fetchUpdates() {
|
|||||||
if(response.status == 201) {
|
if(response.status == 201) {
|
||||||
app.ui.dialog.show('There is an updated extension available.');
|
app.ui.dialog.show('There is an updated extension available.');
|
||||||
app.ui.dialog.element.style.zIndex = 9999;
|
app.ui.dialog.element.style.zIndex = 9999;
|
||||||
|
update_check_checkbox.checked = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.ui.dialog.show('All extensions are already up-to-date with the latest versions.');
|
app.ui.dialog.show('All extensions are already up-to-date with the latest versions.');
|
||||||
@ -172,13 +176,14 @@ async function fetchUpdates() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(exception) {
|
catch(exception) {
|
||||||
app.ui.dialog.show(`Failed to update ComfyUI / ${exception}`);
|
app.ui.dialog.show(`Failed to update custom nodes / ${exception}`);
|
||||||
app.ui.dialog.element.style.zIndex = 9999;
|
app.ui.dialog.element.style.zIndex = 9999;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
fetch_updates_button.disabled = false;
|
fetch_updates_button.disabled = false;
|
||||||
fetch_updates_button.innerText = "Fetch Updates";
|
fetch_updates_button.innerText = "Fetch Updates";
|
||||||
|
fetch_updates_button.style.backgroundColor = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +343,8 @@ class CustomNodesInstaller extends ComfyDialog {
|
|||||||
$el('br')]);
|
$el('br')]);
|
||||||
msg.style.height = '100px';
|
msg.style.height = '100px';
|
||||||
msg.style.verticalAlign = 'middle';
|
msg.style.verticalAlign = 'middle';
|
||||||
|
msg.style.color = "var(--fg-color)";
|
||||||
|
|
||||||
this.element.appendChild(msg);
|
this.element.appendChild(msg);
|
||||||
|
|
||||||
// invalidate
|
// invalidate
|
||||||
@ -1343,6 +1350,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
|||||||
this.update_check_checkbox = $el("input",{type:'checkbox', id:"skip_update_check"},[])
|
this.update_check_checkbox = $el("input",{type:'checkbox', id:"skip_update_check"},[])
|
||||||
const uc_checkbox_text = $el("label",{},[" Skip update check"])
|
const uc_checkbox_text = $el("label",{},[" Skip update check"])
|
||||||
uc_checkbox_text.style.color = "var(--fg-color)";
|
uc_checkbox_text.style.color = "var(--fg-color)";
|
||||||
|
this.update_check_checkbox.checked = true;
|
||||||
|
|
||||||
update_comfyui_button =
|
update_comfyui_button =
|
||||||
$el("button", {
|
$el("button", {
|
||||||
@ -1357,7 +1365,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
|||||||
type: "button",
|
type: "button",
|
||||||
textContent: "Fetch Updates",
|
textContent: "Fetch Updates",
|
||||||
onclick:
|
onclick:
|
||||||
() => fetchUpdates()
|
() => fetchUpdates(this.update_check_checkbox)
|
||||||
});
|
});
|
||||||
|
|
||||||
let preview_combo = document.createElement("select");
|
let preview_combo = document.createElement("select");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user