Skip to content

Commit 9cc7e2e

Browse files
committed
future house fixes
1 parent 890243c commit 9cc7e2e

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

tests/scripts/end_to_end_test_futurehouse.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
from pathlib import Path
12
import os
2-
import pathlib
33

4-
from end_to_end_test_utilities import CoverageExpectation, TestConfig, run_codeflash_command, run_with_retries
4+
from tests.scripts.end_to_end_test_utilities import (
5+
CoverageExpectation,
6+
TestConfig,
7+
run_codeflash_command,
8+
run_with_retries
9+
)
510

611

712
def run_test(expected_improvement_pct: int) -> bool:
813
config = TestConfig(
9-
file_path="src/aviary/common_tags.py",
10-
expected_unit_tests=0, # todo: fix bug https://linear.app/codeflash-ai/issue/CF-921/test-discovery-does-not-work-properly-for-e2e-futurehouse-example for context
14+
file_path=Path("src/aviary/common_tags.py"),
15+
expected_unit_tests=2,
1116
min_improvement_x=0.05,
1217
coverage_expectations=[
1318
CoverageExpectation(
@@ -17,10 +22,10 @@ def run_test(expected_improvement_pct: int) -> bool:
1722
)
1823
],
1924
)
20-
cwd = (
21-
pathlib.Path(__file__).parent.parent.parent / "code_to_optimize" / "code_directories" / "futurehouse_structure"
25+
future_house_working_dir = (
26+
Path(__file__).parent.parent.parent / "code_to_optimize" / "code_directories" / "futurehouse_structure"
2227
).resolve()
23-
return run_codeflash_command(cwd, config, expected_improvement_pct)
28+
return run_codeflash_command(future_house_working_dir, config, expected_improvement_pct)
2429

2530

2631
if __name__ == "__main__":

tests/scripts/end_to_end_test_utilities.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import time
88
from dataclasses import dataclass, field
99
from typing import Optional
10+
import contextlib
11+
import tomllib
1012

1113

1214
@dataclass
@@ -82,7 +84,6 @@ def run_codeflash_command(
8284
logging.basicConfig(level=logging.INFO)
8385
if config.trace_mode:
8486
return run_trace_test(cwd, config, expected_improvement_pct)
85-
8687
path_to_file = cwd / config.file_path
8788
file_contents = path_to_file.read_text("utf-8")
8889
pytest_dir = cwd / "tests" / "pytest"
@@ -102,7 +103,6 @@ def run_codeflash_command(
102103

103104
return_code = process.wait()
104105
stdout = "".join(output)
105-
106106
validated = validate_output(stdout, return_code, expected_improvement_pct, config)
107107
if not validated:
108108
# Write original file contents back to file
@@ -129,7 +129,20 @@ def build_command(
129129

130130
if config.function_name:
131131
base_command.extend(["--function", config.function_name])
132-
base_command.extend(["--tests-root", str(test_root), "--module-root", str(cwd)])
132+
133+
# Check if pyproject.toml exists with codeflash config - if so, don't override it
134+
pyproject_path = cwd / "pyproject.toml"
135+
has_codeflash_config = False
136+
if pyproject_path.exists():
137+
with contextlib.suppress(Exception):
138+
with open(pyproject_path, "rb") as f:
139+
pyproject_data = tomllib.load(f)
140+
has_codeflash_config = "tool" in pyproject_data and "codeflash" in pyproject_data["tool"]
141+
142+
# Only pass --tests-root and --module-root if they're not configured in pyproject.toml
143+
if not has_codeflash_config:
144+
base_command.extend(["--tests-root", str(test_root), "--module-root", str(cwd)])
145+
133146
if benchmarks_root:
134147
base_command.extend(["--benchmark", "--benchmarks-root", str(benchmarks_root)])
135148
if config.use_worktree:

0 commit comments

Comments
 (0)