TEA EEG baselines keep their artifacts under MLFLOW_ARTIFACT_ROOT, not in the working directory

This commit is contained in:
AlbertoPMDM
2026-11-19 23:17:42 -06:00
parent 3669aa9eae
commit 7b8a4e8499
2 changed files with 26 additions and 1 deletions
+23
View File
@@ -78,6 +78,29 @@ def test_each_scenario_is_registered_with_what_promotion_checks(mlflow_tracking,
registry.promote("tea", "eeg-posterior-rhythm", version)
def test_each_baseline_keeps_its_artifacts_under_the_artifact_root(mlflow_tracking, reference, tmp_path, monkeypatch):
"""Pins down: with `MLFLOW_ARTIFACT_ROOT` set, every scenario's run writes its model and routine records under
that root, not in `./mlruns` of the working directory.
Fails if training lets `tea.serving.log_biomarker` create the experiment at MLflow's default location: in a
container the working directory isn't the data volume, and the registered baselines would point at files that
disappear with it.
"""
from mlflow import MlflowClient
root = tmp_path / "artefactos"
monkeypatch.setenv("MLFLOW_ARTIFACT_ROOT", str(root))
found, studies = reference
trained = train.train_all(settings(), "PROD", found=found, studies=studies)
client = MlflowClient()
for scenario, (version, _) in trained.items():
run = client.get_run(client.get_model_version(f"tea-{scenario}", version).run_id)
assert run.info.artifact_uri.startswith(str(root)), scenario
assert any((root / f"tea-{scenario}").rglob("*.json")), scenario
assert not (tmp_path / "mlruns").exists()
def test_a_promoted_baseline_scores_the_analysis(mlflow_tracking, reference):
"""Pins down: once its reports are attached, a baseline is promoted, and the analysis's `Baselines` loads it
from the registry and gives a value at an age its curve covers a z, -1/0/+1 and the curve's centiles.