-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
52 lines (45 loc) · 2.83 KB
/
Copy pathapp.py
File metadata and controls
52 lines (45 loc) · 2.83 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
49
50
51
52
from __future__ import annotations
import argparse
import json
from pathlib import Path
from src.server import run
from src.runtime_doctor import RuntimeDoctor
def main() -> int:
parser = argparse.ArgumentParser(description="Run SithAssembly//Instawatch locally")
parser.add_argument("--host", default="127.0.0.1", help="bind address; defaults to local-only")
parser.add_argument("--port", type=int, default=8080, help="local port")
parser.add_argument("--allow-network", action="store_true", help="allow a non-loopback bind; requires SITH_API_TOKEN and an explicit Host allowlist")
parser.add_argument("--allowed-hosts", help="comma-separated Host header allowlist; required for network binding unless SITH_ALLOWED_HOSTS is set")
parser.add_argument("--max-workers", type=int, default=16, help="maximum concurrent HTTP requests from 1 to 64")
parser.add_argument("--dev", action="store_true", help="write detailed local runtime logs")
parser.add_argument("--compute-mode", choices=("cpu", "auto", "cuda"), default="auto", help="declare the intended local model compute mode; never installs packages")
parser.add_argument("--check-config", action="store_true", help="validate local registries and exit without starting the server")
parser.add_argument("--print-capabilities", action="store_true", help="print local AI acceleration and configuration diagnostics, then exit")
parser.add_argument("--deployment-preflight", action="store_true", help="validate prepared deployment files and exit without starting services")
options = parser.parse_args()
doctor = RuntimeDoctor(Path(__file__).resolve().parent)
if options.deployment_preflight:
from src.deployment_preflight import DeploymentPreflight
report = DeploymentPreflight(Path(__file__).resolve().parent).snapshot()
print(json.dumps(report, ensure_ascii=False, indent=2))
return 0 if report["readiness"] == "prepared" else 1
if options.check_config or options.print_capabilities:
report = doctor.snapshot(options.compute_mode)
if options.check_config and not options.print_capabilities:
report = report["configuration"]
print(json.dumps(report, ensure_ascii=False, indent=2))
return 0 if report.get("state", "ok") == "ok" else 1
if options.compute_mode == "cuda" and not doctor.snapshot("cuda")["acceleration"]["cuda_available"]:
parser.error("--compute-mode cuda requires an available local CUDA runtime; use --print-capabilities to inspect it")
run(
host=options.host,
port=options.port,
dev_mode=options.dev,
compute_mode=options.compute_mode,
allow_network=options.allow_network,
max_workers=options.max_workers,
allowed_hosts=options.allowed_hosts,
)
return 0
if __name__ == "__main__":
raise SystemExit(main())