From 38ff2276e04aa7d24113285a1870540f4d6034dd Mon Sep 17 00:00:00 2001 From: Bryce Adelstein Lelbach Date: Tue, 23 Jun 2026 21:57:49 +0000 Subject: [PATCH 1/2] Show full-precision scores and add `submissions show --no-code` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two small quality-of-life fixes to the submissions views: - Print scores at full f64 precision in both `submissions list` and `submissions show`. They were formatted with `{:.4}`, which rounds the geomean leaderboard score to 4 decimals (e.g. 0.0017 for two distinct submissions that actually scored 0.0017318 vs 0.0017449) — enough to make near-tied submissions indistinguishable. `f64::to_string()` emits the shortest decimal that round-trips, so no rounding and no trailing zero noise. - Add a `--no-code` flag to `submissions show` to omit the (often large) code block, for when you only want the metadata and per-run scores. Default behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/cmd/mod.rs | 8 +++++++- src/cmd/submissions.rs | 17 ++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index e1b1033..21b72bb 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -93,6 +93,10 @@ enum SubmissionsAction { Show { /// Submission ID id: i64, + + /// Do not print the submission's code + #[arg(long)] + no_code: bool, }, /// Delete a submission Delete { @@ -255,7 +259,9 @@ pub async fn execute(cli: Cli) -> Result<()> { SubmissionsAction::List { leaderboard, limit } => { submissions::list_submissions(cli_id, leaderboard, Some(limit)).await } - SubmissionsAction::Show { id } => submissions::show_submission(cli_id, id).await, + SubmissionsAction::Show { id, no_code } => { + submissions::show_submission(cli_id, id, no_code).await + } SubmissionsAction::Delete { id, force } => { submissions::delete_submission(cli_id, id, force).await } diff --git a/src/cmd/submissions.rs b/src/cmd/submissions.rs index 4a9fddc..4e587ae 100644 --- a/src/cmd/submissions.rs +++ b/src/cmd/submissions.rs @@ -36,14 +36,15 @@ pub async fn list_submissions( gpus.join(",") }; - // Get best score (lowest) + // Get best score (lowest). Print full f64 precision (the shortest + // string that round-trips) rather than rounding to 4 decimals. let best_score = sub .runs .iter() .filter_map(|r| r.score) .min_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal)); let score_display = best_score - .map(|s| format!("{:.4}", s)) + .map(|s| s.to_string()) .unwrap_or_else(|| "-".to_string()); let time = truncate(&sub.submission_time, 19); @@ -64,7 +65,7 @@ pub async fn list_submissions( } /// Show a specific submission with full details -pub async fn show_submission(cli_id: String, submission_id: i64) -> Result<()> { +pub async fn show_submission(cli_id: String, submission_id: i64, no_code: bool) -> Result<()> { let client = service::create_client(Some(cli_id))?; let sub = service::get_user_submission(&client, submission_id).await?; @@ -87,7 +88,7 @@ pub async fn show_submission(cli_id: String, submission_id: i64) -> Result<()> { for run in &sub.runs { let score_str = run .score - .map(|s| format!("{:.4}", s)) + .map(|s| s.to_string()) .unwrap_or_else(|| "-".to_string()); let status = if run.passed { "passed" } else { "failed" }; let secret_marker = if run.secret { " [secret]" } else { "" }; @@ -103,9 +104,11 @@ pub async fn show_submission(cli_id: String, submission_id: i64) -> Result<()> { } } - println!("\nCode:"); - println!("{}", "-".repeat(60)); - println!("{}", sub.code); + if !no_code { + println!("\nCode:"); + println!("{}", "-".repeat(60)); + println!("{}", sub.code); + } Ok(()) } From 32f4ea5c49398f53d1beb083ee67bbc6efeb32cd Mon Sep 17 00:00:00 2001 From: Bryce Adelstein Lelbach Date: Tue, 23 Jun 2026 22:23:19 +0000 Subject: [PATCH 2/2] Extract format_score helper and add unit tests Pull the score-rendering logic (shared by `list` and `show`) into a `format_score` helper and cover it with unit tests, so the precision change has patch coverage (codecov/patch was 0%). Also adds a small `truncate` test. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/cmd/submissions.rs | 58 +++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/src/cmd/submissions.rs b/src/cmd/submissions.rs index 4e587ae..203642e 100644 --- a/src/cmd/submissions.rs +++ b/src/cmd/submissions.rs @@ -36,16 +36,13 @@ pub async fn list_submissions( gpus.join(",") }; - // Get best score (lowest). Print full f64 precision (the shortest - // string that round-trips) rather than rounding to 4 decimals. + // Get best score (lowest). let best_score = sub .runs .iter() .filter_map(|r| r.score) .min_by(|a, b| a.partial_cmp(b).unwrap_or(std::cmp::Ordering::Equal)); - let score_display = best_score - .map(|s| s.to_string()) - .unwrap_or_else(|| "-".to_string()); + let score_display = format_score(best_score); let time = truncate(&sub.submission_time, 19); @@ -86,10 +83,7 @@ pub async fn show_submission(cli_id: String, submission_id: i64, no_code: bool) if !sub.runs.is_empty() { println!("\nRuns:"); for run in &sub.runs { - let score_str = run - .score - .map(|s| s.to_string()) - .unwrap_or_else(|| "-".to_string()); + let score_str = format_score(run.score); let status = if run.passed { "passed" } else { "failed" }; let secret_marker = if run.secret { " [secret]" } else { "" }; let time_info = match (&run.start_time, &run.end_time) { @@ -170,3 +164,49 @@ fn truncate(s: &str, max_len: usize) -> String { format!("{}...", &s[..max_len - 3]) } } + +/// Render a score for display: full f64 precision (the shortest string that +/// round-trips) rather than a rounded `{:.4}`, or "-" when there is no score. +fn format_score(score: Option) -> String { + score + .map(|s| s.to_string()) + .unwrap_or_else(|| "-".to_string()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_format_score_full_precision() { + // Full precision, not rounded to 4 decimals: two near-tied scores stay + // distinguishable (the bug this replaces rendered both as "0.0017"). + assert_eq!( + format_score(Some(0.001731805142084383)), + "0.001731805142084383" + ); + assert_eq!( + format_score(Some(0.0017448536290123567)), + "0.0017448536290123567" + ); + } + + #[test] + fn test_format_score_no_trailing_zeros() { + // Shortest round-tripping form: no padding to 4 decimals. + assert_eq!(format_score(Some(1.5)), "1.5"); + assert_eq!(format_score(Some(0.0)), "0"); + } + + #[test] + fn test_format_score_none_is_dash() { + assert_eq!(format_score(None), "-"); + } + + #[test] + fn test_truncate() { + assert_eq!(truncate("short", 19), "short"); + assert_eq!(truncate("submission.py", 19), "submission.py"); + assert_eq!(truncate("0123456789", 8), "01234..."); + } +}