A model whose cohort is empty at a site is skipped, not a failed train run

This commit is contained in:
Roberto Treviño
2026-11-27 05:07:54 -06:00
parent 02aab07a67
commit 999f0fb926
3 changed files with 24 additions and 1 deletions
+11
View File
@@ -112,3 +112,14 @@ def test_survival_matches_the_current_model_with_its_index_fixed():
for ours, theirs in [("probability", "probabilidad"), ("ci_low", "ic_bajo"),
("ci_high", "ic_alto")]: # fmt: skip
np.testing.assert_allclose(both[ours], both[theirs], rtol=RTOL, equal_nan=True)
def test_a_cohort_the_site_lacks_is_reported_not_trained(monkeypatch):
"""A site with no colposcopies has nobody in the post-colposcopy cohort: training that
model says so (and the train job goes on with the others) instead of failing inside it."""
from models import jobs
from models.cacu.jobs import JOBS
monkeypatch.setattr(jobs.gold, "timelines", lambda *a: pd.DataFrame())
with pytest.raises(jobs.EmptyCohort, match="cacu_cohort_post_colposcopy"):
JOBS.train("cin2_pim_post_colposcopy")