From 8cbce7ea199173a07f4b2716fc2b81d4ffc53f05 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 3 May 2023 11:56:32 -0400 Subject: [PATCH] add version flag --- installer.py | 14 ++++++++++---- launch.py | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/installer.py b/installer.py index c51fc10fc..6169857e0 100644 --- a/installer.py +++ b/installer.py @@ -211,7 +211,7 @@ def check_torch(): log.info('Using CPU-only Torch') torch_command = os.environ.get('TORCH_COMMAND', 'torch torchaudio torchvision') xformers_package = os.environ.get('XFORMERS_PACKAGE', 'none') - if 'torch' in torch_command: + if 'torch' in torch_command and not args.version: install(torch_command, 'torch torchvision torchaudio') try: import torch @@ -243,6 +243,8 @@ def check_torch(): except Exception as e: log.error(f'Could not load torch: {e}') exit(1) + if args.version: + return try: if 'xformers' in xformers_package: install(f'--no-deps {xformers_package}', ignore=True) @@ -429,7 +431,7 @@ def check_extensions(): # check version of the main repo and optionally upgrade it -def check_version(): +def check_version(offline=False): if not os.path.exists('.git'): log.error('Not a git repository') exit(1) @@ -439,12 +441,14 @@ def check_version(): # exit(1) ver = git('log -1 --pretty=format:"%h %ad"') log.info(f'Version: {ver}') + if args.version: + return commit = git('rev-parse HEAD') try: import requests except ImportError: return - logging.getLogger("urllib3").setLevel(logging.WARNING) + logging.getLogger("urllib3").setLevel(logging.ERROR) commits = None try: commits = requests.get('https://api.github.com/repos/vladmandic/automatic/branches/master', timeout=10).json() @@ -521,7 +525,8 @@ def add_args(): group.add_argument('--skip-extensions', default = False, action='store_true', help = "Skips running individual extension installers, default: %(default)s") group.add_argument('--skip-git', default = False, action='store_true', help = "Skips running all GIT operations, default: %(default)s") group.add_argument('--experimental', default = False, action='store_true', help = "Allow unsupported versions of libraries, default: %(default)s") - group.add_argument('--test', default = False, action='store_true', help = "Run test only, default: %(default)s") + group.add_argument('--test', default = False, action='store_true', help = "Run test only and exit") + group.add_argument('--version', default = False, action='store_true', help = "Print version information") def parse_args(): @@ -567,6 +572,7 @@ def read_options(): # entry method when used as module def run_setup(): setup_logging(args.upgrade) + log.info('Starting SD.Next') read_options() check_python() if args.reset: diff --git a/launch.py b/launch.py index 4dece79ea..7646dd8c2 100644 --- a/launch.py +++ b/launch.py @@ -92,6 +92,14 @@ def run_extension_installer(ext_dir): installer.run_extension_installer(ext_dir) if __name__ == "__main__": + if args.version: + installer.add_args() + installer.setup_logging(clean=False) + installer.log.info('SD.Next version information') + installer.check_python() + installer.check_version() + installer.check_torch() + exit(0) installer.run_setup() installer.extensions_preload(force=True) installer.log.info(f"Server arguments: {sys.argv[1:]}")