Closed lingondricka2 closed 9 months ago
It's strange if CheckpointLoaderSimple
works but FreeUV2
doesn't. And line 4 and 5 shouldn't work since script/runtime/nodes.py
doesn't exist after v0.3 (there is a nodes
directory at the repository root, but it doesn't have FreeUV2
).
As for VS Code, it uses a static Python analyzer, so sys.path.insert(0, 'src')
won't make the type stub file be used. (Although type stubs in src
should be automatically used normally.)
Can you delete the script
directory, run python -m pip install -e .
at the repository root, and try again?
I did a fresh install.
sys.path.insert(0, 'src\comfy_script\runtime')
from nodes import *
Is needed to avoid NameError: name 'FreeUV2' is not defined
All classes are recognized in VS Code now though which is good.
I've tried your script on my machine. It works without issue (the error is because no output node), both with sys.path.insert(0, 'src')
and without.
Weird, I will complete the script and get back to you if the error still persists.
sys.path.insert(0, 'src\comfy_script\runtime') from nodes import *
This shouldn't work if it's copied from the script. \r
will be treated as special chars, r'src\comfy_script\runtime'
is what actually needed. With this path, from nodes import *
will import nodes/__init__.py
and do nothing since it is empty:
Anyway, nodes/__init__.py
is now removed to avoid any further confusion. It's now impossible to import it by accident.
Changed from:
sys.path.insert(0, '../../')
import folder_paths
sys.path.insert(0, 'src')
from comfy_script.runtime import *
load()
from comfy_script.runtime.nodes import *
to:
sys.path.insert(0, 'src')
from comfy_script.runtime import *
load()
from comfy_script.runtime.nodes import *
sys.path.insert(0, '../../')
import folder_paths
and it works now, I noticed no custom nodes was loaded with the top code.
Now I get it. When the runtime is used with ComfyUI loaded, it will get nodes info by import nodes
instead of accessing the API. And sys.path.insert(0, '../../')
will make the runtime think ComfyUI is loaded. As for FreeUV2
, it's actually FreeU_V2
in ComfyUI, so it can't be used but CheckpointLoaderSimple
can.
It's now fixed. Thanks very much for your test.
This might be an issue with me lacking python skills.
Gives error:
Uncomment line 4 and 5 and it works
FreeUV2 is not recognized in VS Code, uncomment line 6 and it is recognized but script gives error:
Not sure if this is how type stubs should be imported, new to python. The script is work in progress btw.