[Bugfix] fixes and code cleanup to update and installation routines (#3101)

- Fix the update script to work again and fixes the ambiguity between
when a user wants to update to a tag vs updating to a branch, by making
these two operations explicitly separate.
- Remove dangling functions and arguments related to legacy checkpoint
conversion. These are no longer needed now that all legacy models are
either converted at import time, or on-the-fly in RAM.
This commit is contained in:
Lincoln Stein 2023-04-25 03:28:23 +01:00 committed by GitHub
commit c174cab3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 34 deletions

View File

@ -1,10 +1,9 @@
""" '''
Minimalist updater script. Prompts user for the tag or branch to update to and runs Minimalist updater script. Prompts user for the tag or branch to update to and runs
pip install <path_to_git_source>. pip install <path_to_git_source>.
""" '''
import os import os
import platform import platform
import requests import requests
from rich import box, print from rich import box, print
from rich.console import Console, Group, group from rich.console import Console, Group, group
@ -17,6 +16,8 @@ from rich.text import Text
from invokeai.version import __version__ from invokeai.version import __version__
INVOKE_AI_SRC="https://github.com/invoke-ai/InvokeAI/archive" INVOKE_AI_SRC="https://github.com/invoke-ai/InvokeAI/archive"
INVOKE_AI_TAG="https://github.com/invoke-ai/InvokeAI/archive/refs/tags"
INVOKE_AI_BRANCH="https://github.com/invoke-ai/InvokeAI/archive/refs/heads"
INVOKE_AI_REL="https://api.github.com/repos/invoke-ai/InvokeAI/releases" INVOKE_AI_REL="https://api.github.com/repos/invoke-ai/InvokeAI/releases"
OS = platform.uname().system OS = platform.uname().system
@ -28,22 +29,22 @@ if OS == "Windows":
else: else:
console = Console(style=Style(color="grey74", bgcolor="grey19")) console = Console(style=Style(color="grey74", bgcolor="grey19"))
def get_versions()->dict: def get_versions()->dict:
return requests.get(url=INVOKE_AI_REL).json() return requests.get(url=INVOKE_AI_REL).json()
def welcome(versions: dict): def welcome(versions: dict):
@group() @group()
def text(): def text():
yield f"InvokeAI Version: [bold yellow]{__version__}" yield f'InvokeAI Version: [bold yellow]{__version__}'
yield "" yield ''
yield "This script will update InvokeAI to the latest release, or to a development version of your choice." yield 'This script will update InvokeAI to the latest release, or to a development version of your choice.'
yield "" yield ''
yield "[bold yellow]Options:" yield '[bold yellow]Options:'
yield f"""[1] Update to the latest official release ([italic]{versions[0]['tag_name']}[/italic]) yield f'''[1] Update to the latest official release ([italic]{versions[0]['tag_name']}[/italic])
[2] Update to the bleeding-edge development version ([italic]main[/italic]) [2] Update to the bleeding-edge development version ([italic]main[/italic])
[3] Manually enter the tag or branch name you wish to update""" [3] Manually enter the [bold]tag name[/bold] for the version you wish to update to
[4] Manually enter the [bold]branch name[/bold] for the version you wish to update to'''
console.rule() console.rule()
print( print(
@ -59,33 +60,41 @@ def welcome(versions: dict):
) )
console.line() console.line()
def main(): def main():
versions = get_versions() versions = get_versions()
welcome(versions) welcome(versions)
tag = None tag = None
choice = Prompt.ask("Choice:", choices=["1", "2", "3"], default="1") branch = None
release = None
choice = Prompt.ask('Choice:',choices=['1','2','3','4'],default='1')
if choice == "1": if choice=='1':
tag = versions[0]["tag_name"] release = versions[0]['tag_name']
elif choice == "2": elif choice=='2':
tag = "main" release = 'main'
elif choice == "3": elif choice=='3':
tag = Prompt.ask("Enter an InvokeAI tag or branch name") tag = Prompt.ask('Enter an InvokeAI tag name')
elif choice=='4':
branch = Prompt.ask('Enter an InvokeAI branch name')
print(f":crossed_fingers: Upgrading to [yellow]{tag}[/yellow]") print(f':crossed_fingers: Upgrading to [yellow]{tag if tag else release}[/yellow]')
cmd = f"pip install {INVOKE_AI_SRC}/{tag}.zip --use-pep517" if release:
print("") cmd = f'pip install {INVOKE_AI_SRC}/{release}.zip --use-pep517 --upgrade'
print("") elif tag:
if os.system(cmd) == 0: cmd = f'pip install {INVOKE_AI_TAG}/{tag}.zip --use-pep517 --upgrade'
print(f":heavy_check_mark: Upgrade successful")
else: else:
print(f":exclamation: [bold red]Upgrade failed[/red bold]") cmd = f'pip install {INVOKE_AI_BRANCH}/{branch}.zip --use-pep517 --upgrade'
print('')
print('')
if os.system(cmd)==0:
print(f':heavy_check_mark: Upgrade successful')
else:
print(f':exclamation: [bold red]Upgrade failed[/red bold]')
if __name__ == "__main__": if __name__ == "__main__":
try: try:
main() main()
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass

View File

@ -109,7 +109,7 @@ dependencies = [
"invokeai-merge" = "invokeai.frontend.merge:invokeai_merge_diffusers" "invokeai-merge" = "invokeai.frontend.merge:invokeai_merge_diffusers"
"invokeai-ti" = "invokeai.frontend.training:invokeai_textual_inversion" "invokeai-ti" = "invokeai.frontend.training:invokeai_textual_inversion"
"invokeai-model-install" = "invokeai.frontend.install:invokeai_model_install" "invokeai-model-install" = "invokeai.frontend.install:invokeai_model_install"
"invokeai-update" = "invokeai.frontend.config:invokeai_update" "invokeai-update" = "invokeai.frontend.install:invokeai_update"
"invokeai-metadata" = "invokeai.frontend.CLI.sd_metadata:print_metadata" "invokeai-metadata" = "invokeai.frontend.CLI.sd_metadata:print_metadata"
"invokeai-node-cli" = "invokeai.app.cli_app:invoke_cli" "invokeai-node-cli" = "invokeai.app.cli_app:invoke_cli"
"invokeai-node-web" = "invokeai.app.api_app:invoke_api" "invokeai-node-web" = "invokeai.app.api_app:invoke_api"