Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range when initializing after updating comfyui #13

Open
trojblue opened this issue Sep 8, 2024 · 1 comment

Comments

@trojblue
Copy link

trojblue commented Sep 8, 2024

here:

def _ensure_package_dicts_exist(module_name: str):

the module_name getting passed into it is comfyui-router, which does not contain any dots, therefore gets a import failed error:

Traceback (most recent call last):
  File "/rmt/yada/apps/comfyui/nodes.py", line 1993, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/rmt/yada/apps/comfyui/custom_nodes/comfyui-router/__init__.py", line 34, in <module>
    easy_nodes.initialize_easy_nodes(default_category="ComfyUI Router", auto_register=True)
  File "/root/miniconda3/lib/python3.10/site-packages/easy_nodes/easy_nodes.py", line 122, in initialize_easy_nodes
    _ensure_package_dicts_exist(frame)
  File "/root/miniconda3/lib/python3.10/site-packages/easy_nodes/easy_nodes.py", line 720, in _ensure_package_dicts_exist
    package_name = module_name.split('.')[-2]
IndexError: list index out of range

node folder init code:

# comfyui-router/__init__.py
import easy_nodes
easy_nodes.initialize_easy_nodes(default_category="ComfyUI Router", auto_register=True)

from .comfy_nodes import *  # noqa: F403, E402

NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS = easy_nodes.get_node_mappings()

print("NODE_CLASS_MAPPINGS", NODE_CLASS_MAPPINGS)
print("NODE_DISPLAY_NAME_MAPPINGS", NODE_DISPLAY_NAME_MAPPINGS)


__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]

# Optional: export the node list to a file so that e.g. ComfyUI-Manager can pick it up.
easy_nodes.save_node_list(os.path.join(os.path.dirname(__file__), "node_list.json"))

the code works fine before I updated comfyui from 0.19 to latest (9c5fca75f46f7b9f18c07385925f151a7629a94f). I tried using auto_register=False, which gets imported successfully, but if i add a debug print the frame is still a string with no dots

@trojblue
Copy link
Author

trojblue commented Sep 8, 2024

update: adding a try-except block seems to fix it?

def _ensure_package_dicts_exist(module_name: str):
    
    try:
        package_name = module_name.split('.')[-2]
    except IndexError: # package installed with pip install -e .
        package_name = module_name

init code:

import easy_nodes
easy_nodes.initialize_easy_nodes(default_category="ComfyUI Router", auto_register=True)

from .comfy_nodes import *  # noqa: F403, E402

# NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS = easy_nodes.get_node_mappings()

# print("NODE_CLASS_MAPPINGS", NODE_CLASS_MAPPINGS)
# print("NODE_DISPLAY_NAME_MAPPINGS", NODE_DISPLAY_NAME_MAPPINGS)


# __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]

# Optional: export the node list to a file so that e.g. ComfyUI-Manager can pick it up.
# easy_nodes.save_node_list(os.path.join(os.path.dirname(__file__), "node_list.json"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant