Skip to content

Commit d95a11d

Browse files
committed
slight fixes
1 parent 64818c7 commit d95a11d

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,14 +823,14 @@ def establish_original_code_baseline(
823823
test_env = os.environ.copy()
824824
test_env["CODEFLASH_TEST_ITERATION"] = "0"
825825
test_env["CODEFLASH_TRACER_DISABLE"] = "1"
826+
test_env["CODEFLASH_LOOP_INDEX"] = "0"
826827
if "PYTHONPATH" not in test_env:
827828
test_env["PYTHONPATH"] = str(self.args.project_root)
828829
else:
829830
test_env["PYTHONPATH"] += os.pathsep + str(self.args.project_root)
830831

831832
coverage_results = None
832833
# Instrument codeflash capture
833-
original_fto_code = Path(self.function_to_optimize.file_path).read_text("utf-8")
834834
try:
835835
instrument_codeflash_capture(
836836
self.function_to_optimize, file_path_to_helper_classes, self.test_cfg.tests_root
@@ -847,7 +847,7 @@ def establish_original_code_baseline(
847847
finally:
848848
# Remove codeflash capture
849849
self.write_code_and_helpers(
850-
original_fto_code, original_helper_code, self.function_to_optimize.file_path
850+
self.function_to_optimize_source_code, original_helper_code, self.function_to_optimize.file_path
851851
)
852852
if not behavioral_results:
853853
logger.warning(
@@ -949,6 +949,7 @@ def run_optimized_candidate(
949949

950950
with progress_bar("Testing optimization candidate"):
951951
test_env = os.environ.copy()
952+
test_env["CODEFLASH_LOOP_INDEX"] = "0"
952953
test_env["CODEFLASH_TEST_ITERATION"] = str(optimization_candidate_index)
953954
test_env["CODEFLASH_TRACER_DISABLE"] = "1"
954955
if "PYTHONPATH" not in test_env:
@@ -1103,8 +1104,8 @@ def run_and_parse_tests(
11031104
logger.debug(
11041105
f'Nonzero return code {run_result.returncode} when running tests in '
11051106
f'{", ".join([str(f.instrumented_behavior_file_path) for f in test_files.test_files])}.\n'
1106-
# f"stdout: {run_result.stdout}\n"
1107-
# f"stderr: {run_result.stderr}\n"
1107+
f"stdout: {run_result.stdout}\n"
1108+
f"stderr: {run_result.stderr}\n"
11081109
)
11091110

11101111
results, coverage_results = parse_test_results(

codeflash/optimization/optimizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def __init__(self, args: Namespace) -> None:
4545
self.experiment_id = os.getenv("CODEFLASH_EXPERIMENT_ID", None)
4646
self.local_aiservice_client = LocalAiServiceClient() if self.experiment_id else None
4747

48-
self.test_files = TestFiles(test_files=[])
49-
5048
def create_function_optimizer(
5149
self,
5250
function_to_optimize: FunctionToOptimize,

codeflash/verification/test_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def usable_runtime_data_by_test_case(self) -> dict[InvocationId, list[int]]:
168168
for result in self.test_results:
169169
if result.did_pass and not result.runtime:
170170
logger.debug(
171-
f"Ignoring test case that passed but had no runtime -> {result.id}, Loop # {result.loop_index}"
171+
f"Ignoring test case that passed but had no runtime -> {result.id}, Loop # {result.loop_index}, Test Type: {result.test_type}, Verification Type: {result.verification_type}"
172172
)
173173
usable_runtimes = [
174174
(result.id, result.runtime) for result in self.test_results if result.did_pass and result.runtime

codeflash/verification/test_runner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,25 @@ def run_behavioral_tests(
8787
env=pytest_test_env,
8888
timeout=600,
8989
)
90-
logger.debug(results)
90+
logger.debug(
91+
f"""Result return code: {results.returncode}, {"Result stderr:" + str(results.stderr) if results.stderr else ''}""")
9192
else:
9293
results = execute_test_subprocess(
9394
pytest_cmd_list + common_pytest_args + result_args + test_files,
9495
cwd=cwd,
9596
env=pytest_test_env,
9697
timeout=600, # TODO: Make this dynamic
9798
)
99+
logger.debug(
100+
f"""Result return code: {results.returncode}, {"Result stderr:" + str(results.stderr) if results.stderr else ''}""")
98101
elif test_framework == "unittest":
99102
if enable_coverage:
100103
raise ValueError("Coverage is not supported yet for unittest framework")
101104
test_env["CODEFLASH_LOOP_INDEX"] = "1"
102105
test_files = [file.instrumented_behavior_file_path for file in test_paths.test_files]
103106
result_file_path, results = run_unittest_tests(verbose, test_files, test_env, cwd)
107+
logger.debug(
108+
f"""Result return code: {results.returncode}, {"Result stderr:" + str(results.stderr) if results.stderr else ''}""")
104109
else:
105110
raise ValueError(f"Unsupported test framework: {test_framework}")
106111

0 commit comments

Comments
 (0)