diff options
Diffstat (limited to 'lib/src/producer/doctor.py')
| -rw-r--r-- | lib/src/producer/doctor.py | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/lib/src/producer/doctor.py b/lib/src/producer/doctor.py deleted file mode 100644 index 2d8997f..0000000 --- a/lib/src/producer/doctor.py +++ /dev/null @@ -1,95 +0,0 @@ -from __future__ import annotations - -import importlib.util -import shutil -import sys -from pathlib import Path - -from . import __version__ - -DATA_DIR = Path(__file__).resolve().parents[2] - - -def _check(name: str, ok: bool, detail: str = "") -> bool: - mark = "ok " if ok else "MISS" - line = f" [{mark}] {name}" - if detail: - line += f": {detail}" - print(line) - return ok - - -def _import(name: str): - try: - return importlib.import_module(name) - except Exception: - return None - - -def _chain_error(name: str) -> str: - """Import failure text for a module whose deeper import chain doesn't load.""" - try: - importlib.import_module(name) - except Exception as e: - return str(e) or type(e).__name__ - return "" - - -def main(_argv: list[str] | None = None) -> int: - print(f"producer {__version__} doctor") - print(f" data dir: {DATA_DIR}") - critical_ok = True - - v = sys.version_info - critical_ok &= _check("python", v >= (3, 10), f"{v.major}.{v.minor}.{v.micro}") - - for mod in ("numpy", "scipy", "soundfile", "pyloudnorm"): - m = _import(mod) - ok = m is not None - critical_ok &= ok - _check(mod, ok, getattr(m, "__version__", "") if ok else "not installed") - - torch = _import("torch") - if torch is None: - _check("torch", False, "not installed (installs on first denoise/enhance run)") - else: - ver = getattr(torch, "__version__", "?") - cuda = bool(torch.cuda.is_available()) - dev = torch.cuda.get_device_name(0) if cuda else "" - _check("torch", True, f"{ver}, cuda={cuda}" + (f" ({dev})" if dev else "")) - - ffmpeg = shutil.which("ffmpeg") - _check("ffmpeg", ffmpeg is not None, ffmpeg or "missing (needed for mp3 + odd formats)") - - for mod in ("deepfilternet", "zipenhancer", "clearvoice"): - m = _import(mod) or _import(mod.replace("-", "_")) - if m is None: - _check(mod, False, "lazy (installed on first use)") - continue - detail = "installed" - if mod == "zipenhancer": - # zipenhancer loads modelscope lazily on first use; probe the - # config module whose extras-only deps have broken it in the wild - broken = _chain_error("modelscope.utils.config") - if broken and "modelscope" not in broken: - detail += f"; modelscope chain broken: {broken} (will install on first use)" - _check(mod, True, detail) - - dfn3 = DATA_DIR / "models" / "DeepFilterNet3" / "config.ini" - _check("dfn3 weights", dfn3.is_file(), str(dfn3)) - - res_venv = DATA_DIR / "venvs" / "resemble" / "bin" / "python" - _check("resemble venv", res_venv.is_file(), str(res_venv)) - - uv = DATA_DIR / "bin" / "uv" - _check("uv", uv.is_file() or shutil.which("uv") is not None, str(uv)) - - cfg = DATA_DIR.parent / "config.toml" - _check("config.toml", cfg.exists(), str(cfg)) - - print("doctor:", "core OK" if critical_ok else "core problems detected") - return 0 if critical_ok else 1 - - -if __name__ == "__main__": - sys.exit(main()) |
