stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Use parse_known_args in modules/shared.py for better WSGI support.

Open stristr opened this issue 2 years ago • 2 comments

Describe what this pull request is trying to achieve.

When running in a WSGI environment (e.g. with gunicorn) there will often be additional, unknown command line args in scope. Without this change, unknown command line args will fail at initialization time.

Additional notes and description of your changes

Using parse_known_args() instead of parse_args() allows broader usage with standard hosting patterns such as gunicorn.

Environment this was tested in

OS: Linux

stristr avatar Feb 24 '23 18:02 stristr

Merging this in would make the program not error out when the user types an argument incorrectly. I would rather keep that than support some unicorn.

AUTOMATIC1111 avatar Mar 11 '23 11:03 AUTOMATIC1111

Merging this in would make the program not error out when the user types an argument incorrectly. I would rather keep that than support some unicorn.

Hmm, could we put disabling strict arg parsing behind an environment variable for minimal disruption to existing code? I believe hosting behind a proxy is common enough to merit a fix for this use case.

stristr avatar Mar 11 '23 15:03 stristr

Yeah, that's a good idea. I was thinking about adding a commandline arg and handling it in launch, bit this is simpler.

AUTOMATIC1111 avatar Mar 11 '23 18:03 AUTOMATIC1111

Thank you for the fix.

stristr avatar Mar 11 '23 18:03 stristr

https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings

AUTOMATIC1111 avatar Mar 11 '23 18:03 AUTOMATIC1111