-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_pro.py
More file actions
48 lines (37 loc) · 1.59 KB
/
Copy pathlaunch_pro.py
File metadata and controls
48 lines (37 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations
import os
import subprocess
import sys
import launch
from aiwf.runtime.bootstrap_env import apply_from_argv
def main() -> None:
"""Prepare the shared AIWF environment, then launch the Pro React app."""
argv = sys.argv[1:]
show_terminal = "--terminal" in argv
argv = [arg for arg in argv if arg != "--terminal"]
sys.path.insert(0, str(launch.ROOT))
apply_from_argv(argv)
os.environ.setdefault("XFORMERS_FORCE_DISABLE_TRITON", "1")
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
skip_prepare = "--skip-prepare-environment" in argv
skip_install = "--skip-install" in argv
launch.prepare(skip_prepare, skip_install, argv)
pro_argv = launch.strip_launch_only_args(argv)
env = os.environ.copy()
env.setdefault("XFORMERS_FORCE_DISABLE_TRITON", "1")
env.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
env["PYTHONPATH"] = (
str(launch.ROOT)
if "PYTHONPATH" not in env
else str(launch.ROOT) + os.pathsep + env["PYTHONPATH"]
)
command = [launch.python(), str(launch.ROOT / "webui_pro.py"), *pro_argv]
if os.name == "nt":
creationflags = subprocess.CREATE_NEW_CONSOLE if show_terminal else subprocess.CREATE_NO_WINDOW
if show_terminal:
print("[AIWF Pro] Opening backend terminal. Close the Pro app window to stop the backend.")
proc = subprocess.Popen(command, cwd=str(launch.ROOT), env=env, creationflags=creationflags)
raise SystemExit(proc.wait())
os.execvpe(launch.python(), command, env)
if __name__ == "__main__":
main()