asagi4 / comfyui-utility-nodes

Some utility nodes for ComfyUI
7 stars 3 forks source link

lark.exceptions.GrammarError: Dynamic Earley doesn't support weights on terminals #3

Open balaccord opened 1 week ago

balaccord commented 1 week ago

Tried to install your extension but got the error

Traceback (most recent call last):
  File "F:\SD\ComfyUI\ComfyUI\nodes.py", line 1993, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "F:\SD\ComfyUI\ComfyUI\custom_nodes\comfyui-utility-nodes\__init__.py", line 2, in <module>
    from .utils import wildcards as w
  File "F:\SD\ComfyUI\ComfyUI\custom_nodes\comfyui-utility-nodes\utils\wildcards.py", line 9, in <module>
    from .parse import parse
  File "F:\SD\ComfyUI\ComfyUI\custom_nodes\comfyui-utility-nodes\utils\parse.py", line 270, in <module>
    parser = lark.Lark(definition, parser="earley")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\lark.py", line 380, in __init__
    self.parser = self._build_parser()
                  ^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\lark.py", line 422, in _build_parser
    return parser_class(self.lexer_conf, parser_conf, options=self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\parser_frontends.py", line 40, in __call__
    return ParsingFrontend(lexer_conf, parser_conf, options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\parser_frontends.py", line 68, in __init__
    self.parser = create_parser(lexer_conf, parser_conf, options)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\parser_frontends.py", line 215, in create_earley_parser
    return f(lexer_conf, parser_conf, options, resolve_ambiguity=resolve_ambiguity, debug=debug, tree_class=tree_class, **extra)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\parser_frontends.py", line 192, in create_earley_parser__dynamic
    earley_matcher = EarleyRegexpMatcher(lexer_conf)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\SD\ComfyUI\python_embeded\Lib\site-packages\lark\parser_frontends.py", line 173, in __init__
    raise GrammarError("Dynamic Earley doesn't support weights on terminals", t, t.priority)
lark.exceptions.GrammarError: ("Dynamic Earley doesn't support weights on terminals", TerminalDef('_TERM', '(?:(?:(?:\r)?\n)+|;)'), 10)

lark==1.1.9 lark-parser==0.12.0 ComfyUI yesterday's 2024-09-06 10:21, c27ebeb1

I found the discussion here with this error description https://github.com/lark-parser/lark/issues/383 but it's closed at 2019

asagi4 commented 1 week ago

Try removing lark-parser. That's some weird package that seems to break things.

I have lark 1.1.9 in my own venv and it works fine.

balaccord commented 1 week ago

Unfortunately, removing lark-parser not only didn't fix comfyui-utility-nodes but broke yet two extensions instead: comfyui-prompt-control and ComfyUI-Easy-Use. And, of course, after the second ComfyUI restarting lark-parser is here again

Probably dependencies incompatibility or maybe python version. Mine is Python 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

I'm afraid I'm not quite ready to reinstall venv from scratch. At least not now while the rest is working (works don't touch). Have any other suggestions?

asagi4 commented 1 week ago

My virtualenv uses python 3.11.9, though I'm on linux; the patch version shouldn't matter. If you have some kind of windows-specific bug then I can't be of much help.

I have no idea how removing lark-parser could break comfyui-prompt-control, since I don't have that package installed at all in my venv and I would notice if not having it broke prompt control. Maybe some other part of your venv is out of date and causing issues.

asagi4 commented 1 week ago

Here's a list of packages in my venv. It probably contains some extra things not strictly needed for ComfyUI but you can use it for reference

absl-py                      2.1.0
accelerate                   0.31.0
addict                       2.4.0
aggdraw                      1.3.18.post0
aiohappyeyeballs             2.3.4
aiohttp                      3.10.2
aiosignal                    1.3.1
albucore                     0.0.12
albumentations               1.4.12
annotated-types              0.7.0
antlr4-python3-runtime       4.9.3
anyio                        4.4.0
argon2-cffi                  23.1.0
argon2-cffi-bindings         21.2.0
arrow                        1.3.0
attrs                        23.2.0
beautifulsoup4               4.12.3
binaryornot                  0.4.4
bitsandbytes                 0.43.3
blend_modes                  2.1.0
blind-watermark              0.4.4
cachetools                   5.4.0
certifi                      2024.6.2
cffi                         1.16.0
chardet                      5.2.0
charset-normalizer           3.3.2
click                        8.1.7
colorama                     0.4.6
colour-science               0.4.4
contourpy                    1.2.1
cookiecutter                 2.6.0
cryptography                 42.0.8
cuda-python                  12.5.0
cycler                       0.12.1
datasets                     2.20.0
Deprecated                   1.2.14
diffusers                    0.29.1
dill                         0.3.8
dnspython                    2.6.1
docopt                       0.6.2
easydict                     1.13
einops                       0.8.0
email_validator              2.2.0
eval_type_backport           0.2.0
fairscale                    0.4.13
fastapi                      0.111.1
fastapi-cli                  0.0.4
filelock                     3.15.4
flatbuffers                  24.3.25
flet                         0.23.2
flet-core                    0.23.2
flet-runtime                 0.23.2
fonttools                    4.53.0
frozenlist                   1.4.1
fsspec                       2024.5.0
gdown                        5.2.0
gguf                         0.9.1
gitdb                        4.0.11
GitPython                    3.1.43
google-ai-generativelanguage 0.6.6
google-api-core              2.19.1
google-api-python-client     2.139.0
google-auth                  2.32.0
google-auth-httplib2         0.2.0
google-generativeai          0.7.2
googleapis-common-protos     1.63.2
grpcio                       1.65.1
grpcio-status                1.62.2
h11                          0.14.0
httpcore                     1.0.5
httplib2                     0.22.0
httptools                    0.6.1
httpx                        0.27.0
huggingface-hub              0.23.4
idna                         3.7
image-reward                 1.5
imageio                      2.34.2
importlib_metadata           8.0.0
interegular                  0.3.3
jax                          0.4.31
jaxlib                       0.4.31
Jinja2                       3.1.4
kiwisolver                   1.4.5
kornia                       0.7.3
kornia_rs                    0.1.3
lark                         1.1.9
lazy_loader                  0.4
llvmlite                     0.43.0
loguru                       0.7.2
markdown-it-py               3.0.0
MarkupSafe                   2.1.5
matplotlib                   3.9.0
matrix-client                0.4.0
mdurl                        0.1.2
mediapipe                    0.10.14
ml-dtypes                    0.4.0
mpmath                       1.3.0
multidict                    6.0.5
multiprocess                 0.70.16
networkx                     3.3
nexfort                      0.1.dev268
numba                        0.60.0
numpy                        1.26.4
nvidia-cublas-cu12           12.4.2.65
nvidia-cuda-cupti-cu12       12.4.99
nvidia-cuda-nvrtc-cu12       12.4.99
nvidia-cuda-runtime-cu12     12.4.99
nvidia-cudnn-cu12            9.1.0.70
nvidia-cufft-cu12            11.2.0.44
nvidia-curand-cu12           10.3.5.119
nvidia-cusolver-cu12         11.6.0.99
nvidia-cusparse-cu12         12.3.0.142
nvidia-nccl-cu12             2.20.5
nvidia-nvjitlink-cu12        12.4.99
nvidia-nvtx-cu12             12.4.99
oauthlib                     3.2.2
omegaconf                    2.3.0
oneflow                      0.9.1.dev20240901+cu122
onefx                        0.0.3
onnx                         1.16.1
opencv-contrib-python        4.10.0.84
opencv-python                4.10.0.84
opencv-python-headless       4.10.0.84
opt-einsum                   3.3.0
packaging                    23.2
pandas                       2.2.2
peft                         0.12.0
piexif                       1.1.3
pillow                       10.4.0
pip                          24.2
platformdirs                 4.2.2
proto-plus                   1.24.0
protobuf                     4.25.4
psd-tools                    1.9.34
psutil                       6.0.0
py-cpuinfo                   9.0.0
pyarrow                      17.0.0
pyarrow-hotfix               0.6
pyasn1                       0.6.0
pyasn1_modules               0.4.0
pycparser                    2.22
pydantic                     2.8.2
pydantic_core                2.20.1
PyGithub                     2.3.0
Pygments                     2.18.0
PyJWT                        2.8.0
PyMatting                    1.1.12
PyNaCl                       1.5.0
pyparsing                    3.1.2
pypng                        0.20220715.0
PySocks                      1.7.1
python-dateutil              2.9.0.post0
python-dotenv                1.0.1
python-multipart             0.0.9
python-slugify               8.0.4
pytz                         2024.1
PyWavelets                   1.6.0
PyYAML                       6.0.2
pyzbar                       0.1.9
qrcode                       7.4.2
regex                        2024.5.15
repath                       0.9.0
requests                     2.32.3
rich                         13.7.1
rsa                          4.9
safetensors                  0.4.4
scikit-image                 0.24.0
scipy                        1.14.0
seaborn                      0.13.2
segment-anything             1.0
sentencepiece                0.2.0
setuptools                   59.8.0
shellingham                  1.5.4
six                          1.16.0
smmap                        5.0.1
sniffio                      1.3.1
sounddevice                  0.4.7
soundfile                    0.12.1
soupsieve                    2.5
spandrel                     0.3.4
starlette                    0.37.2
sympy                        1.12.1
tensorrt-cu12                10.1.0
tensorrt-cu12-bindings       10.1.0
tensorrt-cu12-libs           10.1.0
text-unidecode               1.3
tifffile                     2024.6.18
timm                         0.6.13
tokenizers                   0.19.1
tomli                        2.0.1
torch                        2.4.0+cu124
torchaudio                   2.4.0+cu124
torchsde                     0.2.6
torchvision                  0.19.0+cu124
tqdm                         4.66.5
trampoline                   0.1.2
transformers                 4.44.0
transparent-background       1.3.1
triton                       3.0.0
typer                        0.12.3
typer-config                 1.4.0
types-python-dateutil        2.9.0.20240316
typing_extensions            4.12.2
tzdata                       2024.1
ultralytics                  8.2.45
ultralytics-thop             2.0.0
uritemplate                  4.1.1
urllib3                      1.26.19
uvicorn                      0.30.3
uvloop                       0.19.0
watchdog                     4.0.1
watchfiles                   0.22.0
websockets                   12.0
wget                         3.2
wrapt                        1.16.0
xxhash                       3.4.1
yapf                         0.40.2
yarl                         1.9.4
zipp                         3.19.2
balaccord commented 1 week ago

I thought maybe it the polite reminder to finally clean up my comfy and made the clean install. Only comfy manager, rgthree and yours. Surprisingly or not, it took off

Have no idea what it was: yet another bit of pip hell, python version stuff or smth The new python is freshiest from the comfy Windows distro was: 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)] became: 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)]

Will try to add one by one only the modules I myself use really. There's a small chance it wouldn't break again. I remembered I saw the modules incompatibility warnings now and then after yet another pip install. All my things were working afterwards though but who knew what these incompatibilities were

Many thanks, this cleanup was in my plans for decades)

So, when it's working, would you answer please, if it's able to get the another node variables as I hoped for? I need some variable expansion feature like what the the save image node does with filenames. It's a kind of strange, all that I found so far are the two nodes only that can extract only the single value at a time. So it's needed to build the complex node chain instead of simple "A:%node1.fileld1%, B:%node2.field2%" or such

asagi4 commented 6 days ago

MUSimpleWildcard doesn't look into other nodes. The values they produce aren't available when expansion happens, and with ComfyUI's lazy evaluation of graphs nowadays, the only way to guarantee that a node's output is available to another node is to connect their input and output.

It might be possible to look up literal inputs to other nodes since ComfyUI sends those with the graph, but that's not currently implemented. Is that what you're looking for?

balaccord commented 5 days ago

Kinda sad to know nodes of that kind are not available and it's a bit of strange at once. Why? Am I the one only who need some debugging info inside of the workflow? Some days ago I was building the complex workflow with more or less complicated calculations and I needed to know what the intermediate variables were and the debugging part turned out pretty horrifying clutter of ins, outs, concats and substs. I finally managed them into the group node but it's too far from any good and not changeable at all

It seems now is the time to make my own node