From 899ed2d9a31306156ded70640acf2d2d81e6e384 Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Thu, 19 Sep 2024 18:41:41 +0900 Subject: [PATCH] add 'is_default' to model paths config including impl and doc in example file --- extra_model_paths.yaml.example | 2 ++ folder_paths.py | 7 +++++-- utils/extra_config.py | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/extra_model_paths.yaml.example b/extra_model_paths.yaml.example index d4fd55c87..b55913a5a 100644 --- a/extra_model_paths.yaml.example +++ b/extra_model_paths.yaml.example @@ -25,6 +25,8 @@ a111: #comfyui: # base_path: path/to/comfyui/ +# # You can use is_default to mark that these folders should be listed first, and used as the default dirs for eg downloads +# #is_default: true # checkpoints: models/checkpoints/ # clip: models/clip/ # clip_vision: models/clip_vision/ diff --git a/folder_paths.py b/folder_paths.py index 0ad8bc184..1f03c08d8 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -195,11 +195,14 @@ def exists_annotated_filepath(name) -> bool: return os.path.exists(filepath) -def add_model_folder_path(folder_name: str, full_folder_path: str) -> None: +def add_model_folder_path(folder_name: str, full_folder_path: str, is_default: bool = False) -> None: global folder_names_and_paths folder_name = map_legacy(folder_name) if folder_name in folder_names_and_paths: - folder_names_and_paths[folder_name][0].append(full_folder_path) + if is_default: + folder_names_and_paths[folder_name][0].insert(0, full_folder_path) + else: + folder_names_and_paths[folder_name][0].append(full_folder_path) else: folder_names_and_paths[folder_name] = ([full_folder_path], set()) diff --git a/utils/extra_config.py b/utils/extra_config.py index 7ac3650ac..908765902 100644 --- a/utils/extra_config.py +++ b/utils/extra_config.py @@ -14,6 +14,9 @@ def load_extra_path_config(yaml_path): if "base_path" in conf: base_path = conf.pop("base_path") base_path = os.path.expandvars(os.path.expanduser(base_path)) + is_default = False + if "is_default" in conf: + is_default = conf.pop("is_default") for x in conf: for y in conf[x].split("\n"): if len(y) == 0: @@ -22,4 +25,4 @@ def load_extra_path_config(yaml_path): if base_path is not None: full_path = os.path.join(base_path, full_path) logging.info("Adding extra search path {} {}".format(x, full_path)) - folder_paths.add_model_folder_path(x, full_path) + folder_paths.add_model_folder_path(x, full_path, is_default)