From 3eed45dc3edb1515f587ac42caf6a0b6116006cb Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 28 Nov 2024 14:01:45 -0800 Subject: [PATCH] fix: improve benchmark directory selection based on latest .md file timestamp --- benchmark/benchmark.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index db696079b..a8d033c08 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -68,10 +68,23 @@ def find_latest_benchmark_dir(): print("Error: No benchmark directories found from the last 24 hours.") sys.exit(1) - latest_dir = max( - recent_dirs, - key=lambda d: next((f.stat().st_mtime for f in d.glob("*/.*.md") if f.is_file()), 0), - ) + # Find directory with most recently modified .md file + latest_dir = None + latest_time = 0 + + for d in recent_dirs: + # Look for .md files in subdirectories + for md_file in d.glob("*/.*.md"): + if md_file.is_file(): + mtime = md_file.stat().st_mtime + if mtime > latest_time: + latest_time = mtime + latest_dir = d + + if not latest_dir: + print("Error: No .md files found in recent benchmark directories.") + sys.exit(1) + print(f"Using the most recently updated benchmark directory: {latest_dir.name}") return latest_dir