Live models: the labelled members are saved once per build and version, prepared by the indicators cycle and loaded by each API worker as it starts
This commit is contained in:
@@ -48,6 +48,19 @@ def _short(value: Any) -> str:
|
||||
return text if len(text) <= _SUMMARY_MAX else text[:_SUMMARY_MAX] + "…"
|
||||
|
||||
|
||||
def _warm_models(dominio: str) -> dict[str, Any]:
|
||||
"""Leaves the members of the domain's live models labelled over the new build, so the API reads them instead of the build."""
|
||||
from webapi.model_analysis import warm
|
||||
|
||||
started = time.monotonic()
|
||||
try:
|
||||
resumen = warm(dominio)
|
||||
except Exception as exc: # the indicators are already saved
|
||||
log.exception("no se pudieron preparar los modelos de %s", dominio)
|
||||
resumen = f"error: {type(exc).__name__}"
|
||||
return {"paso": "modelos", "segundos": round(time.monotonic() - started, 2), "resumen": _short(resumen)}
|
||||
|
||||
|
||||
class RecomputationQueue:
|
||||
"""Marker-file queue and status of the indicator recomputations."""
|
||||
|
||||
@@ -123,6 +136,7 @@ class RecomputationQueue:
|
||||
estado="ok",
|
||||
pasos=[{"paso": p.name, "segundos": round(p.seconds, 2), "resumen": _short(p.summary)} for p in pasos],
|
||||
)
|
||||
entrada["pasos"].append(_warm_models(dominio))
|
||||
except Exception as exc: # the worker must survive a failing domain
|
||||
log.exception("recálculo de %s falló", dominio)
|
||||
entrada.update(estado="error", error={"tipo": type(exc).__name__, "mensaje": sanitize_message(str(exc))})
|
||||
|
||||
Reference in New Issue
Block a user