mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-14 19:17:32 +08:00
fix: nested models: block inherits outer block_base and block_is_default
When models: has no base_path or is_default of its own, fall back to the enclosing block's values instead of None/False. This ensures relative category paths resolve against the outer base_path as users would expect.
This commit is contained in:
parent
e488f8bbc4
commit
f334f2db3d
@ -591,3 +591,30 @@ def test_explicit_custom_nodes_key(mock_yaml_load, clear_folder_paths, tmp_path)
|
||||
assert os.path.normpath(str(tmp_path / "my_nodes")) in \
|
||||
folder_paths.folder_names_and_paths["custom_nodes"][0]
|
||||
|
||||
|
||||
@patch("yaml.safe_load")
|
||||
def test_nested_models_inherits_block_base(mock_yaml_load, clear_folder_paths, tmp_path):
|
||||
"""models: block without its own base_path inherits the outer block's base_path."""
|
||||
config_data = {
|
||||
"comfyui": {
|
||||
"base_path": str(tmp_path),
|
||||
"is_default": True,
|
||||
"models": {
|
||||
"checkpoints": "models/checkpoints/",
|
||||
},
|
||||
}
|
||||
}
|
||||
mock_yaml_load.return_value = config_data
|
||||
folder_paths.folder_names_and_paths["checkpoints"] = ([], set())
|
||||
|
||||
yaml_path = str(tmp_path / "extra_paths.yaml")
|
||||
with open(yaml_path, "w") as f:
|
||||
f.write("")
|
||||
|
||||
load_extra_path_config(yaml_path)
|
||||
|
||||
expected = os.path.normpath(str(tmp_path / "models" / "checkpoints"))
|
||||
paths = folder_paths.folder_names_and_paths["checkpoints"][0]
|
||||
assert expected in paths
|
||||
# is_default inherited: path should be at index 0
|
||||
assert paths[0] == expected
|
||||
|
||||
@ -81,10 +81,10 @@ def load_extra_path_config(yaml_path: str, allow_system_dirs: bool = False) -> N
|
||||
# New nested style: models: { base_path, is_default, <categories> }
|
||||
has_models_block = True
|
||||
models_conf = dict(value)
|
||||
models_base = None
|
||||
models_base = block_base
|
||||
if "base_path" in models_conf:
|
||||
models_base = _resolve_base(models_conf.pop("base_path"), block_base, yaml_dir)
|
||||
models_is_default = bool(models_conf.pop("is_default", False))
|
||||
models_is_default = bool(models_conf.pop("is_default", block_is_default))
|
||||
explicit: set[str] = set(models_conf.keys())
|
||||
for cat, raw in models_conf.items():
|
||||
_add_model_paths(cat, raw, models_base, yaml_dir, models_is_default)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user