Skip to content

Commit

Permalink
Installer tweaks (#4070)
Browse files Browse the repository at this point in the history
## What type of PR is this? (check all applicable)


- [ X] Optimization

## Have you discussed this change with the InvokeAI team?
- [X ] Yes
- [ ] No, because:

      
## Have you updated all relevant documentation?
- [X ] Yes
- [ ] No


## Description

This PR does two things:

1. if the environment variable INVOKEAI_ROOT is defined at install time,
the zipfile installer will default to its value when asking the user
where to install the software
2. If the user has more than 72 models of any type installed, then the
list will be truncated in the TUI and the user given a warning. Anything
larger than this number of models causes the vertical space to overflow.
The only effect of truncation is that the user will not be able to see
and delete the models that were truncated. The message advises the user
to go to the Web Model Manager interface in this event.
  • Loading branch information
lstein authored Jul 30, 2023
2 parents 6dc4dde + cafcd16 commit adfcb61
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
5 changes: 3 additions & 2 deletions installer/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def app_venv(self, path: str = None):
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
Expand All @@ -168,7 +168,8 @@ def install(

messages.welcome()

self.dest = Path(root).expanduser().resolve() if yes_to_all else messages.dest_path(root)
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
self.venv = self.app_venv()
Expand Down
3 changes: 2 additions & 1 deletion installer/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import argparse
import os
from pathlib import Path
from installer import Installer

Expand All @@ -15,7 +16,7 @@
dest="root",
type=str,
help="Destination path for installation",
default="~/invokeai",
default=os.environ.get("INVOKEAI_ROOT") or "~/invokeai",
)
parser.add_argument(
"-y",
Expand Down
2 changes: 1 addition & 1 deletion invokeai/frontend/install/invokeai_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 20 additions & 2 deletions invokeai/frontend/install/model_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
# 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"""
Expand Down Expand Up @@ -102,7 +105,7 @@ def create(self):
SingleSelectColumns,
values=[
"STARTER MODELS",
"MORE MODELS",
"MAIN MODELS",
"CONTROLNETS",
"LORA/LYCORIS",
"TEXTUAL INVERSION",
Expand Down Expand Up @@ -271,6 +274,11 @@ def add_model_widgets(
)
)

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,
Expand All @@ -289,6 +297,16 @@ def add_model_widgets(
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(
Expand All @@ -313,7 +331,7 @@ def add_pipeline_widgets(
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,
)

Expand Down

0 comments on commit adfcb61

Please sign in to comment.