Commit
·
f94c8f9
1
Parent(s):
0d8e3dc
updated /model/config
Browse files
app.py
CHANGED
|
@@ -968,18 +968,64 @@ def model_assets_status():
|
|
| 968 |
|
| 969 |
@app.get("/model/config")
|
| 970 |
def model_config():
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 976 |
return {
|
| 977 |
-
"size":
|
| 978 |
-
"repo":
|
| 979 |
-
"revision":
|
| 980 |
-
"selected_step":
|
| 981 |
-
"
|
| 982 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 983 |
}
|
| 984 |
|
| 985 |
@app.get("/model/checkpoints")
|
|
|
|
| 968 |
|
| 969 |
@app.get("/model/config")
|
| 970 |
def model_config():
|
| 971 |
+
"""
|
| 972 |
+
Lightweight config snapshot:
|
| 973 |
+
- never calls get_mrt() (no model build / no downloads)
|
| 974 |
+
- never calls snapshot_download()
|
| 975 |
+
- reports whether a model instance is currently loaded in memory
|
| 976 |
+
- best-effort local checkpoint presence (no network)
|
| 977 |
+
"""
|
| 978 |
+
# Read-only snapshot of in-memory model presence
|
| 979 |
+
with _MRT_LOCK:
|
| 980 |
+
loaded = (_MRT is not None)
|
| 981 |
+
|
| 982 |
+
size = os.getenv("MRT_SIZE", "large")
|
| 983 |
+
repo = os.getenv("MRT_CKPT_REPO")
|
| 984 |
+
rev = os.getenv("MRT_CKPT_REV", "main")
|
| 985 |
+
step = os.getenv("MRT_CKPT_STEP")
|
| 986 |
+
assets = os.getenv("MRT_ASSETS_REPO")
|
| 987 |
+
|
| 988 |
+
# Best-effort local cache probe (no network)
|
| 989 |
+
def _local_ckpt_dir(step_str: str | None) -> str | None:
|
| 990 |
+
if not step_str:
|
| 991 |
+
return None
|
| 992 |
+
try:
|
| 993 |
+
from pathlib import Path
|
| 994 |
+
import re
|
| 995 |
+
step = re.escape(str(step_str))
|
| 996 |
+
candidates: list[str] = []
|
| 997 |
+
for root in ("/home/appuser/.cache/mrt_ckpt/extracted",
|
| 998 |
+
"/home/appuser/.cache/mrt_ckpt/repo"):
|
| 999 |
+
p = Path(root)
|
| 1000 |
+
if not p.exists():
|
| 1001 |
+
continue
|
| 1002 |
+
# Look for exact "checkpoint_<step>" directories anywhere under these roots
|
| 1003 |
+
for d in p.rglob(f"checkpoint_{step}"):
|
| 1004 |
+
if d.is_dir():
|
| 1005 |
+
candidates.append(str(d))
|
| 1006 |
+
return candidates[0] if candidates else None
|
| 1007 |
+
except Exception:
|
| 1008 |
+
return None
|
| 1009 |
+
|
| 1010 |
+
local_ckpt = _local_ckpt_dir(step)
|
| 1011 |
+
|
| 1012 |
return {
|
| 1013 |
+
"size": size,
|
| 1014 |
+
"repo": repo,
|
| 1015 |
+
"revision": rev,
|
| 1016 |
+
"selected_step": step,
|
| 1017 |
+
"assets_repo": assets,
|
| 1018 |
+
|
| 1019 |
+
# in-memory + local cache hints (no network, no model build)
|
| 1020 |
+
"loaded": loaded,
|
| 1021 |
+
"active_jam": _any_jam_running(),
|
| 1022 |
+
"local_checkpoint_dir": local_ckpt, # None if not found locally
|
| 1023 |
+
|
| 1024 |
+
# steering assets currently resident in memory
|
| 1025 |
+
"mean_loaded": (_MEAN_EMBED is not None),
|
| 1026 |
+
"centroids_loaded": (_CENTROIDS is not None),
|
| 1027 |
+
"centroid_count": (None if _CENTROIDS is None else int(_CENTROIDS.shape[0])),
|
| 1028 |
+
"warmup_done": bool(_WARMED),
|
| 1029 |
}
|
| 1030 |
|
| 1031 |
@app.get("/model/checkpoints")
|