From 781322a6473f0633b8f0bb56d2d5b49098d93c1f Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sat, 29 Jul 2023 16:16:44 -0400 Subject: [PATCH 1/4] installer respects INVOKEAI_ROOT for default root location --- installer/lib/installer.py | 5 ++++- invokeai/frontend/install/model_install.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/installer/lib/installer.py b/installer/lib/installer.py index e1ca8c2e8f..f15c83ba66 100644 --- a/installer/lib/installer.py +++ b/installer/lib/installer.py @@ -168,7 +168,10 @@ class Installer: messages.welcome() - self.dest = Path(root).expanduser().resolve() if yes_to_all else messages.dest_path(root) + invokeai_root = os.environ.get('INVOKEAI_ROOT') + default_path = invokeai_root or Path(root).expanduser().resolve() + + self.dest = default_path if yes_to_all else messages.dest_path(root) # create the venv for the app self.venv = self.app_venv() diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index ea9efe1908..78dd0f88d0 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -58,6 +58,8 @@ logger = InvokeAILogger.getLogger() # from https://stackoverflow.com/questions/92438/stripping-non-printable-characters-from-a-string-in-python NOPRINT_TRANS_TABLE = {i: None for i in range(0, sys.maxunicode + 1) if not chr(i).isprintable()} +# maximum number of installed models we can display before overflowing vertically +MAX_OTHER_MODELS = 72 def make_printable(s: str) -> str: """Replace non-printable characters in a string""" @@ -271,6 +273,11 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage): ) ) + truncation = False + if len(model_labels) > MAX_OTHER_MODELS: + model_labels = model_labels[0:MAX_OTHER_MODELS] + truncation = True + widgets.update( models_selected=self.add_widget_intelligent( MultiSelectColumns, @@ -289,6 +296,16 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage): models=model_list, ) + if truncation: + widgets.update( + warning_message = self.add_widget_intelligent( + npyscreen.FixedText, + value=f"Too many models to display (max={MAX_OTHER_MODELS}). Some are not displayed.", + editable=False, + color="CAUTION", + ) + ) + self.nextrely += 1 widgets.update( download_ids=self.add_widget_intelligent( From c2eb50d1cdb85059a289fc2a712361cb9a5b438a Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sat, 29 Jul 2023 19:19:42 -0400 Subject: [PATCH 2/4] make installer use initial INVOKEAI_ROOT as default install location --- installer/lib/installer.py | 6 ++---- installer/lib/main.py | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/installer/lib/installer.py b/installer/lib/installer.py index f15c83ba66..40cfcedeb2 100644 --- a/installer/lib/installer.py +++ b/installer/lib/installer.py @@ -149,7 +149,7 @@ class Installer: return venv_dir def install( - self, root: str = "~/invokeai-3", version: str = "latest", yes_to_all=False, find_links: Path = None + self, root: str = "~/invokeai", version: str = "latest", yes_to_all=False, find_links: Path = None ) -> None: """ Install the InvokeAI application into the given runtime path @@ -168,9 +168,7 @@ class Installer: messages.welcome() - invokeai_root = os.environ.get('INVOKEAI_ROOT') - default_path = invokeai_root or Path(root).expanduser().resolve() - + default_path = os.environ.get('INVOKEAI_ROOT') or Path(root).expanduser().resolve() self.dest = default_path if yes_to_all else messages.dest_path(root) # create the venv for the app diff --git a/installer/lib/main.py b/installer/lib/main.py index b442f49255..4b74f984dc 100644 --- a/installer/lib/main.py +++ b/installer/lib/main.py @@ -3,6 +3,7 @@ InvokeAI Installer """ import argparse +import os from pathlib import Path from installer import Installer @@ -15,7 +16,7 @@ if __name__ == "__main__": dest="root", type=str, help="Destination path for installation", - default="~/invokeai", + default=os.environ.get('INVOKEAI_ROOT') or "~/invokeai", ) parser.add_argument( "-y", From b10b07220ec4253cc7e705a63154da268bcd3a0f Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sat, 29 Jul 2023 19:20:20 -0400 Subject: [PATCH 3/4] blackify code --- installer/lib/installer.py | 2 +- installer/lib/main.py | 2 +- invokeai/frontend/install/model_install.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/installer/lib/installer.py b/installer/lib/installer.py index 40cfcedeb2..e0a72b34aa 100644 --- a/installer/lib/installer.py +++ b/installer/lib/installer.py @@ -168,7 +168,7 @@ class Installer: messages.welcome() - default_path = os.environ.get('INVOKEAI_ROOT') or Path(root).expanduser().resolve() + default_path = os.environ.get("INVOKEAI_ROOT") or Path(root).expanduser().resolve() self.dest = default_path if yes_to_all else messages.dest_path(root) # create the venv for the app diff --git a/installer/lib/main.py b/installer/lib/main.py index 4b74f984dc..4f1372652b 100644 --- a/installer/lib/main.py +++ b/installer/lib/main.py @@ -16,7 +16,7 @@ if __name__ == "__main__": dest="root", type=str, help="Destination path for installation", - default=os.environ.get('INVOKEAI_ROOT') or "~/invokeai", + default=os.environ.get("INVOKEAI_ROOT") or "~/invokeai", ) parser.add_argument( "-y", diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index 78dd0f88d0..cdb1d165fd 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -61,6 +61,7 @@ NOPRINT_TRANS_TABLE = {i: None for i in range(0, sys.maxunicode + 1) if not chr( # maximum number of installed models we can display before overflowing vertically MAX_OTHER_MODELS = 72 + def make_printable(s: str) -> str: """Replace non-printable characters in a string""" return s.translate(NOPRINT_TRANS_TABLE) @@ -298,7 +299,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage): if truncation: widgets.update( - warning_message = self.add_widget_intelligent( + warning_message=self.add_widget_intelligent( npyscreen.FixedText, value=f"Too many models to display (max={MAX_OTHER_MODELS}). Some are not displayed.", editable=False, From 43b1eb8e8459db0360ed2dcc8bff859035f3d470 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sat, 29 Jul 2023 19:49:58 -0400 Subject: [PATCH 4/4] wording changes --- invokeai/frontend/install/invokeai_update.py | 2 +- invokeai/frontend/install/model_install.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/install/invokeai_update.py b/invokeai/frontend/install/invokeai_update.py index 56d1a313c7..3fe6ff1574 100644 --- a/invokeai/frontend/install/invokeai_update.py +++ b/invokeai/frontend/install/invokeai_update.py @@ -112,7 +112,7 @@ def main(): extras = get_extras() - print(f":crossed_fingers: Upgrading to [yellow]{tag if tag else release}[/yellow]") + print(f":crossed_fingers: Upgrading to [yellow]{tag or release or branch}[/yellow]") if release: cmd = f'pip install "invokeai{extras} @ {INVOKE_AI_SRC}/{release}.zip" --use-pep517 --upgrade' elif tag: diff --git a/invokeai/frontend/install/model_install.py b/invokeai/frontend/install/model_install.py index cdb1d165fd..7616fa8c81 100644 --- a/invokeai/frontend/install/model_install.py +++ b/invokeai/frontend/install/model_install.py @@ -105,7 +105,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage): SingleSelectColumns, values=[ "STARTER MODELS", - "MORE MODELS", + "MAIN MODELS", "CONTROLNETS", "LORA/LYCORIS", "TEXTUAL INVERSION", @@ -331,7 +331,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage): widgets = self.add_model_widgets( model_type=model_type, window_width=window_width, - install_prompt=f"Additional {model_type.value.title()} models already installed.", + install_prompt=f"Installed {model_type.value.title()} models. Unchecked models in the InvokeAI root directory will be deleted. Enter URLs, paths or repo_ids to import.", **kwargs, )