2023-04-02 15:08:12 +00:00
|
|
|
'''
|
2023-02-12 03:32:48 +00:00
|
|
|
Minimalist updater script. Prompts user for the tag or branch to update to and runs
|
|
|
|
pip install <path_to_git_source>.
|
2023-04-02 15:08:12 +00:00
|
|
|
'''
|
2023-02-23 21:33:57 +00:00
|
|
|
import os
|
2023-02-12 03:32:48 +00:00
|
|
|
import platform
|
|
|
|
import requests
|
|
|
|
from rich import box, print
|
2023-02-23 21:33:57 +00:00
|
|
|
from rich.console import Console, Group, group
|
2023-02-12 03:32:48 +00:00
|
|
|
from rich.panel import Panel
|
|
|
|
from rich.prompt import Prompt
|
|
|
|
from rich.style import Style
|
2023-02-23 21:33:57 +00:00
|
|
|
from rich.syntax import Syntax
|
2023-02-12 03:32:48 +00:00
|
|
|
from rich.text import Text
|
|
|
|
|
2023-03-03 05:02:15 +00:00
|
|
|
from invokeai.version import __version__
|
2023-02-12 03:32:48 +00:00
|
|
|
|
2023-04-02 15:08:12 +00:00
|
|
|
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"
|
2023-02-12 03:32:48 +00:00
|
|
|
|
|
|
|
OS = platform.uname().system
|
|
|
|
ARCH = platform.uname().machine
|
|
|
|
|
|
|
|
if OS == "Windows":
|
|
|
|
# Windows terminals look better without a background colour
|
|
|
|
console = Console(style=Style(color="grey74"))
|
|
|
|
else:
|
2023-02-23 21:33:57 +00:00
|
|
|
console = Console(style=Style(color="grey74", bgcolor="grey19"))
|
2023-02-12 03:32:48 +00:00
|
|
|
|
2023-04-02 15:08:12 +00:00
|
|
|
def get_versions()->dict:
|
2023-02-12 03:32:48 +00:00
|
|
|
return requests.get(url=INVOKE_AI_REL).json()
|
|
|
|
|
|
|
|
def welcome(versions: dict):
|
2023-04-02 15:08:12 +00:00
|
|
|
|
2023-02-12 03:32:48 +00:00
|
|
|
@group()
|
|
|
|
def text():
|
2023-04-02 15:08:12 +00:00
|
|
|
yield f'InvokeAI Version: [bold yellow]{__version__}'
|
|
|
|
yield ''
|
|
|
|
yield 'This script will update InvokeAI to the latest release, or to a development version of your choice.'
|
|
|
|
yield ''
|
|
|
|
yield '[bold yellow]Options:'
|
|
|
|
yield f'''[1] Update to the latest official release ([italic]{versions[0]['tag_name']}[/italic])
|
2023-02-12 03:32:48 +00:00
|
|
|
[2] Update to the bleeding-edge development version ([italic]main[/italic])
|
2023-04-02 15:08:12 +00:00
|
|
|
[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'''
|
2023-02-12 03:32:48 +00:00
|
|
|
|
|
|
|
console.rule()
|
2023-02-23 21:33:57 +00:00
|
|
|
print(
|
2023-02-12 03:32:48 +00:00
|
|
|
Panel(
|
|
|
|
title="[bold wheat1]InvokeAI Updater",
|
|
|
|
renderable=text(),
|
|
|
|
box=box.DOUBLE,
|
|
|
|
expand=True,
|
|
|
|
padding=(1, 2),
|
2023-02-23 21:33:57 +00:00
|
|
|
style=Style(bgcolor="grey23", color="orange1"),
|
2023-02-12 03:32:48 +00:00
|
|
|
subtitle=f"[bold grey39]{OS}-{ARCH}",
|
|
|
|
)
|
|
|
|
)
|
2023-02-23 21:33:57 +00:00
|
|
|
console.line()
|
2023-02-12 03:32:48 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
versions = get_versions()
|
|
|
|
welcome(versions)
|
|
|
|
|
|
|
|
tag = None
|
2023-04-02 15:08:12 +00:00
|
|
|
branch = None
|
|
|
|
release = None
|
|
|
|
choice = Prompt.ask('Choice:',choices=['1','2','3','4'],default='1')
|
|
|
|
|
|
|
|
if choice=='1':
|
|
|
|
release = versions[0]['tag_name']
|
|
|
|
elif choice=='2':
|
|
|
|
release = 'main'
|
|
|
|
elif choice=='3':
|
|
|
|
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 if tag else release}[/yellow]')
|
|
|
|
if release:
|
|
|
|
cmd = f'pip install {INVOKE_AI_SRC}/{release}.zip --use-pep517 --upgrade'
|
|
|
|
elif tag:
|
|
|
|
cmd = f'pip install {INVOKE_AI_TAG}/{tag}.zip --use-pep517 --upgrade'
|
2023-02-23 21:33:57 +00:00
|
|
|
else:
|
2023-04-02 15:08:12 +00:00
|
|
|
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]')
|
|
|
|
|
2023-02-12 03:32:48 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
pass
|
2023-04-02 15:08:12 +00:00
|
|
|
|