fix(prithvi): drop .view() on lists; enrich warmup traceback
Browse filesDiag output from the previous deploy:
warm/prithvi: AttributeError: 'list' object has no attribute 'view'
The yaml-instantiated GenericNonGeoSegmentationDataModule stores
`means` and `stds` as Python lists (verified against the v2
config). The previous patch chained `_old.means.view(-1)
.detach().clone()` BEFORE handing them to _DictNormalize, which
crashed on the .view() call before reaching the conversion logic
inside the class.
Fix: pass `_old.means` and `_old.stds` to _DictNormalize raw.
The class's `_torch.as_tensor(mean).view(-1, 1, 1).float()` handles
list-to-tensor conversion internally — same end state, no
precondition that assumes the inputs are already tensors.
Also: lifespan warmup now stores a 5-line traceback tail in
_LAST_ERR so the next regression surfaces with a real stack
location through /healthz and /v1/diag.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files changed (2)
232 unmodified lines233234235236237238239240241242232 unmodified linesstd = self.std.to(sample.device)return (sample - mean) / stdm.datamodule.aug = _DictNormalize(_old.means.view(-1).detach().clone(),_old.stds.view(-1).detach().clone(),)log.info("prithvi_live: patched v2 datamodule transforms ""for IBM inference.py compat (dict-aware Normalize)")else:232 unmodified lines233234235236237238239240241242243244245246232 unmodified linesstd = self.std.to(sample.device)return (sample - mean) / std# `_old.means` / `_old.stds` come from the# yaml as Python lists — calling `.view()` on# them is what tripped the original# `'list' object has no attribute 'view'`.# _DictNormalize handles the conversion via# torch.as_tensor internally; just pass the# raw values whatever their type.m.datamodule.aug = _DictNormalize(_old.means, _old.stds)log.info("prithvi_live: patched v2 datamodule transforms ""for IBM inference.py compat (dict-aware Normalize)")else:
172 unmodified lines173174175176177178179180181182620 unmodified lines803804805806807808809810811812172 unmodified linesstd = self.std.to(sample.device)return (sample - mean) / stdm.datamodule.aug = _DictNormalize(_old.means.view(-1).detach().clone(),_old.stds.view(-1).detach().clone(),)log.info("prithvi: patched v2 datamodule transforms ""for IBM inference.py compat (dict-aware Normalize)")else:620 unmodified linesfn()log.info("startup %s ok", stage)except Exception as e: # noqa: BLE001log.exception("startup %s failed: %s", stage, e)_LAST_ERR[stage] = {"ok": False,"err": f"{type(e).__name__}: {e}","stage": stage}yieldlog.info("riprap-models stopping")172 unmodified lines173174175176177178179180181182183184185620 unmodified lines806807808809810811812813814815816817818819820172 unmodified linesstd = self.std.to(sample.device)return (sample - mean) / std# `_old.means` / `_old.stds` come from the yaml as# Python lists — calling `.view()` on them is what# tripped the original `'list' object has no attribute# 'view'`. _DictNormalize handles the conversion via# torch.as_tensor internally; just pass the raw values# whatever their type.m.datamodule.aug = _DictNormalize(_old.means, _old.stds)log.info("prithvi: patched v2 datamodule transforms ""for IBM inference.py compat (dict-aware Normalize)")else:620 unmodified linesfn()log.info("startup %s ok", stage)except Exception as e: # noqa: BLE001import tracebacktb = traceback.format_exc()log.exception("startup %s failed: %s", stage, e)_LAST_ERR[stage] = {"ok": False,"err": f"{type(e).__name__}: {e}","stage": stage,"traceback_tail": tb.splitlines()[-5:],}yieldlog.info("riprap-models stopping")