Spaces:
Running
Running
Download run_lpu.py from iparaco/Virtual-LPU: direct link, hf CLI and curl.
- Browser
- Download file 3.7 kB
-
https://huggingface.co/spaces/iparaco/Virtual-LPU/resolve/main/run_lpu.py
- Command line
-
hf download hf://spaces/iparaco/Virtual-LPU/run_lpu.py
-
curl -L -o run_lpu.py https://huggingface.co/spaces/iparaco/Virtual-LPU/resolve/main/run_lpu.py
3.7 kB
| """LPU AI Accelerator V7 — single entry point. | |
| python run_lpu.py start server + open dashboard (browser) | |
| python run_lpu.py --desktop NATIVE WINDOW app (no browser; WebView2) | |
| - installs: pip install pywebview | |
| - falls back to browser mode honestly | |
| - if an accelerator is already running, | |
| opens a window attached to it | |
| python run_lpu.py --no-browser start without opening a browser | |
| python run_lpu.py --port 9000 custom port (loopback only) | |
| python run_lpu.py --host 0.0.0.0 EXPOSED bind: requires token auth | |
| (token file: <LPU_HOME>/server_token) | |
| python run_lpu.py --check environment self-check, no server | |
| On Windows prefer the .cmd launchers (LPU_Desktop.cmd / LPU_Server.cmd / | |
| LPU_Check.cmd): they call python.exe EXPLICITLY, so a machine whose .py | |
| association points at an Electron-based editor cannot silently swallow the | |
| invocation (the cause of the 2026-11-15 "Electron/Chromium warning" report). | |
| The server is fully independent of VS Code and of any training process. | |
| Starting/stopping it NEVER starts/stops training (mission §21 rules 4-6). | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| from pathlib import Path | |
| def _app_root() -> Path: | |
| """Project root that also works inside a PyInstaller --onefile build | |
| (data files land under sys._MEIPASS there).""" | |
| meipass = getattr(sys, "_MEIPASS", None) | |
| if meipass: | |
| cand = Path(meipass) | |
| if (cand / "lpu" / "version.py").exists(): | |
| return cand | |
| if (cand.parent / "lpu" / "version.py").exists(): | |
| return cand.parent | |
| return Path(__file__).resolve().parent | |
| ROOT = _app_root() | |
| sys.path.insert(0, str(ROOT)) | |
| def _load_config(path: str | None) -> dict: | |
| if path is None: | |
| default = ROOT / "configs" / "lpu_config_v7.yaml" | |
| if default.exists(): | |
| path = str(default) | |
| if path is None: | |
| return {} | |
| import yaml | |
| return yaml.safe_load(Path(path).read_text(encoding="utf-8")) or {} | |
| def _self_check() -> int: | |
| from lpu.cli.self_check import run_self_check | |
| return run_self_check() | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = argparse.ArgumentParser( | |
| prog="run_lpu.py", | |
| description="LPU AI Accelerator V7 — server + dashboard launcher") | |
| parser.add_argument("--host", default="127.0.0.1") | |
| parser.add_argument("--port", type=int, default=8710) | |
| parser.add_argument("--config", default=None) | |
| parser.add_argument("--no-browser", action="store_true") | |
| parser.add_argument("--desktop", action="store_true", | |
| help="run as a native window app (no browser)") | |
| parser.add_argument("--check", action="store_true") | |
| args = parser.parse_args(argv) | |
| if args.check: | |
| return _self_check() | |
| if args.desktop: | |
| from desktop_app import main as desktop_main | |
| argv = ["--host", args.host, "--port", str(args.port)] | |
| config_path = args.config | |
| if config_path is None: | |
| default_config = ROOT / "configs" / "lpu_config_v7.yaml" | |
| if default_config.exists(): | |
| config_path = str(default_config) | |
| if config_path: | |
| argv += ["--config", config_path] | |
| return desktop_main(argv) | |
| cfg = _load_config(args.config) | |
| from server.app import create_app | |
| app = create_app(cfg) | |
| import uvicorn | |
| uvicorn.run(app, host=args.host, port=args.port) | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |