fix: surface torchvision::nms as honest skip in terramind_synthesis
Browse filesWas bubbling up as a noisy 'operator torchvision::nms does not exist'
RuntimeError in the trace. Detect it explicitly and return a clean
skip explaining that local inference is unavailable due to the
torchvision binary extension not loading on this deployment.
terramind_synthesis has no remote-inference path, so this is the
honest engineering outcome.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
app/context/terramind_synthesis.py
CHANGED
|
@@ -349,6 +349,21 @@ def fetch(lat: float, lon: float, timeout_s: float = 60.0) -> dict[str, Any]:
|
|
| 349 |
"elapsed_s": round(time.time() - t0, 2),
|
| 350 |
}
|
| 351 |
except Exception as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
log.exception("terramind: fetch failed")
|
| 353 |
return {"ok": False, "err": f"{type(e).__name__}: {e}",
|
| 354 |
"elapsed_s": round(time.time() - t0, 2)}
|
|
|
|
| 349 |
"elapsed_s": round(time.time() - t0, 2),
|
| 350 |
}
|
| 351 |
except Exception as e:
|
| 352 |
+
msg = str(e)
|
| 353 |
+
# Translate the torchvision binary-extension failure into a clean
|
| 354 |
+
# skip. The HF Space ships torchvision via a transitive sentence-
|
| 355 |
+
# transformers dep, but its C extension can't load alongside our
|
| 356 |
+
# CPU torch wheel, so terratorch's NMS call raises RuntimeError.
|
| 357 |
+
# Surface this honestly — the local inference path is unavailable
|
| 358 |
+
# on this deployment, same outcome as a missing terratorch.
|
| 359 |
+
if "torchvision::nms" in msg or "torchvision_C" in msg:
|
| 360 |
+
log.warning("terramind: torchvision binary unavailable on this "
|
| 361 |
+
"deployment; skipping local inference")
|
| 362 |
+
return {"ok": False,
|
| 363 |
+
"skipped": "local inference unavailable on this "
|
| 364 |
+
"deployment (torchvision binary extension "
|
| 365 |
+
"not loadable); no remote synthesis path",
|
| 366 |
+
"elapsed_s": round(time.time() - t0, 2)}
|
| 367 |
log.exception("terramind: fetch failed")
|
| 368 |
return {"ok": False, "err": f"{type(e).__name__}: {e}",
|
| 369 |
"elapsed_s": round(time.time() - t0, 2)}
|