Skip to content

Commit 17de10b

Browse files
authored
Merge pull request #114 from codeflash-ai/line-profiler
correct calculation of total candidate length after adding line profiler results
2 parents f54c1ad + 49157a4 commit 17de10b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def determine_best_candidate(
362362
candidates = deque(candidates)
363363
# Start a new thread for AI service request, start loop in main thread
364364
# check if aiservice request is complete, when it is complete, append result to the candidates list
365-
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
365+
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
366366
future_line_profile_results = executor.submit(
367367
self.aiservice_client.optimize_python_code_line_profiler,
368368
source_code=code_context.read_writable_code,
@@ -382,8 +382,8 @@ def determine_best_candidate(
382382
if done and (future_line_profile_results is not None):
383383
line_profile_results = future_line_profile_results.result()
384384
candidates.extend(line_profile_results)
385-
original_len+= len(candidates)
386-
logger.info(f"Added results from line profiler to candidates, total candidates now: {original_len}")
385+
original_len+= len(line_profile_results)
386+
logger.info(f"Added {len(line_profile_results)} results from line profiler to candidates, total candidates now: {original_len}")
387387
future_line_profile_results = None
388388
candidate_index += 1
389389
candidate = candidates.popleft()
@@ -1086,8 +1086,8 @@ def run_and_parse_tests(
10861086
pytest_cmd=self.test_cfg.pytest_cmd,
10871087
pytest_timeout=INDIVIDUAL_TESTCASE_TIMEOUT,
10881088
pytest_target_runtime_seconds=testing_time,
1089-
pytest_min_loops=1,
1090-
pytest_max_loops=1,
1089+
pytest_min_loops=pytest_min_loops,
1090+
pytest_max_loops=pytest_min_loops,
10911091
test_framework=self.test_cfg.test_framework,
10921092
line_profiler_output_file=line_profiler_output_file,
10931093
)

codeflash/verification/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ def run_line_profile_tests(
182182
f"--timeout={pytest_timeout}",
183183
"-q",
184184
"--codeflash_loops_scope=session",
185-
f"--codeflash_min_loops={pytest_min_loops}",
186-
f"--codeflash_max_loops={pytest_max_loops}",
185+
"--codeflash_min_loops=1",
186+
"--codeflash_max_loops=1",
187187
f"--codeflash_seconds={pytest_target_runtime_seconds}",
188188
]
189189
result_file_path = get_run_tmp_file(Path("pytest_results.xml"))

0 commit comments

Comments
 (0)