SPB Git

spb/wp41_uqo

Public
1.9 KB · 36 lines python
1"""Release gate: the whole pipeline (synthetic bars -> grids -> baselines -> MRPT -> scores -> tables) runs end to end2on license-free data. Marked slow (~3 min on an M-series laptop)."""3import json4import subprocess5import sys6from pathlib import Path78import pytest910ROOT = Path(__file__).resolve().parents[2]111213@pytest.mark.slow14def test_synthetic_pipeline(tmp_path):15    cache = tmp_path / "cache"16    r = subprocess.run([sys.executable, str(ROOT / "scripts" / "make_synthetic.py"), "--cache", str(cache), "--n", "3", "--end", "2024-04-30"],17                       capture_output=True, text=True, cwd=ROOT)18    assert r.returncode == 0, r.stderr[-2000:]19    cfg = (ROOT / "configs" / "synthetic_smoke.yaml").read_text()20    cfg = cfg.replace("cache: data/synthetic/cache", f"cache: {cache}").replace('end: "2024-05-31"', 'end: "2024-04-30"')21    cfg = cfg.replace('train_end: "2024-04-05", val_end: "2024-04-30", test_end: "2024-05-31"', 'train_end: "2024-03-15", val_end: "2024-04-05", test_end: "2024-04-30"')22    cfg = cfg.replace("max_steps: 60", "max_steps: 20").replace("name: synthetic_smoke", "name: synthetic_ci")23    cfg = cfg.replace("  - {name: mlp, kind: mlp}\n", "")24    cfg_path = tmp_path / "ci.yaml"; cfg_path.write_text(cfg)25    r = subprocess.run([sys.executable, str(ROOT / "scripts" / "run_experiment.py"), "--config", str(cfg_path), "--exp-name", "synthetic_ci"],26                       capture_output=True, text=True, cwd=ROOT)27    assert r.returncode == 0, r.stderr[-3000:]28    out = ROOT / "results" / "metrics" / "synthetic_ci"29    lb = (out / "leaderboard_test.csv").read_text()30    assert "naive_rw" in lb and "mrpt_tiny" in lb and "lightgbm" in lb31    s = json.loads((out / "summary_mrpt_tiny_test.json").read_text())32    assert all(0 < s[str(H)]["crps"] < 1 for H in (5, 15, 30, 60))33    assert 0.3 < s["60"]["cov_80"] < 1.034    import shutil35    shutil.rmtree(out, ignore_errors=True)36
Files · e976cfd0ab0ee7e59d46d9e75fd8b8fb0a861c50
Menu

Theme