dynamicprompts icon indicating copy to clipboard operation
dynamicprompts copied to clipboard

[Bug] a pair of underscores not associated with a wildcard will cause the parsing to fail

Open acorderob opened this issue 2 years ago • 4 comments

This is using the A1111 extension. I happened to use a lora that had two underscores in its filename and when the wildcard that contained it chose that option the entire dynamic prompts failed, leaving the prompt unprocessed (but not failing the A1111 generation) and not showing any useful info in the stack trace.

I traced the problem to this part of the code of this library: dynamicprompts\parser\parse.py line 454 when the execution of the parse_string function gave an exception.

My temporary fix is replacing with this, so at least it gives an indication in the console of where the problem is:

    try:
        tokens = get_cached_parser(parser_config).parse_string(
            prompt,
            parse_all=True,
        )
    except Exception as exc:
        raise ValueError(f"Could not parse prompt {prompt!r}") from exc

But it should probably be better to fix the parser to not fail when it finds double underscores.

acorderob avatar Nov 05 '23 11:11 acorderob

As a workaround, you could change the wildcard wrap in the settings to another string - https://github.com/adieyal/sd-dynamic-prompts/#changing-syntax

adieyal avatar Nov 10 '23 23:11 adieyal

I think it could be useful to add a "strict mode" to the SD extension, so that if prompt parsing fails, it'd fail the generation and not use the verbatim command. I've had that happen too many times...

akx avatar Nov 11 '23 10:11 akx

I think it could be useful to add a "strict mode" to the SD extension, so that if prompt parsing fails, it'd fail the generation and not use the verbatim command. I've had that happen too many times...

That hasn't bothered me, but isn't onerous to implement so no reason not to.

adieyal avatar Nov 11 '23 17:11 adieyal

Failing the generation when the parsing fails would be nice. But it also needs proper logging to see where it fails.

acorderob avatar Nov 11 '23 17:11 acorderob