Compare commits

...
Author SHA1 Message Date
Dr.Lt.Data 25b77b3d8a v4: Show a model in a subfolder of an extra model path as installed
The legacy Model Manager looked for the file of a model whose save_path
has a subfolder, such as checkpoints/SD1.5, at the top of each folder
that ComfyUI has for checkpoints and in models/checkpoints/SD1.5. A file
in checkpoints/SD1.5 of a folder that extra_model_paths.yaml adds was not
found, and the model was shown as not installed (#1844). 316 of the 509
rows of model-list.json have such a save_path under a folder of ComfyUI.

After those checks, check_model_installed now asks
folder_paths.get_full_path for the rest of the save_path and the file
name, under the first folder of the save_path. ComfyUI looks in every
folder it has for that name, the extra ones included, and finds nothing
for a name it does not have. The check only adds a way to be found, so a
model that was shown as installed still is. The copy of the function in
glob/utils/model_utils.py gets the same check.
2026-12-02 12:37:39 +09:00
4 changed files with 71 additions and 2 deletions
+8
View File
@@ -36,6 +36,14 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/
### Fixed
- The legacy Model Manager finds a model in a subfolder of an extra model path.
A model whose folder in the list has a subfolder, such as `checkpoints/SD1.5`,
was shown as not installed when its file was in that subfolder of a folder
that `extra_model_paths.yaml` adds (#1844). The Model Manager now also asks
ComfyUI where the file is. ComfyUI looks in every folder it has for the first
part of the path, the extra ones included, so the model is shown as
installed. A model that was shown as installed before still is.
- A download through aria2 works again, and one that fails is reported as
failed. With `COMFYUI_MANAGER_ARIA2_SERVER` set, the install of a registry
nodepack or of a model failed with `No module named 'manager_core'` (#3064,
+3 -1
View File
@@ -127,8 +127,10 @@ def check_model_installed(json_obj):
fullpath = os.path.join(
folder_paths.models_dir, item["save_path"], filename
)
subpath = os.path.join(item["save_path"].partition("/")[2], filename)
found = os.path.exists(fullpath) or folder_paths.get_full_path(model_dir_name, subpath)
item["installed"] = "True" if os.path.exists(fullpath) else "False"
item["installed"] = "True" if found else "False"
with concurrent.futures.ThreadPoolExecutor(8) as executor:
for item in json_obj["models"]:
+3 -1
View File
@@ -1224,8 +1224,10 @@ def check_model_installed(json_obj):
filename = item['filename']
fullpath = os.path.join(folder_paths.models_dir, item['save_path'], filename)
subpath = os.path.join(item['save_path'].partition('/')[2], filename)
found = os.path.exists(fullpath) or folder_paths.get_full_path(model_dir_name, subpath)
item['installed'] = 'True' if os.path.exists(fullpath) else 'False'
item['installed'] = 'True' if found else 'False'
with concurrent.futures.ThreadPoolExecutor(8) as executor:
for item in json_obj['models']:
+57
View File
@@ -0,0 +1,57 @@
import concurrent.futures
import os
from types import SimpleNamespace
import pytest
from legacy_html_testutil import PACKAGE, load_functions
KEYS = ("checkpoints", "controlnet")
CORES = {"legacy": PACKAGE / "legacy/manager_server.py", "glob": PACKAGE / "glob/utils/model_utils.py"}
def installed(tmp_path, core, save_path, file):
folders = {key: [str(tmp_path / "models" / key), str(tmp_path / "extra" / key)] for key in KEYS}
path = tmp_path / file
path.parent.mkdir(parents=True)
path.write_bytes(b"")
def get_full_path(key, name):
return next((os.path.join(folder, name) for folder in folders.get(key, [])
if os.path.isfile(os.path.join(folder, name))), None)
def get_filename_list(key):
return [os.path.relpath(os.path.join(root, name), folder)
for folder in folders.get(key, []) for root, _, names in os.walk(folder) for name in names]
folder_paths = SimpleNamespace(models_dir=str(tmp_path / "models"),
folder_names_and_paths={key: (paths, set()) for key, paths in folders.items()},
get_folder_paths=lambda key: folders[key],
get_filename_list=get_filename_list, get_full_path=get_full_path)
namespace = load_functions(CORES[core], {"check_model_installed"},
{"os": os, "concurrent": concurrent, "folder_paths": folder_paths,
"model_dir_name_map": {}, "MODEL_DIR_NAMES": KEYS})
row = {"name": "m", "type": "checkpoint", "base": "SD1.5", "save_path": save_path,
"filename": "model.safetensors", "url": "https://example.invalid/model.safetensors"}
namespace["check_model_installed"]({"models": [row]})
return row.get("installed")
@pytest.mark.parametrize("core", CORES)
def test_model_in_a_subfolder_of_an_extra_model_path_is_installed(tmp_path, core):
assert installed(tmp_path, core, "checkpoints/SD1.5", "extra/checkpoints/SD1.5/model.safetensors") == "True"
@pytest.mark.parametrize("core", CORES)
@pytest.mark.parametrize("save_path, file, expected", [
("checkpoints/SD1.5", "models/checkpoints/SD1.5/model.safetensors", "True"),
("checkpoints/SD1.5", "extra/checkpoints/model.safetensors", "True"),
("RGT/RGT", "models/RGT/RGT/model.safetensors", "True"),
("checkpoints/SD1.5", "extra/checkpoints/SDXL/model.safetensors", "False"),
("checkpoints/SD1.5", "extra/controlnet/SD1.5/model.safetensors", "False"),
("RGT/RGT", "extra/RGT/RGT/model.safetensors", "False"),
], ids=["install folder", "top of an extra folder", "folder of no key", "other subfolder", "folder of another key",
"extra folder of no key"])
def test_other_layouts_keep_their_state(tmp_path, core, save_path, file, expected):
assert installed(tmp_path, core, save_path, file) == expected