diff options
| author | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
| commit | 6cfcd564c0684c52618235e6366f4a81c02b9a5b (patch) | |
| tree | 55321760a8103bc6b5d79489fac4135a60e6e3ba /app/backends/qwen.py | |
| parent | dc6e7cd43029da62dabe2513fb5aa8a34df1bd6d (diff) | |
| download | tts-audiobook-generator-6cfcd564c0684c52618235e6366f4a81c02b9a5b.tar.gz | |
slop refactor/dedup
Diffstat (limited to 'app/backends/qwen.py')
| -rw-r--r-- | app/backends/qwen.py | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/app/backends/qwen.py b/app/backends/qwen.py index a94b3cc..c099c84 100644 --- a/app/backends/qwen.py +++ b/app/backends/qwen.py @@ -160,7 +160,10 @@ def delete_model_weights(models: Optional[List[str]] = None) -> int: if not directory.is_dir(): continue print(f"[INFO] Removing cached {MODEL_REPOS[name]} weights...") - shutil.rmtree(directory, ignore_errors=True) + shutil.rmtree(directory) + if directory.exists(): + print(f"[WARNING] Could not fully remove {directory}") + continue removed += 1 if removed: print(f"[OK] Deleted cached weights for {removed} " @@ -174,19 +177,6 @@ def _is_installed() -> bool: return envs.module_available("qwen_tts", QWEN_ENV) -def _config_port(url: str, fallback: int) -> int: - import urllib.parse - try: - return urllib.parse.urlsplit(url).port or fallback - except ValueError: - return fallback - - -def current_model() -> str: - """The model a fresh managed start hosts (DEFAULT_MODEL).""" - return DEFAULT_MODEL - - def model_for_identity(identity: Optional[str]) -> Optional[str]: """The model name a qwen demo answers as (None when not a known identity).""" return IDENTITY_TO_MODEL.get(identity) @@ -308,7 +298,7 @@ def build_spec(model: str) -> ServerSpec: "qwen", url, [str(envs.env_script("qwen-tts-demo", QWEN_ENV)), MODEL_REPOS[model], "--ip", "127.0.0.1", - "--port", str(_config_port(url, DEFAULT_PORT))], + "--port", str(common.port_of(url, DEFAULT_PORT))], identity=desired_identity(model)) @@ -336,12 +326,12 @@ def detect() -> BackendStatus: differs from the default one. """ installed = _is_installed() - model = current_model() + model = DEFAULT_MODEL url = config.QWEN_API_URL details: List[str] = [] details.append("pip: installed" if installed else "not installed — run setup to pip install qwen-tts") - details.append(f"port: {_config_port(url, DEFAULT_PORT)}") + details.append(f"port: {common.port_of(url, DEFAULT_PORT)}") details.append(f"default model: {model}") specs = [build_spec(model)] managed = servers.manages(specs) |
