| @@ -1,6 +1,6 @@ | |||||
| use crate::metrics::ErrorCount; | use crate::metrics::ErrorCount; | ||||
| use anyhow::{Context, Result}; | use anyhow::{Context, Result}; | ||||
| use chrono::{DateTime, Utc}; | |||||
| use chrono::{DateTime, Local, Utc}; | |||||
| use serde::Serialize; | use serde::Serialize; | ||||
| use serde_json::Value; | use serde_json::Value; | ||||
| use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||
| @@ -234,14 +234,17 @@ fn write_report<T: Serialize>( | |||||
| started_at: DateTime<Utc>, | started_at: DateTime<Utc>, | ||||
| report: &T, | report: &T, | ||||
| ) -> Result<PathBuf> { | ) -> Result<PathBuf> { | ||||
| let reports_dir = root.join("reports"); | |||||
| let local_started_at = started_at.with_timezone(&Local); | |||||
| let reports_dir = root | |||||
| .join("reports") | |||||
| .join(local_started_at.format("%Y%m%d").to_string()); | |||||
| std::fs::create_dir_all(&reports_dir).with_context(|| { | std::fs::create_dir_all(&reports_dir).with_context(|| { | ||||
| format!( | format!( | ||||
| "failed to create reports directory {}", | "failed to create reports directory {}", | ||||
| reports_dir.display() | reports_dir.display() | ||||
| ) | ) | ||||
| })?; | })?; | ||||
| let timestamp = started_at.format("%Y%m%dT%H%M%SZ"); | |||||
| let timestamp = local_started_at.format("%Y%m%dT%H%M%S%z"); | |||||
| let filename = format!( | let filename = format!( | ||||
| "{}-{}-{}-{timestamp}.json", | "{}-{}-{}-{timestamp}.json", | ||||
| sanitize_filename_component(benchmark), | sanitize_filename_component(benchmark), | ||||
| @@ -296,6 +299,7 @@ mod tests { | |||||
| #[test] | #[test] | ||||
| fn writes_benchmark_report_under_reports_dir() { | fn writes_benchmark_report_under_reports_dir() { | ||||
| let temp_dir = tempfile::tempdir().expect("create temp dir"); | let temp_dir = tempfile::tempdir().expect("create temp dir"); | ||||
| let started_at = Utc.with_ymd_and_hms(2026, 5, 6, 1, 2, 3).unwrap(); | |||||
| let report = BenchmarkReport { | let report = BenchmarkReport { | ||||
| benchmark: "aime2026".to_string(), | benchmark: "aime2026".to_string(), | ||||
| provider: "openai".to_string(), | provider: "openai".to_string(), | ||||
| @@ -318,7 +322,7 @@ mod tests { | |||||
| local_path: "data/benchmarks/aime2026/aime2026.jsonl".to_string(), | local_path: "data/benchmarks/aime2026/aime2026.jsonl".to_string(), | ||||
| }, | }, | ||||
| run: RunReport { | run: RunReport { | ||||
| started_at: Utc.with_ymd_and_hms(2026, 5, 6, 1, 2, 3).unwrap(), | |||||
| started_at, | |||||
| duration_ms: 123, | duration_ms: 123, | ||||
| concurrency: 2, | concurrency: 2, | ||||
| limit: Some(1), | limit: Some(1), | ||||
| @@ -351,7 +355,12 @@ mod tests { | |||||
| let path = write_benchmark_report(temp_dir.path(), &report).expect("write report"); | let path = write_benchmark_report(temp_dir.path(), &report).expect("write report"); | ||||
| assert!(path.ends_with("reports/aime2026-openai-gpt-test-20260506T010203Z.json")); | |||||
| let local_started_at = started_at.with_timezone(&chrono::Local); | |||||
| let expected_date = local_started_at.format("%Y%m%d").to_string(); | |||||
| let expected_timestamp = local_started_at.format("%Y%m%dT%H%M%S%z").to_string(); | |||||
| assert!(path.ends_with(format!( | |||||
| "reports/{expected_date}/aime2026-openai-gpt-test-{expected_timestamp}.json" | |||||
| ))); | |||||
| assert!(path.exists()); | assert!(path.exists()); | ||||
| } | } | ||||