Skip to content

Commit ec14860

Browse files
committed
Move benchmarks to .codeflash/benchmarks/ and auto-discover
Move codeflash's own benchmarks to .codeflash/benchmarks/. Add auto-discovery of .codeflash/benchmarks/ in codeflash compare and benchmark mode -- when benchmarks-root is not explicitly configured, the CLI checks for .codeflash/benchmarks/ before erroring. Backwards compatible: users with existing benchmarks-root config are unaffected. Docs continue to show tests/benchmarks as the example path.
1 parent 5ee642e commit ec14860

11 files changed

Lines changed: 18 additions & 5 deletions

tests/benchmarks/test_benchmark_code_extract_code_context.py renamed to .codeflash/benchmarks/test_benchmark_code_extract_code_context.py

File renamed without changes.
File renamed without changes.

tests/benchmarks/test_benchmark_discover_unit_tests.py renamed to .codeflash/benchmarks/test_benchmark_discover_unit_tests.py

File renamed without changes.

tests/benchmarks/test_benchmark_libcst_multi_file.py renamed to .codeflash/benchmarks/test_benchmark_libcst_multi_file.py

File renamed without changes.
File renamed without changes.

tests/benchmarks/test_benchmark_merge_test_results.py renamed to .codeflash/benchmarks/test_benchmark_merge_test_results.py

File renamed without changes.

codeflash.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"tests/",
1717
"-vv",
1818
"--ignore",
19-
"tests/benchmarks/"
19+
".codeflash/benchmarks/"
2020
],
2121
},
2222
"launch": {

codeflash/cli_cmds/cli.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,14 @@ def process_pyproject_config(args: Namespace) -> Namespace:
156156
raise AssertionError("--tests-root must be specified")
157157
assert Path(args.tests_root).is_dir(), f"--tests-root {args.tests_root} must be a valid directory"
158158
if args.benchmark:
159-
assert args.benchmarks_root is not None, "--benchmarks-root must be specified when running with --benchmark"
159+
if args.benchmarks_root is None:
160+
# Auto-discover .codeflash/benchmarks/ convention
161+
candidate = Path.cwd() / ".codeflash" / "benchmarks"
162+
if candidate.is_dir():
163+
args.benchmarks_root = str(candidate)
164+
else:
165+
msg = "--benchmarks-root must be specified when running with --benchmark, or .codeflash/benchmarks/ must exist"
166+
raise AssertionError(msg)
160167
assert Path(args.benchmarks_root).is_dir(), (
161168
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
162169
)

codeflash/cli_cmds/cmd_compare.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@ def run_compare(args: Namespace) -> None:
8787
benchmarks_root_str = pyproject_config.get("benchmarks_root")
8888

8989
if not benchmarks_root_str:
90-
logger.error("benchmarks-root must be configured in [tool.codeflash] to use compare")
91-
sys.exit(1)
90+
# Auto-discover .codeflash/benchmarks/ if it exists
91+
candidate = project_root / ".codeflash" / "benchmarks"
92+
if candidate.is_dir():
93+
benchmarks_root_str = str(candidate)
94+
logger.info(f"Auto-discovered benchmarks at {candidate}")
95+
else:
96+
logger.error("benchmarks-root must be configured in [tool.codeflash] or .codeflash/benchmarks/ must exist")
97+
sys.exit(1)
9298

9399
benchmarks_root = Path(benchmarks_root_str).resolve()
94100
if not benchmarks_root.is_dir():

0 commit comments

Comments
 (0)