mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-10-04 21:17:11 +08:00
pre-scan model lists
This commit is contained in:
parent
587d0c95f2
commit
ba90c6065c
@ -5,6 +5,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
from typing import Set, List, Dict, Tuple, Literal
|
from typing import Set, List, Dict, Tuple, Literal
|
||||||
from collections.abc import Collection
|
from collections.abc import Collection
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
@ -214,6 +215,18 @@ def get_folder_paths(folder_name: str) -> list[str]:
|
|||||||
folder_name = map_legacy(folder_name)
|
folder_name = map_legacy(folder_name)
|
||||||
return folder_names_and_paths[folder_name][0][:]
|
return folder_names_and_paths[folder_name][0][:]
|
||||||
|
|
||||||
|
|
||||||
|
def prebuild_lists():
|
||||||
|
start_time = time.time()
|
||||||
|
calls = []
|
||||||
|
for folder_name in folder_names_and_paths:
|
||||||
|
calls.append(async_executor.submit(lambda: get_filename_list(folder_name)))
|
||||||
|
while len(calls) > 0:
|
||||||
|
calls.pop().result()
|
||||||
|
end_time = time.time()
|
||||||
|
logging.info("Scanned model lists in {:.2f} seconds".format(end_time - start_time))
|
||||||
|
|
||||||
|
|
||||||
def recursive_search(directory: str, excluded_dir_names: list[str] | None=None) -> tuple[list[str], dict[str, float]]:
|
def recursive_search(directory: str, excluded_dir_names: list[str] | None=None) -> tuple[list[str], dict[str, float]]:
|
||||||
if not os.path.isdir(directory):
|
if not os.path.isdir(directory):
|
||||||
return [], {}
|
return [], {}
|
||||||
@ -261,11 +274,11 @@ def recursive_search(directory: str, excluded_dir_names: list[str] | None=None)
|
|||||||
logging.debug("found {} files".format(len(result)))
|
logging.debug("found {} files".format(len(result)))
|
||||||
return result, dirs
|
return result, dirs
|
||||||
|
|
||||||
|
|
||||||
def filter_files_extensions(files: Collection[str], extensions: Collection[str]) -> list[str]:
|
def filter_files_extensions(files: Collection[str], extensions: Collection[str]) -> list[str]:
|
||||||
return sorted(list(filter(lambda a: os.path.splitext(a)[-1].lower() in extensions or len(extensions) == 0, files)))
|
return sorted(list(filter(lambda a: os.path.splitext(a)[-1].lower() in extensions or len(extensions) == 0, files)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_full_path(folder_name: str, filename: str) -> str | None:
|
def get_full_path(folder_name: str, filename: str) -> str | None:
|
||||||
global folder_names_and_paths
|
global folder_names_and_paths
|
||||||
folder_name = map_legacy(folder_name)
|
folder_name = map_legacy(folder_name)
|
||||||
|
|||||||
2
main.py
2
main.py
@ -212,6 +212,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes)
|
nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes)
|
||||||
|
|
||||||
|
folder_paths.prebuild_lists()
|
||||||
|
|
||||||
cuda_malloc_warning()
|
cuda_malloc_warning()
|
||||||
|
|
||||||
server.add_routes()
|
server.add_routes()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user