TEA EEG baselines keep their artifacts under MLFLOW_ARTIFACT_ROOT, not in the working directory
This commit is contained in:
@@ -29,7 +29,7 @@ from models.io.lineage import (
|
|||||||
registered_name,
|
registered_name,
|
||||||
)
|
)
|
||||||
from models.io.registry import REFERENCE_SOURCE
|
from models.io.registry import REFERENCE_SOURCE
|
||||||
from models.io.tracking import routine_path
|
from models.io.tracking import experiment_id, routine_path
|
||||||
from models.tea.eeg.analyze import ReferenceStudy, pipeline, plan, reference
|
from models.tea.eeg.analyze import ReferenceStudy, pipeline, plan, reference
|
||||||
from models.tea.eeg.settings import Settings
|
from models.tea.eeg.settings import Settings
|
||||||
|
|
||||||
@@ -144,6 +144,8 @@ def train_scenario(scenario: str, studies: list[ReferenceStudy], found: Listing,
|
|||||||
module.train(data)
|
module.train(data)
|
||||||
sha, state = _module_state(module)
|
sha, state = _module_state(module)
|
||||||
name = registered_name(DOMAIN, scenario)
|
name = registered_name(DOMAIN, scenario)
|
||||||
|
# Created here first so it lives under MLFLOW_ARTIFACT_ROOT; `log_biomarker` alone would put it in ./mlruns.
|
||||||
|
experiment_id(MlflowClient(), name)
|
||||||
mv = log_biomarker(module, plan=plan(s), registered_name=name, run_name=scenario, n_reference=len(data),
|
mv = log_biomarker(module, plan=plan(s), registered_name=name, run_name=scenario, n_reference=len(data),
|
||||||
experiment=name)
|
experiment=name)
|
||||||
client, run_id, version = MlflowClient(), mv.run_id, str(mv.version)
|
client, run_id, version = MlflowClient(), mv.run_id, str(mv.version)
|
||||||
|
|||||||
@@ -78,6 +78,29 @@ def test_each_scenario_is_registered_with_what_promotion_checks(mlflow_tracking,
|
|||||||
registry.promote("tea", "eeg-posterior-rhythm", version)
|
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):
|
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
|
"""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.
|
from the registry and gives a value at an age its curve covers a z, -1/0/+1 and the curve's centiles.
|
||||||
|
|||||||
Reference in New Issue
Block a user