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
+6
View File
@@ -14,6 +14,10 @@ from joblib.externals.loky import get_reusable_executor
from persistance import gold, registry
class EmptyCohort(ValueError):
"""The site has nobody in a model's cohort (no colposcopies, say): nothing to learn from."""
class Predictor(mlflow.pyfunc.PythonModel):
"""A fitted model as MLflow serves it: patient timelines in (gold `<domain>_events` rows
with each patient's index date), one row per patient and horizon out."""
@@ -51,6 +55,8 @@ class Jobs:
fitted, metrics, found = spec.train(None, as_of)
else:
events = gold.timelines(self.events, spec.cohort, as_of)
if events.empty:
raise EmptyCohort(f"{self.registered(name)}: nobody in {spec.cohort}")
fitted, metrics, data = spec.train(events, as_of)
found = {
"technical_validation": self.technical_validation(spec, metrics, data),