Merge branch 'v2.3' into bugfix/v2-model-conversion

This commit is contained in:
Lincoln Stein 2023-02-23 21:27:49 -05:00 committed by GitHub
commit 0982548e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 45 deletions

View File

@ -28,7 +28,7 @@ jobs:
run: twine check dist/* run: twine check dist/*
- name: check PyPI versions - name: check PyPI versions
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/v2.3'
run: | run: |
pip install --upgrade requests pip install --upgrade requests
python -c "\ python -c "\

View File

@ -1 +1 @@
__version__='2.3.1+rc3' __version__='2.3.1-rc4'

View File

@ -2,18 +2,16 @@
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 platform import platform
import requests import requests
import subprocess
from rich import box, print from rich import box, print
from rich.console import Console, group from rich.console import Console, Group, group
from rich.panel import Panel from rich.panel import Panel
from rich.prompt import Prompt from rich.prompt import Prompt
from rich.style import Style from rich.style import Style
from rich.syntax import Syntax
from rich.text import Text from rich.text import Text
from rich.live import Live
from rich.table import Table
from ldm.invoke import __version__ from ldm.invoke import __version__
@ -23,13 +21,11 @@ INVOKE_AI_REL="https://api.github.com/repos/invoke-ai/InvokeAI/releases"
OS = platform.uname().system OS = platform.uname().system
ARCH = platform.uname().machine ARCH = platform.uname().machine
ORANGE_ON_DARK_GREY = Style(bgcolor="grey23", color="orange1")
if OS == "Windows": if OS == "Windows":
# Windows terminals look better without a background colour # Windows terminals look better without a background colour
console = Console(style=Style(color="grey74")) console = Console(style=Style(color="grey74"))
else: else:
console = Console(style=Style(color="grey74", bgcolor="grey23")) 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()
@ -48,55 +44,45 @@ def welcome(versions: dict):
[3] Manually enter the tag or branch name you wish to update''' [3] Manually enter the tag or branch name you wish to update'''
console.rule() console.rule()
console.print( print(
Panel( Panel(
title="[bold wheat1]InvokeAI Updater", title="[bold wheat1]InvokeAI Updater",
renderable=text(), renderable=text(),
box=box.DOUBLE, box=box.DOUBLE,
expand=True, expand=True,
padding=(1, 2), padding=(1, 2),
style=ORANGE_ON_DARK_GREY, style=Style(bgcolor="grey23", color="orange1"),
subtitle=f"[bold grey39]{OS}-{ARCH}", subtitle=f"[bold grey39]{OS}-{ARCH}",
) )
) )
# console.rule is used instead of console.line to maintain dark background console.line()
# on terminals where light background is the default
console.rule(characters=" ")
def main(): def main():
versions = get_versions() versions = get_versions()
welcome(versions) welcome(versions)
tag = None tag = None
choice = Prompt.ask(Text.from_markup(('[grey74 on grey23]Choice:')),choices=['1','2','3'],default='1') choice = Prompt.ask('Choice:',choices=['1','2','3'],default='1')
if choice=='1': if choice=='1':
tag = versions[0]['tag_name'] tag = versions[0]['tag_name']
elif choice=='2': elif choice=='2':
tag = 'main' tag = 'main'
elif choice=='3': elif choice=='3':
tag = Prompt.ask('[grey74 on grey23]Enter an InvokeAI tag or branch name') tag = Prompt.ask('Enter an InvokeAI tag or branch name')
console.print(Panel(f':crossed_fingers: Upgrading to [yellow]{tag}[/yellow]', box=box.MINIMAL, style=ORANGE_ON_DARK_GREY))
print(f':crossed_fingers: Upgrading to [yellow]{tag}[/yellow]')
cmd = f'pip install {INVOKE_AI_SRC}/{tag}.zip --use-pep517' cmd = f'pip install {INVOKE_AI_SRC}/{tag}.zip --use-pep517'
print('')
progress = Table.grid(expand=True) print('')
progress_panel = Panel(progress, box=box.MINIMAL, style=ORANGE_ON_DARK_GREY) if os.system(cmd)==0:
print(f':heavy_check_mark: Upgrade successful')
with subprocess.Popen(['bash', '-c', cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
progress.add_column()
with Live(progress_panel, console=console, vertical_overflow='visible'):
while proc.poll() is None:
for l in iter(proc.stdout.readline, b''):
progress.add_row(l.decode().strip(), style=ORANGE_ON_DARK_GREY)
if proc.returncode == 0:
console.rule(f':heavy_check_mark: Upgrade successful')
else: else:
console.rule(f':exclamation: [bold red]Upgrade failed[/red bold]') 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

@ -19,15 +19,7 @@ from typing import Union
Globals = Namespace() Globals = Namespace()
# This is usually overwritten by the command line and/or environment variables # Where to look for the initialization file and other key components
if os.environ.get('INVOKEAI_ROOT'):
Globals.root = osp.abspath(os.environ.get('INVOKEAI_ROOT'))
elif os.environ.get('VIRTUAL_ENV'):
Globals.root = osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'), '..'))
else:
Globals.root = osp.abspath(osp.expanduser('~/invokeai'))
# Where to look for the initialization file
Globals.initfile = 'invokeai.init' Globals.initfile = 'invokeai.init'
Globals.models_file = 'models.yaml' Globals.models_file = 'models.yaml'
Globals.models_dir = 'models' Globals.models_dir = 'models'
@ -35,6 +27,20 @@ Globals.config_dir = 'configs'
Globals.autoscan_dir = 'weights' Globals.autoscan_dir = 'weights'
Globals.converted_ckpts_dir = 'converted_ckpts' Globals.converted_ckpts_dir = 'converted_ckpts'
# Set the default root directory. This can be overwritten by explicitly
# passing the `--root <directory>` argument on the command line.
# logic is:
# 1) use INVOKEAI_ROOT environment variable (no check for this being a valid directory)
# 2) use VIRTUAL_ENV environment variable, with a check for initfile being there
# 3) use ~/invokeai
if os.environ.get('INVOKEAI_ROOT'):
Globals.root = osp.abspath(os.environ.get('INVOKEAI_ROOT'))
elif os.environ.get('VIRTUAL_ENV') and Path(os.environ.get('VIRTUAL_ENV'),'..',Globals.initfile).exists():
Globals.root = osp.abspath(osp.join(os.environ.get('VIRTUAL_ENV'), '..'))
else:
Globals.root = osp.abspath(osp.expanduser('~/invokeai'))
# Try loading patchmatch # Try loading patchmatch
Globals.try_patchmatch = True Globals.try_patchmatch = True