From aa4024d39340fc87192264f0e611387dc2594d04 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 9 Jul 2024 16:51:15 -0400 Subject: [PATCH] check console error --- .github/workflows/test-browser.yml | 7 +++++++ nodes.py | 25 +++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-browser.yml b/.github/workflows/test-browser.yml index af79c46398a..7beb0c69646 100644 --- a/.github/workflows/test-browser.yml +++ b/.github/workflows/test-browser.yml @@ -55,6 +55,13 @@ jobs: - name: Run Playwright tests run: npx playwright test working-directory: ComfyUI_frontend + - name: Check for unhandled exceptions in server log + run: | + if grep -qE "Exception|Error" console_output.log; then + echo "Unhandled exception/error found in server log." + exit 1 + fi + working-directory: ComfyUI - uses: actions/upload-artifact@v4 if: always() with: diff --git a/nodes.py b/nodes.py index a230f725b84..5310e6ae08e 100644 --- a/nodes.py +++ b/nodes.py @@ -1888,12 +1888,29 @@ def expand_image(self, image, left, top, right, bottom, feathering): 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) - if os.path.isfile(module_path): - sp = os.path.splitext(module_path) - module_name = sp[0] + module_name = get_module_name(module_path) try: logging.debug("Trying to load custom node {}".format(module_path)) if os.path.isfile(module_path):