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

improved argument parsing

Open hananbeer opened this issue 1 year ago • 3 comments

improved argument parsing

take for example command: python launch.py --skip-install --zformer (arg with typo) previous behavior had some annoying issues:

  1. add missing arguments --skip-install and --exit weren't present in arg parse which printed an error even though they were functional

  2. don't crash when bad arg is passed when an incorrect argument is passed, you waited the entire startup just to fail afterwards. now you won't crash and a warning will be issued.

  3. use --skip-install argument for extensions install as well the more extensions you have, the longer startup times - significantly.

no extensions: Startup time: 38.8s

several extensions: Extensions loaded: 96.3s

there is already existing --skip-install for pip, so I used it for extensions as well.

things to consider

I think after extension install we should put a ".installed" file in the directory and skip install if it exists. I wanted to discuss before implementing this but my logic is this: install.py will probably update pip and other things but not the extension itself, which can break the extension. to upgrade extensions you should use the UI, or possibly add an argument for this.

if you think this is a good idea I will create a PR.

hananbeer avatar Mar 15 '23 05:03 hananbeer

I made a few more changes. it seems like a lot of changes but actually it's mostly renaming things and moving things such that everything loads at the right order, faster boot times. I took extra care to ensure it is compatible so it doesn't break any args from older versions, scripts, extensions, etc.

also added --fast-boot option which helps a lot with loading times.

hananbeer avatar Mar 16 '23 08:03 hananbeer

"I made a few more changes to argument parser." actually I refactored the entire arg parsing to unify the behavior since it was causing all sorts of issues the way it was currently designed where args were parsed in many different ways in different locations.

it seems like a lot of changes but actually it's mostly renaming things and moving things.

now it's easier (and cleaner) to add new args.

  • added missing args
  • no more unnecessary warnings about args
  • not crashing if args passed improperly
  • loading everything in the correct order
  • --help will show every arg properly, including extensions
  • faster boot times in general
    • especially with the --fast-boot arg I added which is great :)
  • fix fork bomb in tests; again this was caused by improper handling of args
  • I took extra care to ensure compatibility so older scripts and extensions won't break

hananbeer avatar Mar 16 '23 09:03 hananbeer

The PR is too big. Some of the changes (not launching extensions' installers) are welcome but I don't want to merge big refactoring PRs from anyone but me. A command line option that just enables other command line options is not welcome. Also I think this makes it impossible to just launch webui.py instead of launch.py, which some people do. The shared.py -> cmd_args.py edits make it so that entire history of the commandline args, when were they added and by who is lost - this is also undesirable. PRs should be small and limited to just one thing when possible.

AUTOMATIC1111 avatar Mar 25 '23 11:03 AUTOMATIC1111