Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codeflash/cli_cmds/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def parse_args() -> Namespace:
parser.add_argument(
"--no-pr", action="store_true", help="Do not create a PR for the optimization, only update the code locally."
)
parser.add_argument(
"--no-gen-tests", action="store_true", help="Do not generate tests, use only existing tests for optimization."
)
parser.add_argument("--staging-review", action="store_true", help="Upload optimizations to staging for review")
parser.add_argument(
"--verify-setup",
Expand Down
68 changes: 36 additions & 32 deletions codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,47 +1295,51 @@ def generate_tests(
n_tests = N_TESTS_TO_GENERATE_EFFECTIVE
assert len(generated_test_paths) == n_tests

# Submit test generation tasks
future_tests = self.submit_test_generation_tasks(
self.executor,
testgen_context.markdown,
[definition.fully_qualified_name for definition in helper_functions],
generated_test_paths,
generated_perf_test_paths,
)
if not self.args.no_gen_tests:
# Submit test generation tasks
future_tests = self.submit_test_generation_tasks(
self.executor,
testgen_context.markdown,
[definition.fully_qualified_name for definition in helper_functions],
generated_test_paths,
generated_perf_test_paths,
)

future_concolic_tests = self.executor.submit(
generate_concolic_tests, self.test_cfg, self.args, self.function_to_optimize, self.function_to_optimize_ast
)

# Wait for test futures to complete
concurrent.futures.wait([*future_tests, future_concolic_tests])

if not self.args.no_gen_tests:
# Wait for test futures to complete
concurrent.futures.wait([*future_tests, future_concolic_tests])
else:
concurrent.futures.wait([future_concolic_tests])
# Process test generation results
tests: list[GeneratedTests] = []
for future in future_tests:
res = future.result()
if res:
(
generated_test_source,
instrumented_behavior_test_source,
instrumented_perf_test_source,
test_behavior_path,
test_perf_path,
) = res
tests.append(
GeneratedTests(
generated_original_test_source=generated_test_source,
instrumented_behavior_test_source=instrumented_behavior_test_source,
instrumented_perf_test_source=instrumented_perf_test_source,
behavior_file_path=test_behavior_path,
perf_file_path=test_perf_path,
if not self.args.no_gen_tests:
for future in future_tests:
res = future.result()
if res:
(
generated_test_source,
instrumented_behavior_test_source,
instrumented_perf_test_source,
test_behavior_path,
test_perf_path,
) = res
tests.append(
GeneratedTests(
generated_original_test_source=generated_test_source,
instrumented_behavior_test_source=instrumented_behavior_test_source,
instrumented_perf_test_source=instrumented_perf_test_source,
behavior_file_path=test_behavior_path,
perf_file_path=test_perf_path,
)
)
)

if not tests:
logger.warning(f"Failed to generate and instrument tests for {self.function_to_optimize.function_name}")
return Failure(f"/!\\ NO TESTS GENERATED for {self.function_to_optimize.function_name}")
if not tests:
logger.warning(f"Failed to generate and instrument tests for {self.function_to_optimize.function_name}")
return Failure(f"/!\\ NO TESTS GENERATED for {self.function_to_optimize.function_name}")

function_to_concolic_tests, concolic_test_str = future_concolic_tests.result()
count_tests = len(tests)
Expand Down
Loading