fix: remove unnecessary Optimizer from benchmark test

The test only needs project_root, not a full Optimizer (which requires
an API key). Also adds missing __init__.py to tests/benchmarks/.
This commit is contained in:
Kevin Turcios 2026-04-10 00:10:36 -05:00
parent 2208e8ca77
commit 1a25f05e14
2 changed files with 3 additions and 16 deletions

View file

View file

@ -1,31 +1,18 @@
from argparse import Namespace
from pathlib import Path
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
from codeflash.languages.python.context.code_context_extractor import get_code_optimization_context
from codeflash.models.models import FunctionParent
from codeflash.optimization.optimizer import Optimizer
def test_benchmark_extract(benchmark) -> None:
file_path = Path(__file__).parent.parent.parent.resolve() / "codeflash"
opt = Optimizer(
Namespace(
project_root=file_path.resolve(),
disable_telemetry=True,
tests_root=(file_path / "tests").resolve(),
test_framework="pytest",
pytest_cmd="pytest",
experiment_id=None,
test_project_root=Path.cwd(),
)
)
project_root = Path(__file__).parent.parent.parent.resolve() / "codeflash"
function_to_optimize = FunctionToOptimize(
function_name="replace_function_and_helpers_with_optimized_code",
file_path=file_path / "languages" / "function_optimizer.py",
file_path=project_root / "languages" / "function_optimizer.py",
parents=[FunctionParent(name="FunctionOptimizer", type="ClassDef")],
starting_line=None,
ending_line=None,
)
benchmark(get_code_optimization_context, function_to_optimize, opt.args.project_root)
benchmark(get_code_optimization_context, function_to_optimize, project_root)