From 895fc30c378cd8c91b56095d57f70dbfa995132d Mon Sep 17 00:00:00 2001 From: wl-zhao Date: Sun, 20 Oct 2024 09:33:56 +0800 Subject: [PATCH] fix folder_path bugs --- custom_routes.py | 2 +- dependency_checker.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/custom_routes.py b/custom_routes.py index bedb50e..3fbab8b 100755 --- a/custom_routes.py +++ b/custom_routes.py @@ -59,7 +59,7 @@ def schema_validator(prompt): if node_class_type is None: raise NotImplementedError(f"Missing nodes founded, please first install the missing nodes using ComfyUI Manager") node_cls = NODE_CLASS_MAPPINGS[node_class_type] - if hasattr(node_cls, "RELATIVE_PYTHON_MODULE") and node_cls.RELATIVE_PYTHON_MODULE == "custom_nodes.ComfyUI-ShellAgent-Plugin": + if hasattr(node_cls, "RELATIVE_PYTHON_MODULE") and node_cls.RELATIVE_PYTHON_MODULE.startswith("custom_nodes.ComfyUI-ShellAgent-Plugin"): schema = {} if "input_name" in node_info["inputs"]: mode = "inputs" diff --git a/dependency_checker.py b/dependency_checker.py index d79490e..b9dfb94 100644 --- a/dependency_checker.py +++ b/dependency_checker.py @@ -5,6 +5,8 @@ import logging from functools import partial import re import glob +from folder_paths import models_dir as MODELS_DIR +from folder_paths import base_path as BASE_PATH from .utils import compute_sha256, windows_to_linux_path from .file_upload import collect_local_file, process_local_file_path_async @@ -115,7 +117,7 @@ def resolve_dependencies(prompt, custom_dependencies): # resolve custom nodes an for item in model_loaders_info[node_class_type]: pattern = item["field_name"] if re.match(f"^{pattern}$", field_name): - ckpt_path = os.path.join("models", item["save_path"], filename) + ckpt_path = os.path.join(MODELS_DIR, item["save_path"], filename) ckpt_paths.append(ckpt_path) else: for field_name, filename in node_info["inputs"].items(): @@ -130,7 +132,7 @@ def resolve_dependencies(prompt, custom_dependencies): # resolve custom nodes an # find possible paths matching_files = [] # Walk through all subdirectories and files in the directory - for possible_filename in glob.glob("models/**/*", recursive=True): + for possible_filename in glob.glob(os.path.join(MODELS_DIR, "**", "*"), recursive=True): if os.path.isfile(possible_filename) and possible_filename.endswith(filename): matching_files.append(possible_filename) print(f"matched files: {matching_files}") @@ -142,7 +144,7 @@ def resolve_dependencies(prompt, custom_dependencies): # resolve custom nodes an print("ckpt_paths:", ckpt_paths) custom_nodes = list(set(custom_nodes)) # step 0: comfyui version - comfyui_version = inspect_repo_version("./") + comfyui_version = inspect_repo_version(BASE_PATH) # step 1: custom nodes custom_nodes_list = []