drop cohort builder plumbing; use kit cohorte_armado builds for MLflow lineage
This commit is contained in:
@@ -3,7 +3,6 @@ import json
|
||||
import pytest
|
||||
|
||||
from models.base import ScreeningModel
|
||||
from models.cohort import CohortBuilder, ExclusionCriterion
|
||||
from models.prediction import ApplicabilityRejected, Interpretability, PredictionService
|
||||
from models.registry import registry
|
||||
|
||||
@@ -18,11 +17,8 @@ class StubModel(ScreeningModel):
|
||||
return {"label": "positivo", "confianza": 0.73}
|
||||
|
||||
|
||||
class AlwaysRejectCohortBuilder(CohortBuilder):
|
||||
domain = "cacu"
|
||||
scenario = "tamizaje"
|
||||
criteria_version = "v1"
|
||||
criteria = [ExclusionCriterion(code="X", reason_code="siempre", predicate=lambda e: True, applicable_in_production=True)]
|
||||
def never_applicable(row: dict) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _promote_a_version(production_ready):
|
||||
@@ -56,7 +52,7 @@ def test_predict_without_active_version_raises(governance_db, mlflow_tracking):
|
||||
def test_applicability_gate_flags_but_does_not_block_by_default(production_ready):
|
||||
_promote_a_version(production_ready)
|
||||
service = PredictionService(
|
||||
StubModel(), domain="cacu", scenario="tamizaje", cohort_builder=AlwaysRejectCohortBuilder()
|
||||
StubModel(), domain="cacu", scenario="tamizaje", aplicable=never_applicable
|
||||
)
|
||||
|
||||
prediction = service.predict_and_record({"edad": 40}, pac_id_hospital="H-1")
|
||||
@@ -69,9 +65,16 @@ def test_applicability_gate_can_reject_outright(production_ready):
|
||||
StubModel(),
|
||||
domain="cacu",
|
||||
scenario="tamizaje",
|
||||
cohort_builder=AlwaysRejectCohortBuilder(),
|
||||
aplicable=never_applicable,
|
||||
reject_inapplicable=True,
|
||||
)
|
||||
|
||||
with pytest.raises(ApplicabilityRejected):
|
||||
service.predict_and_record({"edad": 40}, pac_id_hospital="H-1")
|
||||
|
||||
|
||||
def test_applicability_gate_needs_a_dict(production_ready):
|
||||
_promote_a_version(production_ready)
|
||||
service = PredictionService(StubModel(), domain="cacu", scenario="tamizaje", aplicable=never_applicable)
|
||||
with pytest.raises(TypeError):
|
||||
service.predict_and_record([40], pac_id_hospital="H-1")
|
||||
|
||||
Reference in New Issue
Block a user