mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
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.
This commit is contained in:
parent
5ee642e35e
commit
ec14860d29
11 changed files with 18 additions and 5 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
"tests/",
|
"tests/",
|
||||||
"-vv",
|
"-vv",
|
||||||
"--ignore",
|
"--ignore",
|
||||||
"tests/benchmarks/"
|
".codeflash/benchmarks/"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"launch": {
|
"launch": {
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,14 @@ def process_pyproject_config(args: Namespace) -> Namespace:
|
||||||
raise AssertionError("--tests-root must be specified")
|
raise AssertionError("--tests-root must be specified")
|
||||||
assert Path(args.tests_root).is_dir(), f"--tests-root {args.tests_root} must be a valid directory"
|
assert Path(args.tests_root).is_dir(), f"--tests-root {args.tests_root} must be a valid directory"
|
||||||
if args.benchmark:
|
if args.benchmark:
|
||||||
assert args.benchmarks_root is not None, "--benchmarks-root must be specified when running with --benchmark"
|
if args.benchmarks_root is None:
|
||||||
|
# Auto-discover .codeflash/benchmarks/ convention
|
||||||
|
candidate = Path.cwd() / ".codeflash" / "benchmarks"
|
||||||
|
if candidate.is_dir():
|
||||||
|
args.benchmarks_root = str(candidate)
|
||||||
|
else:
|
||||||
|
msg = "--benchmarks-root must be specified when running with --benchmark, or .codeflash/benchmarks/ must exist"
|
||||||
|
raise AssertionError(msg)
|
||||||
assert Path(args.benchmarks_root).is_dir(), (
|
assert Path(args.benchmarks_root).is_dir(), (
|
||||||
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
|
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,14 @@ def run_compare(args: Namespace) -> None:
|
||||||
benchmarks_root_str = pyproject_config.get("benchmarks_root")
|
benchmarks_root_str = pyproject_config.get("benchmarks_root")
|
||||||
|
|
||||||
if not benchmarks_root_str:
|
if not benchmarks_root_str:
|
||||||
logger.error("benchmarks-root must be configured in [tool.codeflash] to use compare")
|
# Auto-discover .codeflash/benchmarks/ if it exists
|
||||||
sys.exit(1)
|
candidate = project_root / ".codeflash" / "benchmarks"
|
||||||
|
if candidate.is_dir():
|
||||||
|
benchmarks_root_str = str(candidate)
|
||||||
|
logger.info(f"Auto-discovered benchmarks at {candidate}")
|
||||||
|
else:
|
||||||
|
logger.error("benchmarks-root must be configured in [tool.codeflash] or .codeflash/benchmarks/ must exist")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
benchmarks_root = Path(benchmarks_root_str).resolve()
|
benchmarks_root = Path(benchmarks_root_str).resolve()
|
||||||
if not benchmarks_root.is_dir():
|
if not benchmarks_root.is_dir():
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ __version__ = "{version}"
|
||||||
# All paths are relative to this pyproject.toml's directory.
|
# All paths are relative to this pyproject.toml's directory.
|
||||||
module-root = "codeflash"
|
module-root = "codeflash"
|
||||||
tests-root = "tests"
|
tests-root = "tests"
|
||||||
benchmarks-root = "tests/benchmarks"
|
benchmarks-root = ".codeflash/benchmarks"
|
||||||
ignore-paths = []
|
ignore-paths = []
|
||||||
formatter-cmds = [
|
formatter-cmds = [
|
||||||
"uvx ruff check --exit-zero --fix $file",
|
"uvx ruff check --exit-zero --fix $file",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue