(installer) add a --y[es[to_all]] argument for a fully hands-off install/config

This commit is contained in:
Eugene Brodsky 2023-01-17 00:47:36 -05:00
parent 4b659982b7
commit 242abac12d
3 changed files with 30 additions and 9 deletions

View File

@ -141,28 +141,30 @@ class Installer:
pass
def install(self, path: str = "~/invokeai", version: str = "latest") -> None:
def install(self, root: str = "~/invokeai", version: str = "latest", yes_to_all=False) -> None:
"""
Install the InvokeAI application into the given runtime path
:param path: Destination path for the installation
:type path: str
:param root: Destination path for the installation
:type root: str
:param version: InvokeAI version to install
:type version: str
:param yes: Accept defaults to all questions
:type yes: bool
"""
import messages
messages.welcome()
self.dest = messages.dest_path(path)
self.dest = Path(root).expanduser().resolve() if yes_to_all else messages.dest_path(root)
self.venv = self.app_venv()
self.instance = InvokeAiInstance(runtime=self.dest, venv=self.venv)
# create the venv, install dependencies and the application
self.instance.deploy(extra_index_url=get_torch_source())
self.instance.deploy(extra_index_url=get_torch_source() if not yes_to_all else None)
# run the configuration flow
self.instance.configure()
@ -288,6 +290,9 @@ class InvokeAiInstance:
from ldm.invoke.config import configure_invokeai
# NOTE: currently the config script does its own arg parsing! this means the command-line switches
# from the installer will also automatically propagate down to the config script.
# this may change in the future with config refactoring!
configure_invokeai.main()
def install_user_scripts(self):

View File

@ -8,14 +8,30 @@ from installer import Installer
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--root", type=str, help="Destination path for installation", default="~/invokeai")
parser.add_argument(
"-r",
"--root",
dest="root",
type=str,
help="Destination path for installation",
default="~/invokeai",
)
parser.add_argument(
"-y",
"--yes",
"--yes-to-all",
dest="yes_to_all",
action="store_true",
help="Assume default answers to all questions",
default=False,
)
args = parser.parse_args()
inst = Installer()
try:
inst.install(path=args.root)
inst.install(**args.__dict__)
except KeyboardInterrupt as exc:
print("\n")
print("Ctrl-C pressed. Aborting.")

View File

@ -14,8 +14,8 @@ from rich.console import Console, Group
from rich.panel import Panel
from rich.prompt import Confirm
from rich.style import Style
from rich.text import Text
from rich.syntax import Syntax
from rich.text import Text
"""
INVOKE_AI_SRC=https://github.com/invoke-ai/InvokeAI/archive/refs/tags/${INVOKEAI_VERSION}.zip
@ -247,4 +247,4 @@ def introduction() -> None:
"",
"[i]At any point you may interrupt this program and resume later.",
)))
console.line(2)
console.line(2)