drop cohort builder plumbing; use kit cohorte_armado builds for MLflow lineage
This commit is contained in:
+36
-4
@@ -2,17 +2,19 @@ import pytest
|
||||
|
||||
from core.governance.enums import ArtifactKind, Environment
|
||||
from models.registry import registry
|
||||
from mlflow import MlflowException
|
||||
|
||||
from models.training import ReadOnlyRepository, TrainingRun
|
||||
|
||||
|
||||
def test_prod_run_requires_cohort_version_id():
|
||||
with pytest.raises(ValueError, match="cohort_version_id"):
|
||||
def test_prod_run_requires_a_cohort_build():
|
||||
with pytest.raises(ValueError, match="cohorte_armado_id"):
|
||||
TrainingRun(domain="cacu", scenario="tamizaje", environment=Environment.PROD)
|
||||
|
||||
|
||||
def test_dev_run_does_not_require_cohort_version_id(mlflow_tracking):
|
||||
def test_dev_run_does_not_require_a_cohort_build(mlflow_tracking):
|
||||
run = TrainingRun(domain="cacu", scenario="tamizaje", environment=Environment.DEV)
|
||||
assert run.cohort_version_id is None
|
||||
assert run.cohorte_armado_id is None
|
||||
|
||||
|
||||
def test_finish_registers_model_version_and_artifacts(mlflow_tracking, tmp_path):
|
||||
@@ -49,3 +51,33 @@ def test_training_run_repository_is_read_only(cacu_db, mlflow_tracking):
|
||||
assert isinstance(repo, ReadOnlyRepository)
|
||||
with pytest.raises(PermissionError):
|
||||
repo.create(object())
|
||||
|
||||
|
||||
def test_experiments_keep_artifacts_under_the_configured_root(mlflow_tracking, tmp_path, monkeypatch):
|
||||
root = tmp_path / "artefactos"
|
||||
monkeypatch.setenv("MLFLOW_ARTIFACT_ROOT", str(root))
|
||||
run = TrainingRun(domain="cama", scenario="riesgo", environment=Environment.DEV)
|
||||
experiment = run.client.get_experiment_by_name("cama-riesgo")
|
||||
assert experiment.artifact_location.endswith(str(root / "cama-riesgo"))
|
||||
|
||||
|
||||
def test_finish_only_tolerates_an_existing_registered_model(mlflow_tracking, monkeypatch):
|
||||
run = TrainingRun(domain="cacu", scenario="tamizaje", environment=Environment.DEV)
|
||||
assert run.finish() == "1"
|
||||
|
||||
second = TrainingRun(domain="cacu", scenario="tamizaje", environment=Environment.DEV)
|
||||
assert second.finish() == "2"
|
||||
|
||||
third = TrainingRun(domain="cacu", scenario="tamizaje", environment=Environment.DEV)
|
||||
|
||||
def unreachable(name):
|
||||
raise MlflowException("servidor no disponible")
|
||||
|
||||
monkeypatch.setattr(third.client, "create_registered_model", unreachable)
|
||||
with pytest.raises(MlflowException, match="no disponible"):
|
||||
third.finish()
|
||||
|
||||
|
||||
def test_unknown_domain_is_rejected():
|
||||
with pytest.raises(ValueError, match="dominio desconocido"):
|
||||
TrainingRun(domain="x", scenario="tamizaje", environment=Environment.DEV)
|
||||
|
||||
Reference in New Issue
Block a user