Spaces:
Running on Zero
Running on Zero
fix(models): keep the failure summary inside the space log tail
Browse filesThe Space API keeps only the last 2000 characters of output, and the
bootstrap summary is meant to be those characters. With an hf_xet error
followed by a failed xet-off retry on every root, each root's reason
carried two 300-character errors and the summary grew past 2000
characters, cutting off the line that names the repo and commit. Each
root's reason is now capped at 400 characters in the summary; the full
per-attempt errors are still logged as they happen.
- model_store.py +9 -3
- tests/test_model_store.py +16 -0
model_store.py
CHANGED
|
@@ -115,11 +115,15 @@ def _gb(n_bytes: float) -> str:
|
|
| 115 |
return f"{n_bytes / 1e9:.2f}"
|
| 116 |
|
| 117 |
|
| 118 |
-
def
|
| 119 |
-
text = " ".join(
|
| 120 |
return text if len(text) <= limit else text[: limit - 3] + "..."
|
| 121 |
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
def _label(entry: dict) -> str:
|
| 124 |
return f"{entry['repo_id']}@{entry['revision'][:12]}"
|
| 125 |
|
|
@@ -392,7 +396,9 @@ def ensure_repo(
|
|
| 392 |
f"could not get {entry['repo_id']}@{entry['revision']} "
|
| 393 |
f"({len(entry['files'])} files, {_gb(total)} GB) into any cache root:"
|
| 394 |
]
|
| 395 |
-
|
|
|
|
|
|
|
| 396 |
if not failures:
|
| 397 |
lines.append(" (no cache roots given)")
|
| 398 |
raise ModelStoreError("\n".join(lines))
|
|
|
|
| 115 |
return f"{n_bytes / 1e9:.2f}"
|
| 116 |
|
| 117 |
|
| 118 |
+
def _shorten(text: str, limit: int) -> str:
|
| 119 |
+
text = " ".join(text.split())
|
| 120 |
return text if len(text) <= limit else text[: limit - 3] + "..."
|
| 121 |
|
| 122 |
|
| 123 |
+
def _describe(exc: BaseException, limit: int = 300) -> str:
|
| 124 |
+
return _shorten(f"{type(exc).__name__}: {exc}", limit)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
def _label(entry: dict) -> str:
|
| 128 |
return f"{entry['repo_id']}@{entry['revision'][:12]}"
|
| 129 |
|
|
|
|
| 396 |
f"could not get {entry['repo_id']}@{entry['revision']} "
|
| 397 |
f"({len(entry['files'])} files, {_gb(total)} GB) into any cache root:"
|
| 398 |
]
|
| 399 |
+
# Short enough that the whole summary survives in the 2000-character log
|
| 400 |
+
# tail the Space API keeps.
|
| 401 |
+
lines += [f" {root}: {_shorten(reason, 400)}" for root, reason in failures]
|
| 402 |
if not failures:
|
| 403 |
lines.append(" (no cache roots given)")
|
| 404 |
raise ModelStoreError("\n".join(lines))
|
tests/test_model_store.py
CHANGED
|
@@ -569,6 +569,22 @@ def test_ensure_raises_one_summary_when_every_root_fails(roots, fake_time):
|
|
| 569 |
assert len(dl.calls) == 3
|
| 570 |
|
| 571 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
# --- R9.4: the 2026-09-22 state -------------------------------------------------
|
| 573 |
|
| 574 |
|
|
|
|
| 569 |
assert len(dl.calls) == 3
|
| 570 |
|
| 571 |
|
| 572 |
+
def test_ensure_summary_fits_the_space_log_tail_even_with_long_errors(roots, ensure_kw):
|
| 573 |
+
entry = make_entry(FILES, repo_id="ACE-Step/Some-Repo")
|
| 574 |
+
huge = OSError("I/O error: " + "x" * 5000 + " (os error 13)")
|
| 575 |
+
dl = FakeDownloader([entry], {"ACE-Step/Some-Repo": [huge] * 10})
|
| 576 |
+
|
| 577 |
+
with pytest.raises(ms.ModelStoreError) as exc:
|
| 578 |
+
ms.ensure_repo(entry, roots, downloader=dl, **ensure_kw)
|
| 579 |
+
|
| 580 |
+
msg = str(exc.value)
|
| 581 |
+
# app.py prefixes one short line; the Space API keeps the last 2000 characters.
|
| 582 |
+
assert len(msg) < 1900, len(msg)
|
| 583 |
+
assert msg.startswith(f"could not get ACE-Step/Some-Repo@{REV}")
|
| 584 |
+
for root in roots:
|
| 585 |
+
assert str(root) in msg
|
| 586 |
+
|
| 587 |
+
|
| 588 |
# --- R9.4: the 2026-09-22 state -------------------------------------------------
|
| 589 |
|
| 590 |
|