AttributeError: module 'comfy.cmd.server' has no attribute 'nodes'
Hi there -- I'm attempting to use ComfyScript with the ComfyUI package in a Docker image. I've followed the Readme as best I could, paired with a little reading of the source code, but I'm now stuck. Take a look at my imports and setup:
from comfy_script.runtime import *
import random
import boto3
import os
import tarfile
load('comfyui')
from comfy_script.runtime.nodes import *
Pretty standard stuff, I think. However, when the script hits the load line, it dies and spits out the following error:
Traceback (most recent call last):
File "/app/main.py", line 7, in <module>
load('comfyui')
File "/home/user/micromamba/lib/python3.10/site-packages/comfy_script/runtime/__init__.py", line 31, in load
asyncio.run(_load(comfyui, args, vars, watch, save_script_source))
File "/home/user/micromamba/lib/python3.10/site-packages/nest_asyncio.py", line 30, in run
return loop.run_until_complete(task)
File "/home/user/micromamba/lib/python3.10/site-packages/nest_asyncio.py", line 98, in run_until_complete
return f.result()
File "/home/user/micromamba/lib/python3.10/asyncio/futures.py", line 201, in result
raise self._exception.with_traceback(self._exception_tb)
File "/home/user/micromamba/lib/python3.10/asyncio/tasks.py", line 232, in __step
result = coro.send(None)
File "/home/user/micromamba/lib/python3.10/site-packages/comfy_script/runtime/__init__.py", line 54, in _load
start_comfyui(comfyui, args)
File "/home/user/micromamba/lib/python3.10/site-packages/comfy_script/runtime/__init__.py", line 340, in start_comfyui
loop.run_until_complete(main.main())
File "/home/user/micromamba/lib/python3.10/site-packages/nest_asyncio.py", line 98, in run_until_complete
return f.result()
File "/home/user/micromamba/lib/python3.10/asyncio/futures.py", line 201, in result
raise self._exception.with_traceback(self._exception_tb)
File "/home/user/micromamba/lib/python3.10/asyncio/tasks.py", line 232, in __step
result = coro.send(None)
File "/home/user/micromamba/lib/python3.10/site-packages/comfy/cmd/main.py", line 201, in main
exit(0)
File "/home/user/micromamba/lib/python3.10/site-packages/comfy_script/runtime/__init__.py", line 271, in exit_hook
setup_comfyui_polyfills(outer.f_locals)
File "/home/user/micromamba/lib/python3.10/site-packages/comfy_script/runtime/__init__.py", line 235, in setup_comfyui_polyfills
exported_nodes = comfy.cmd.server.nodes
AttributeError: module 'comfy.cmd.server' has no attribute 'nodes'
Pasted the whole stack trace for context, but the error is evident at the bottom there.
The relevant parts of my Dockerfile -- just installing the required packages, nothing special:
RUN pip install wheel
RUN pip install --no-build-isolation git+https://github.com/hiddenswitch/ComfyUI.git
RUN pip install -U "comfy-script[default]"
Any ideas on where this is going wrong? Thanks!
There are some breaking changes in the comfyui package, again (#28). It's now fixed in ComfyScript v0.4.5. I've also added the last tested commit id of comfyui in the readme, so if there are some problems with new versions in the future, one can find a working old version to workaround.
However, there are still other problems in comfyui. The built package doesn't include JSON configs needed by models (https://github.com/hiddenswitch/ComfyUI/issues/6). A workaround is to use editable install:
RUN pip install wheel
RUN git clone https://github.com/hiddenswitch/ComfyUI.git && cd ComfyUI && pip install --no-build-isolation -e .
RUN pip install -U "comfy-script[default]"
Great, that did it, thanks! And thanks for the README update as well.
I am investigating the issues reported here too
In order to improve compatibility, I'm going to introduce a method that will declare symbols wherever they used to be. I apologize for the breakage. There are significant challenges with node loading order that required moving things around - nodes are actually lazily loaded at this point, which resolved all kinds of bugs. I will keep you posted on that solution.