Trung0246 / ComfyUI-0246

Random nodes for ComfyUI
MIT License
113 stars 11 forks source link

Error running node if Comfy not installed in a directory called "ComfyUI" #11

Closed cliffrowley closed 12 months ago

cliffrowley commented 12 months ago

I'm running ComfyUI in a docker container, where it's installed in /app. Installing this node throws the following error:

comfyui-app-1  | Traceback (most recent call last):
comfyui-app-1  |   File "/app/nodes.py", line 1800, in load_custom_node
comfyui-app-1  |     module_spec.loader.exec_module(module)
comfyui-app-1  |   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
comfyui-app-1  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
comfyui-app-1  |   File "/app/custom_nodes/ComfyUI-0246/__init__.py", line 1, in <module>
comfyui-app-1  |     from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
comfyui-app-1  |   File "/app/custom_nodes/ComfyUI-0246/nodes.py", line 23, in <module>
comfyui-app-1  |     with utils0246.temp_dir(pathlib.Path(__file__).parent.parent.parent.parent.absolute() / "ComfyUI" / "custom_nodes"):
comfyui-app-1  |   File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
comfyui-app-1  |     return next(self.gen)
comfyui-app-1  |   File "/app/custom_nodes/ComfyUI-0246/utils.py", line 71, in temp_dir
comfyui-app-1  |     os.chdir(new_dir)
comfyui-app-1  | FileNotFoundError: [Errno 2] No such file or directory: '/ComfyUI/custom_nodes'
comfyui-app-1  |
comfyui-app-1  | Cannot import /app/custom_nodes/ComfyUI-0246 module for custom nodes: [Errno 2] No such file or directory: '/ComfyUI/custom_nodes'

I believe it's because of this line, which incorrectly assumes the installation directory name: https://github.com/Trung0246/ComfyUI-0246/blob/272894bcad5bcfe1fcacce4896c106a78d5e019d/nodes.py#L23

Perhaps instead, you could go up one fewer parents, and then you wouldn't need to know the name of the installation directory?

Trung0246 commented 12 months ago

Just changed the dir path. Hopefully nothing breaks.

cliffrowley commented 12 months ago

Lovely, I'll give it a try - thanks for your speedy response!

cliffrowley commented 12 months ago

Works perfectly. What an incredible node. Literally my favourite thing for organisation - well done!