Compare commits

...
Author SHA1 Message Date
Dr.Lt.Data 00e04062c6 Show a model in a subfolder of an extra model path as installed
The 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). 349 of the 569
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.
2026-12-01 00:22:53 +09:00
3 changed files with 70 additions and 1 deletions
+9
View File
@@ -2,6 +2,15 @@
## Unreleased
### The 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.
### The PyTorch restore after a nodepack installs the builds that were installed before
When a nodepack changed torch or torchvision and the torch from before had
+3 -1
View File
@@ -1145,8 +1145,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']:
+58
View File
@@ -0,0 +1,58 @@
import ast
import concurrent.futures
import os
from types import SimpleNamespace
import pytest
from manager_test_utils import GLOB_DIR
KEYS = ("checkpoints", "controlnet")
def installed(tmp_path, 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)
source = (GLOB_DIR / "manager_server.py").read_text(encoding="utf-8")
nodes = [node for node in ast.parse(source).body
if isinstance(node, ast.FunctionDef) and node.name == "check_model_installed"]
assert len(nodes) == 1
namespace = {"os": os, "concurrent": concurrent, "folder_paths": folder_paths, "model_dir_name_map": {}}
exec(compile(ast.Module(nodes, []), "<check_model_installed>", "exec"), namespace)
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")
def test_model_in_a_subfolder_of_an_extra_model_path_is_installed(tmp_path):
assert installed(tmp_path, "checkpoints/SD1.5", "extra/checkpoints/SD1.5/model.safetensors") == "True"
@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, save_path, file, expected):
assert installed(tmp_path, save_path, file) == expected