aboutsummaryrefslogtreecommitdiff
path: root/app/backends/faster.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/backends/faster.py')
-rwxr-xr-xapp/backends/faster.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/backends/faster.py b/app/backends/faster.py
index 3631153..e52a023 100755
--- a/app/backends/faster.py
+++ b/app/backends/faster.py
@@ -511,6 +511,44 @@ def _detect_remote(managed: bool = False):
return False, {}
+def update(*, emit=None, cancel=None) -> int:
+ """Update the faster-qwen3-tts backend: pip upgrade + checkout refresh.
+
+ A managed server that is running is stopped first (best-effort): the
+ server runs ``examples/openai_server.py`` from the checkout being
+ reset and imports the package being upgraded. Phases: stop server /
+ pip install -U / git update — CANCEL is honored between phases only,
+ so a started phase always completes. The pip package (into
+ FASTER_ENV) and the cloned checkout are refreshed independently: the
+ checkout only holds ``examples/openai_server.py`` (and the untracked
+ voices.json, which a hard reset leaves alone), so a failed phase is
+ warned about and reflected in the exit code without undoing the
+ other. Returns the exit code (130 when cancelled before a remaining
+ phase).
+ """
+ if servers.pid_for("faster") is not None:
+ servers.stop("faster")
+ if common.cancel_requested(cancel):
+ return 130
+ rc = common.pip_install([FASTER_PIP_PKG], emit=emit, cancel=cancel,
+ env_dir=FASTER_ENV, upgrade=True)
+ if rc != 0:
+ print(f"[WARNING] pip install -U failed (exit {rc}); update "
+ f"{FASTER_PIP_PKG} manually")
+ else:
+ print(f"[OK] {FASTER_PIP_PKG} is up to date (or just upgraded).")
+ if common.cancel_requested(cancel):
+ return 130
+ if _is_cloned():
+ clone_rc = common.git_update(_checkout(), emit=emit, cancel=cancel)
+ if clone_rc != 0:
+ print(f"[WARNING] checkout update failed (exit {clone_rc}); "
+ f"run 'git -C {_checkout()} pull' manually")
+ return clone_rc
+ print(f"[OK] {_checkout()} is at origin's HEAD.")
+ return rc
+
+
def uninstall(*, emit=None, cancel=None) -> int:
"""Remove the faster-qwen3-tts backend entirely.