mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-10 23:17:11 +08:00
Allow folder_paths base_path to be customised.
This commit is contained in:
parent
80abdea13b
commit
8a29e9329e
@ -12,7 +12,38 @@ supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetenso
|
|||||||
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
|
folder_names_and_paths: dict[str, tuple[list[str], set[str]]] = {}
|
||||||
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
|
filename_list_cache: dict[str, tuple[list[str], dict[str, float], float]] = {}
|
||||||
|
|
||||||
base_path = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
|
def reset_all_paths(new_base_path: str) -> None:
|
||||||
|
"""
|
||||||
|
Internal use only. Designed for use immediately after startup.
|
||||||
|
|
||||||
|
Removes all existing known paths, clears the filename cache, and creates the defaults under a new base path.
|
||||||
|
|
||||||
|
Paths:
|
||||||
|
- All default model paths
|
||||||
|
- input
|
||||||
|
- output
|
||||||
|
- temp
|
||||||
|
- user
|
||||||
|
- custom_nodes
|
||||||
|
|
||||||
|
Also creates the input directory if missing.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
new_base_path: The base path to prepend to all default relative paths.
|
||||||
|
"""
|
||||||
|
|
||||||
|
global base_path
|
||||||
|
global models_dir
|
||||||
|
global output_directory
|
||||||
|
global temp_directory
|
||||||
|
global input_directory
|
||||||
|
global user_directory
|
||||||
|
|
||||||
|
filename_list_cache.clear()
|
||||||
|
folder_names_and_paths.clear()
|
||||||
|
|
||||||
|
base_path = new_base_path
|
||||||
models_dir = os.path.join(base_path, "models")
|
models_dir = os.path.join(base_path, "models")
|
||||||
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
|
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_pt_extensions)
|
||||||
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
||||||
@ -45,6 +76,18 @@ temp_directory = os.path.join(base_path, "temp")
|
|||||||
input_directory = os.path.join(base_path, "input")
|
input_directory = os.path.join(base_path, "input")
|
||||||
user_directory = os.path.join(base_path, "user")
|
user_directory = os.path.join(base_path, "user")
|
||||||
|
|
||||||
|
# Create input dir if it does not already exist.
|
||||||
|
if not os.path.exists(input_directory):
|
||||||
|
try:
|
||||||
|
os.makedirs(input_directory)
|
||||||
|
except:
|
||||||
|
logging.error("Failed to create input directory")
|
||||||
|
|
||||||
|
|
||||||
|
# Default configuration: add all paths relative to this file.
|
||||||
|
reset_all_paths(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
class CacheHelper:
|
class CacheHelper:
|
||||||
"""
|
"""
|
||||||
Helper class for managing file list cache data.
|
Helper class for managing file list cache data.
|
||||||
@ -84,12 +127,6 @@ def map_legacy(folder_name: str) -> str:
|
|||||||
"clip": "text_encoders"}
|
"clip": "text_encoders"}
|
||||||
return legacy.get(folder_name, folder_name)
|
return legacy.get(folder_name, folder_name)
|
||||||
|
|
||||||
if not os.path.exists(input_directory):
|
|
||||||
try:
|
|
||||||
os.makedirs(input_directory)
|
|
||||||
except:
|
|
||||||
logging.error("Failed to create input directory")
|
|
||||||
|
|
||||||
def set_output_directory(output_dir: str) -> None:
|
def set_output_directory(output_dir: str) -> None:
|
||||||
global output_directory
|
global output_directory
|
||||||
output_directory = output_dir
|
output_directory = output_dir
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user