Skip to content

Commit f334f2d

Browse files
committed
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.
1 parent e488f8b commit f334f2d

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

tests-unit/utils/extra_config_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,3 +591,30 @@ def test_explicit_custom_nodes_key(mock_yaml_load, clear_folder_paths, tmp_path)
591591
assert os.path.normpath(str(tmp_path / "my_nodes")) in \
592592
folder_paths.folder_names_and_paths["custom_nodes"][0]
593593

594+
595+
@patch("yaml.safe_load")
596+
def test_nested_models_inherits_block_base(mock_yaml_load, clear_folder_paths, tmp_path):
597+
"""models: block without its own base_path inherits the outer block's base_path."""
598+
config_data = {
599+
"comfyui": {
600+
"base_path": str(tmp_path),
601+
"is_default": True,
602+
"models": {
603+
"checkpoints": "models/checkpoints/",
604+
},
605+
}
606+
}
607+
mock_yaml_load.return_value = config_data
608+
folder_paths.folder_names_and_paths["checkpoints"] = ([], set())
609+
610+
yaml_path = str(tmp_path / "extra_paths.yaml")
611+
with open(yaml_path, "w") as f:
612+
f.write("")
613+
614+
load_extra_path_config(yaml_path)
615+
616+
expected = os.path.normpath(str(tmp_path / "models" / "checkpoints"))
617+
paths = folder_paths.folder_names_and_paths["checkpoints"][0]
618+
assert expected in paths
619+
# is_default inherited: path should be at index 0
620+
assert paths[0] == expected

utils/extra_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ def load_extra_path_config(yaml_path: str, allow_system_dirs: bool = False) -> N
8181
# New nested style: models: { base_path, is_default, <categories> }
8282
has_models_block = True
8383
models_conf = dict(value)
84-
models_base = None
84+
models_base = block_base
8585
if "base_path" in models_conf:
8686
models_base = _resolve_base(models_conf.pop("base_path"), block_base, yaml_dir)
87-
models_is_default = bool(models_conf.pop("is_default", False))
87+
models_is_default = bool(models_conf.pop("is_default", block_is_default))
8888
explicit: set[str] = set(models_conf.keys())
8989
for cat, raw in models_conf.items():
9090
_add_model_paths(cat, raw, models_base, yaml_dir, models_is_default)

0 commit comments

Comments
 (0)