better error reporting when root directory not found (#2001)

- The invoke.py script now checks that the root (runtime) directory contains
  the expected config/models.yaml file and if it doesn't exits with a helpful
  error message about how to set the proper root.

- Formerly the script would fail with a "bad model" message and try to redownload
  its models, which is not helpful in the case that the root is missing or
  damaged.
This commit is contained in:
Lincoln Stein 2022-12-15 09:34:10 -05:00 committed by GitHub
parent 834e56a513
commit 6c015eedb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,9 +45,15 @@ def main():
print('--max_loaded_models must be >= 1; using 1')
args.max_loaded_models = 1
# alert - setting globals here
# alert - setting a global here
Globals.try_patchmatch = args.patchmatch
if not os.path.exists(os.path.join(Globals.root,'configs','models.yaml')):
print(f"\n** Error. The file {os.path.join(Globals.root,'configs','models.yaml')} could not be found.")
print(f'** Please check the location of your invokeai directory and use the --root_dir option to point to the correct path.')
print(f'** This script will now exit.')
sys.exit(-1)
print(f'>> InvokeAI runtime directory is "{Globals.root}"')
# loading here to avoid long delays on startup