from pathlib import Path from app.modules.results.service import parse_training_curve def test_parse_yolo_results_curve(tmp_path: Path): csv_path = tmp_path / "results.csv" csv_path.write_text( "\n".join( [ "epoch,time,train/box_loss,train/seg_loss,metrics/mAP50(M),val/seg_loss,lr/pg0", "1,1.0,1.5,3.0,0.12,2.8,0.001", "2,2.0,1.2,2.5,0.18,2.1,0.001", "3,3.0,0.9,2.0,0.25,1.9,0.001", ] ), encoding="utf-8", ) curve = parse_training_curve(csv_path) assert curve is not None assert curve["x_key"] == "epoch" names = [item["name"] for item in curve["series"]] assert "train/seg_loss" in names assert "metrics/mAP50(M)" in names assert all("lr/" not in name for name in names)