From 8e8f9cce0fcb9c10939e0bb3938e0e3657435c40 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 7 Jul 2023 20:47:29 -0400 Subject: [PATCH] print version when --version provided at command line --- invokeai/app/api/dependencies.py | 4 +++- invokeai/app/api_app.py | 12 ++++++++++-- invokeai/app/cli_app.py | 7 +++++++ invokeai/app/services/config.py | 2 ++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/invokeai/app/api/dependencies.py b/invokeai/app/api/dependencies.py index efeb778922..9c08013fef 100644 --- a/invokeai/app/api/dependencies.py +++ b/invokeai/app/api/dependencies.py @@ -17,6 +17,7 @@ from invokeai.app.services.metadata import CoreMetadataService from invokeai.app.services.resource_name import SimpleNameService from invokeai.app.services.urls import LocalUrlService from invokeai.backend.util.logging import InvokeAILogger +from invokeai.version.invokeai_version import __version__ from ..services.default_graphs import create_system_graphs from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage @@ -58,7 +59,8 @@ class ApiDependencies: @staticmethod def initialize(config, event_handler_id: int, logger: Logger = logger): - logger.info(f"Internet connectivity is {config.internet_available}") + logger.debug(f'InvokeAI version {__version__}') + logger.debug(f"Internet connectivity is {config.internet_available}") events = FastAPIEventService(event_handler_id) diff --git a/invokeai/app/api_app.py b/invokeai/app/api_app.py index 421ead5797..045edd2513 100644 --- a/invokeai/app/api_app.py +++ b/invokeai/app/api_app.py @@ -1,5 +1,6 @@ -# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) +# Copyright (c) 2022-2023 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team import asyncio +import sys from inspect import signature import uvicorn @@ -20,13 +21,20 @@ from ..backend.util.logging import InvokeAILogger app_config = InvokeAIAppConfig.get_config() app_config.parse_args() logger = InvokeAILogger.getLogger(config=app_config) +from invokeai.version.invokeai_version import __version__ + +# we call this early so that the message appears before +# other invokeai initialization messages +if app_config.version: + print(f'InvokeAI version {__version__}') + sys.exit(0) import invokeai.frontend.web as web_dir - from .api.dependencies import ApiDependencies from .api.routers import sessions, models, images, boards, board_images from .api.sockets import SocketIO from .invocations.baseinvocation import BaseInvocation + import torch if torch.backends.mps.is_available(): diff --git a/invokeai/app/cli_app.py b/invokeai/app/cli_app.py index 9af309f6d7..e3c6280ccb 100644 --- a/invokeai/app/cli_app.py +++ b/invokeai/app/cli_app.py @@ -16,6 +16,12 @@ from invokeai.backend.util.logging import InvokeAILogger config = InvokeAIAppConfig.get_config() config.parse_args() logger = InvokeAILogger().getLogger(config=config) +from invokeai.version.invokeai_version import __version__ + +# we call this early so that the message appears before other invokeai initialization messages +if config.version: + print(f'InvokeAI version {__version__}') + sys.exit(0) from invokeai.app.services.board_image_record_storage import ( SqliteBoardImageRecordStorage, @@ -208,6 +214,7 @@ def invoke_all(context: CliContext): raise SessionError() def invoke_cli(): + logger.info(f'InvokeAI version {__version__}') # get the optional list of invocations to execute on the command line parser = config.get_parser() parser.add_argument('commands',nargs='*') diff --git a/invokeai/app/services/config.py b/invokeai/app/services/config.py index 97514c5282..5efe23bdc9 100644 --- a/invokeai/app/services/config.py +++ b/invokeai/app/services/config.py @@ -389,6 +389,8 @@ setting environment variables INVOKEAI_. # note - would be better to read the log_format values from logging.py, but this creates circular dependencies issues log_format : Literal[tuple(['plain','color','syslog','legacy'])] = Field(default="color", description='Log format. Use "plain" for text-only, "color" for colorized output, "legacy" for 2.3-style logging and "syslog" for syslog-style', category="Logging") log_level : Literal[tuple(["debug","info","warning","error","critical"])] = Field(default="debug", description="Emit logging messages at this level or higher", category="Logging") + + version : bool = Field(default=False, description="Show InvokeAI version and exit", category="Other") #fmt: on def parse_args(self, argv: List[str]=None, conf: DictConfig = None, clobber=False):