civitai / civitai_comfy_nodes

Comfy Nodes that make utilizing resources from Civitas easy as copying and pasting
100 stars 16 forks source link

'IndexError: list index out of range' in comfy-nodes\utils.py #1

Closed DoogeJ closed 1 year ago

DoogeJ commented 1 year ago

I am probably doing something wrong, but I cloned civitai/comfy-nodes in my ComfyUI\custom_nodes-folder, where it created a nice subfolder.

But now ComfyUI fails to load with an IndexError: list index out of range in comfy-nodes\utils.py on key = os.path.join(path_parts[-2], path_parts[-1]).

Full stacktrace:

Traceback (most recent call last):
  File "C:\dev\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "C:\dev\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_app.py", line 504, in _handle
    resp = await handler(request)
  File "C:\dev\ComfyUI_windows_portable\python_embeded\lib\site-packages\aiohttp\web_middlewares.py", line 117, in impl
    return await handler(request)
  File "C:\dev\ComfyUI_windows_portable\ComfyUI\server.py", line 42, in cache_control
    response: web.Response = await handler(request)
  File "C:\dev\ComfyUI_windows_portable\ComfyUI\server.py", line 390, in get_object_info
    out[x] = node_info(x)
  File "C:\dev\ComfyUI_windows_portable\ComfyUI\server.py", line 369, in node_info
    info['input'] = obj_class.INPUT_TYPES()
  File "C:\dev\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy-nodes\civitai_lora_loader.py", line 34, in INPUT_TYPES
    lora_paths = short_paths_map(LORAS)
  File "C:\dev\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfy-nodes\utils.py", line 8, in short_paths_map
    key = os.path.join(path_parts[-2], path_parts[-1])
IndexError: list index out of range

Environment information:

Suggestions very welcome!

barney1511 commented 1 year ago
Error handling request
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\aiohttp\web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "C:\Program Files\Python310\lib\site-packages\aiohttp\web_app.py", line 504, in _handle
    resp = await handler(request)
  File "C:\Program Files\Python310\lib\site-packages\aiohttp\web_middlewares.py", line 117, in impl
    return await handler(request)
  File "X:\ComfyUI\server.py", line 42, in cache_control
    response: web.Response = await handler(request)
  File "X:\ComfyUI\server.py", line 390, in get_object_info
    out[x] = node_info(x)
  File "X:\ComfyUI\server.py", line 369, in node_info
    info['input'] = obj_class.INPUT_TYPES()
  File "X:\ComfyUI\custom_nodes\comfy-nodes\civitai_lora_loader.py", line 34, in INPUT_TYPES
    lora_paths = short_paths_map(LORAS)
  File "X:\ComfyUI\custom_nodes\comfy-nodes\utils.py", line 8, in short_paths_map
    key = os.path.join(path_parts[-2], path_parts[-1])
IndexError: list index out of range

Just adding that I'm also getting the same error. Same version of python as OP but I'm on Windows 11. This is on a fresh install of ComfyUI and this plugin.

DoogeJ commented 1 year ago

@barney1511 are you using ComfyUI with the option to use Automatic1111 folder structures by defining the path in extra_model_paths.yaml?

I feel like this might cause an issue. My Python is horrible, but when I delete or rename extra_model_paths.yaml in my setup, suddenly everything starts working as expected. I suppose it's time to get rid of Automatic1111 and move my models over until this is fixed :)

WASasquatch commented 1 year ago

If paths are too short, we can't shorten the paths any further, so we get a key error. I failed to account for this. In this patch: https://github.com/civitai/comfy-nodes/commit/d556af6e3663329868bee416ed517c945f13b7f0#diff-09d0cbaf891d623ac245ccf84485a687b554217349ca55557c60b33234b969aeR8 I am just using the "full" path when we can't shorten it.

DoogeJ commented 1 year ago

Works for me now! Thanks a lot for the rapid response! :)