(installer) use plumbum for better stdout streaming

This commit is contained in:
Eugene Brodsky 2023-01-09 22:19:38 -05:00
parent f75b194b76
commit c279314cf5

View File

@ -11,7 +11,7 @@ from pathlib import Path
from tempfile import TemporaryDirectory, TemporaryFile from tempfile import TemporaryDirectory, TemporaryFile
SUPPORTED_PYTHON = ">=3.9.0,<3.11" SUPPORTED_PYTHON = ">=3.9.0,<3.11"
INSTALLER_REQS = ["rich", "semver", "requests"] INSTALLER_REQS = ["rich", "semver", "requests", "plumbum"]
OS = platform.uname().system OS = platform.uname().system
ARCH = platform.uname().machine ARCH = platform.uname().machine
@ -150,6 +150,8 @@ class Installer:
self.instance.deploy() self.instance.deploy()
self.instance.configure()
class InvokeAiInstance: class InvokeAiInstance:
""" """
@ -183,33 +185,33 @@ class InvokeAiInstance:
### this is all very rough for now as a PoC ### this is all very rough for now as a PoC
### source installer basically ### source installer basically
proc = subprocess.Popen( from plumbum import local, FG
[
self.pip, pip = local[self.pip]
(
pip[
"install", "install",
"--require-virtualenv", "--require-virtualenv",
"-r", "-r",
(Path(__file__).parents[1] / "environments-and-requirements/requirements-base.txt") (Path(__file__).parents[1] / "environments-and-requirements/requirements-base.txt")
.expanduser() .expanduser()
.resolve(), .resolve(),
], ]
stdout=subprocess.PIPE, & FG
) )
for c in iter(lambda: proc.stdout.read(1).decode(), ""):
sys.stdout.write(c)
proc = subprocess.Popen( (pip["install", "--require-virtualenv", Path(__file__).parents[1].expanduser().resolve()] & FG)
[self.pip, "install", "--require-virtualenv", Path(__file__).parents[1].expanduser().resolve()],
stdout=subprocess.PIPE,
)
for c in iter(lambda: proc.stdout.read(1).decode(), ""):
sys.stdout.write(c)
def configure(self): def configure(self):
""" """
Configure the InvokeAI runtime directory Configure the InvokeAI runtime directory
""" """
from ldm.invoke.configuration import configure
configure.main()
def update(self): def update(self):
pass pass