From e5024bf5e94129a360c2bbb755c141379d2f618e Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 6 Jun 2023 15:17:15 -0400 Subject: [PATCH] fix conhost launch-with args --- invokeai/backend/install/invokeai_configure.py | 16 ++++++---------- invokeai/frontend/install/model_install.py | 15 +++++++-------- invokeai/frontend/install/widgets.py | 9 +++++++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/invokeai/backend/install/invokeai_configure.py b/invokeai/backend/install/invokeai_configure.py index 1d69b85aa3..77d5a2f3ff 100755 --- a/invokeai/backend/install/invokeai_configure.py +++ b/invokeai/backend/install/invokeai_configure.py @@ -37,7 +37,6 @@ from transformers import ( import invokeai.configs as configs from invokeai.app.services.config import ( - get_invokeai_config, InvokeAIAppConfig, ) from invokeai.frontend.install.model_install import addModelsForm, process_and_execute @@ -45,6 +44,8 @@ from invokeai.frontend.install.widgets import ( CenteredButtonPress, IntTitleSlider, set_min_terminal_size, + MIN_COLS, + MIN_LINES, ) from invokeai.backend.install.legacy_arg_parsing import legacy_parser from invokeai.backend.install.model_install_backend import ( @@ -55,10 +56,7 @@ from invokeai.backend.install.model_install_backend import ( UserSelections, ) -from invokeai.app.services.config import InvokeAIAppConfig - warnings.filterwarnings("ignore") - transformers.logging.set_verbosity_error() @@ -72,10 +70,6 @@ Weights_dir = "ldm/stable-diffusion-v1/" Default_config_file = config.model_conf_path SD_Configs = config.legacy_conf_path -# minimum size for the UI -MIN_COLS = 135 -MIN_LINES = 45 - PRECISION_CHOICES = ['auto','float16','float32','autocast'] INIT_FILE_PREAMBLE = """# InvokeAI initialization file @@ -690,8 +684,10 @@ def run_console_ui( # parse_args() will read from init file if present invokeai_opts = default_startup_options(initfile) invokeai_opts.root = program_opts.root - - set_min_terminal_size(MIN_COLS, MIN_LINES) + + # The third argument is needed in the Windows 11 environment to + # launch a console window running this program. + set_min_terminal_size(MIN_COLS, MIN_LINES,'invokeai-configure') # the install-models application spawns a subprocess to install # models, and will crash unless this is set before running. diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index b15ecfb1b4..56d1594bee 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -45,19 +45,16 @@ from invokeai.frontend.install.widgets import ( CenteredTitleText, MultiSelectColumns, SingleSelectColumns, - OffsetButtonPress, TextBox, BufferBox, FileBox, set_min_terminal_size, select_stable_diffusion_config_file, + MIN_COLS, + MIN_LINES, ) from invokeai.app.services.config import InvokeAIAppConfig -# minimum size for the UI -MIN_COLS = 140 -MIN_LINES = 50 - config = InvokeAIAppConfig.get_config() # build a table mapping all non-printable characters to None @@ -698,7 +695,7 @@ class StderrToMessage(): def ask_user_for_config_file(model_path: Path, tui_conn: Connection=None )->Path: - logger.debug(f'Waiting for user action in dialog box (above).') + logger.debug('Waiting for user action in dialog box (above).') if tui_conn: return _ask_user_for_cf_tui(model_path, tui_conn) else: @@ -846,8 +843,10 @@ def select_and_download_models(opt: Namespace): else: # needed because the torch library is loaded, even though we don't use it torch.multiprocessing.set_start_method("spawn") - - set_min_terminal_size(MIN_COLS, MIN_LINES) + + # the third argument is needed in the Windows 11 environment in + # order to launch and resize a console window running this program + set_min_terminal_size(MIN_COLS, MIN_LINES,'invokeai-model-install') installApp = AddModelApplication(opt) try: installApp.run() diff --git a/invokeai/frontend/install/widgets.py b/invokeai/frontend/install/widgets.py index 1180f1f811..dba5122bf9 100644 --- a/invokeai/frontend/install/widgets.py +++ b/invokeai/frontend/install/widgets.py @@ -16,8 +16,12 @@ from npyscreen import fmPopup from shutil import get_terminal_size from curses import BUTTON2_CLICKED,BUTTON3_CLICKED +# minimum size for UIs +MIN_COLS = 140 +MIN_LINES = 50 + # ------------------------------------- -def set_terminal_size(columns: int, lines: int): +def set_terminal_size(columns: int, lines: int, launch_command: str=None): ts = get_terminal_size() width = max(columns,ts.columns) height = max(lines,ts.lines) @@ -29,7 +33,8 @@ def set_terminal_size(columns: int, lines: int): # in the Windows 10 environment. if 'IA_RELAUNCHED' not in os.environ: args=['conhost'] - args.extend(sys.argv) + args.extend([launch_command] if launch_command else [sys.argv[0]]) + args.extend(sys.argv[1:]) os.environ['IA_RELAUNCHED'] = 'True' os.execvp('conhost',args) else: