Chaoses-Ib / ComfyScript

A Python frontend and library for ComfyUI
https://discord.gg/arqJbtEg7w
MIT License
431 stars 24 forks source link

`AttributeError: module 'comfy.cmd.main' has no attribute 'server'` #28

Closed zer0mania closed 9 months ago

zer0mania commented 9 months ago

I tried running it with the comfyui python package however I got this error each time I try to run it.

Log:

ComfyScript: Importing ComfyUI from comfyui package
Total VRAM 12288 MB, total RAM 16297 MB
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3060 : cudaMallocAsync
VAE dtype: torch.bfloat16
Using pytorch cross attention
D:\comfyui\venv\lib\site-packages\comfy_script\runtime\__init__.py:334: RuntimeWarning: coroutine 'main' was never awaited
  main.main()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
  File "D:\comfyui\test.py", line 2, in <module>
    load("comfyui")
  File "D:\comfyui\venv\lib\site-packages\comfy_script\runtime\__init__.py", line 31, in load
    asyncio.run(_load(comfyui, args, vars, watch, save_script_source))
  File "D:\comfyui\venv\lib\site-packages\nest_asyncio.py", line 30, in run
    return loop.run_until_complete(task)
  File "D:\comfyui\venv\lib\site-packages\nest_asyncio.py", line 98, in run_until_complete
    return f.result()
  File "C:\Python\lib\asyncio\futures.py", line 201, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "C:\Python\lib\asyncio\tasks.py", line 232, in __step
    result = coro.send(None)
  File "D:\comfyui\venv\lib\site-packages\comfy_script\runtime\__init__.py", line 52, in _load
    start_comfyui(comfyui, args)
  File "D:\comfyui\venv\lib\site-packages\comfy_script\runtime\__init__.py", line 340, in start_comfyui
    threading.Thread(target=main.server.loop.run_until_complete, args=(main.server.publish_loop(),), daemon=True).start()
AttributeError: module 'comfy.cmd.main' has no attribute 'server'

Code:

from comfy_script.runtime import *
load("comfyui")
from comfy_script.runtime.nodes import *

with Workflow():
    model, clip, vae = CheckpointLoaderSimple('v1-5-pruned-emaonly.ckpt')
    conditioning = CLIPTextEncode('beautiful scenery nature glass bottle landscape, , purple galaxy bottle,', clip)
    conditioning2 = CLIPTextEncode('text, watermark', clip)
    latent = EmptyLatentImage(512, 512, 1)
    latent = KSampler(model, 156680208700286, 20, 8, 'euler', 'normal', conditioning, conditioning2, latent, 1)
    image = VAEDecode(latent, vae)
    SaveImage(image, 'ComfyUI')
Chaoses-Ib commented 9 months ago

image

The code works on the old version I use, so there must be some breaking changes in the new version. I'll fix it soon.

Chaoses-Ib commented 9 months ago

Fixed. Thanks for your report. v0.4.2 is now published and you can run python -m pip install -U comfy-script to update.