From bd2d3e27d786b89e9ef89d6eb083e94172126306 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Thu, 4 Jul 2024 21:43:23 -0400 Subject: [PATCH] Show comfy_extras warning at the end. Remove code. --- main.py | 8 ++------ nodes.py | 35 +++++++++++------------------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/main.py b/main.py index 2957dd2f..9650703a 100644 --- a/main.py +++ b/main.py @@ -81,7 +81,7 @@ import yaml import execution import server from server import BinaryEventTypes -from nodes import init_builtin_extra_nodes, init_external_custom_nodes +import nodes import comfy.model_management def cuda_malloc_warning(): @@ -219,11 +219,7 @@ if __name__ == "__main__": for config_path in itertools.chain(*args.extra_model_paths_config): load_extra_path_config(config_path) - init_builtin_extra_nodes() - if not args.disable_all_custom_nodes: - init_external_custom_nodes() - else: - logging.info("Skipping loading of custom nodes") + nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes) cuda_malloc_warning() diff --git a/nodes.py b/nodes.py index 03544be0..8f8abb49 100644 --- a/nodes.py +++ b/nodes.py @@ -1888,30 +1888,6 @@ NODE_DISPLAY_NAME_MAPPINGS = { EXTENSION_WEB_DIRS = {} -def get_module_name(module_path: str) -> str: - """ - Returns the module name based on the given module path. - Examples: - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.py") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__.py") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__/") -> "custom_nodes.my_custom_node" - get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.disabled") -> "custom_nodes.my - - Args: - module_path (str): The path of the module. - - Returns: - str: The module name. - """ - relative_path = os.path.relpath(module_path, folder_paths.base_path) - if os.path.isfile(module_path): - relative_path = os.path.splitext(relative_path)[0] - return relative_path.replace(os.sep, '.') - - def load_custom_node(module_path, ignore=set()): module_name = os.path.basename(module_path) try: @@ -2039,6 +2015,17 @@ def init_builtin_extra_nodes(): if not load_custom_node(os.path.join(extras_dir, node_file)): import_failed.append(node_file) + return import_failed + + +def init_extra_nodes(init_custom_nodes=True): + import_failed = init_external_custom_nodes() + + if init_custom_nodes: + init_external_custom_nodes() + else: + logging.info("Skipping loading of custom nodes") + if len(import_failed) > 0: logging.warning("WARNING: some comfy_extras/ nodes did not import correctly. This may be because they are missing some dependencies.\n") for node in import_failed: