CaMa survival figure: the whole cohort's points from the pipeline's survival stage

This commit is contained in:
Roberto Treviño Cervantes
2026-11-22 23:46:57 -06:00
parent 5738a9c302
commit 1048175531
+7 -4
View File
@@ -133,7 +133,9 @@ def refresh_subgroups(domain: str) -> list[str]:
def _subgroup_rows(domain: str, scenario: str, version: str) -> list[dict]:
"""The scenario points of the latest build computed by the cycle (`refresh_subgroups`), or the ones the version published
when it trained while the cycle hasn't computed them."""
when it trained while the cycle hasn't computed them, the whole cohort's among them as `WHOLE_COHORT`."""
from models.cama.survival.development import WHOLE_COHORT
current = _current_build(domain, scenario)
if current is not None and current[0] == str(version):
path = _subgroups_path(domain, scenario, *current)
@@ -142,7 +144,8 @@ def _subgroup_rows(domain: str, scenario: str, version: str) -> list[dict]:
return json.loads(path.read_text(encoding="utf-8"))
except (OSError, ValueError):
log.warning("no se pudo leer %s", path)
return _summary(domain, scenario, version, table="subgrupos_puntos")
return _summary(domain, scenario, version, table="subgrupos_puntos") + [
{**row, "subgrupo": WHOLE_COHORT} for row in _summary(domain, scenario, version, table="cohorte_puntos")]
def warm(domain: str) -> list[str]:
@@ -243,7 +246,7 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
name = (request.get_json(silent=True) or {}).get("escenario")
try:
spec, model, labelled, version = _live_context(domain, scenario)
spec, _, labelled, version = _live_context(domain, scenario)
except LookupError as error:
return jsonify({"error": f"sin curvas: {error}"}), 404
published = live.published_points(_subgroup_rows(domain, scenario, version), name)
@@ -252,7 +255,7 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
record = _ANSWERS.get(key)
if record is None:
try:
record = live.curves(spec, model, labelled, name, published)
record = live.curves(spec, labelled, name, published)
except live.QueryError as error:
return jsonify({"error": str(error)}), 422
with _LOCK: