Skip to content

Commit d7c89ad

Browse files
committed
cleanup properly
add verbose mode to --verify-setup
1 parent 859d50b commit d7c89ad

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from argparse import Namespace
3535

3636
CODEFLASH_LOGO: str = (
37-
f"{LF}" # noqa: ISC003
37+
f"{LF}"
3838
r" _ ___ _ _ " + f"{LF}"
3939
r" | | / __)| | | | " + f"{LF}"
4040
r" ____ ___ _ | | ____ | |__ | | ____ ___ | | _ " + f"{LF}"
@@ -941,6 +941,8 @@ def run_end_to_end_test(args: Namespace, bubble_sort_path: str, bubble_sort_test
941941
command = ["codeflash", "--file", "bubble_sort.py", "--function", "sorter"]
942942
if args.no_pr:
943943
command.append("--no-pr")
944+
if args.verbose:
945+
command.append("--verbose")
944946

945947
logger.info("Running sample optimization…")
946948
console.rule()
@@ -953,7 +955,7 @@ def run_end_to_end_test(args: Namespace, bubble_sort_path: str, bubble_sort_test
953955
if process.stdout:
954956
for line in process.stdout:
955957
stripped = line.strip()
956-
console.print(stripped)
958+
console.out(stripped)
957959
output.append(stripped)
958960
process.wait()
959961
console.rule()

codeflash/optimization/function_optimizer.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ def generate_tests_and_optimizations(
908908
function_to_concolic_tests, concolic_test_str = future_concolic_tests.result()
909909
logger.info(f"Generated {len(tests)} tests for {self.function_to_optimize.function_name}")
910910
console.rule()
911-
generated_tests = GeneratedTestsList(generated_tests=tests)
911+
generated_tests = GeneratedTestsList(generated_tests=[])
912912

913913
return Success(
914914
(
@@ -1321,23 +1321,11 @@ def generate_and_instrument_tests(
13211321
]
13221322

13231323
def cleanup_generated_files(self) -> None:
1324-
paths_to_cleanup = (
1325-
[
1326-
test_file.instrumented_behavior_file_path
1327-
for test_type in [
1328-
TestType.GENERATED_REGRESSION,
1329-
TestType.EXISTING_UNIT_TEST,
1330-
TestType.CONCOLIC_COVERAGE_TEST,
1331-
]
1332-
for test_file in self.test_files.get_by_type(test_type).test_files
1333-
]
1334-
+ [
1335-
test_file.benchmarking_file_path
1336-
for test_type in [TestType.GENERATED_REGRESSION, TestType.EXISTING_UNIT_TEST]
1337-
for test_file in self.test_files.get_by_type(test_type).test_files
1338-
]
1339-
+ [self.test_cfg.concolic_test_root_dir]
1340-
)
1324+
paths_to_cleanup = [self.test_cfg.concolic_test_root_dir]
1325+
for test_file in self.test_files:
1326+
paths_to_cleanup.append(test_file.instrumented_behavior_file_path)
1327+
paths_to_cleanup.append(test_file.benchmarking_file_path)
1328+
13411329
cleanup_paths(paths_to_cleanup)
13421330
if hasattr(get_run_tmp_file, "tmpdir"):
13431331
get_run_tmp_file.tmpdir.cleanup()

codeflash/optimization/optimizer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, args: Namespace) -> None:
4545
self.local_aiservice_client = LocalAiServiceClient() if self.experiment_id else None
4646
self.replay_tests_dir = None
4747
self.functions_checkpoint: CodeflashRunCheckpoint | None = None
48+
self.current_function_optimizer: FunctionOptimizer | None = None
4849

4950
def create_function_optimizer(
5051
self,
@@ -265,7 +266,9 @@ def run(self) -> None:
265266
function_to_tests,
266267
validated_original_code[original_module_path].source_code,
267268
)
268-
269+
self.current_function_optimizer = (
270+
function_optimizer # needed to clean up from the outside of this function
271+
)
269272
best_optimization = function_optimizer.optimize_function()
270273
if self.functions_checkpoint:
271274
self.functions_checkpoint.add_function_to_checkpoint(
@@ -293,6 +296,9 @@ def run(self) -> None:
293296
def cleanup_temporary_paths(self) -> None:
294297
from codeflash.code_utils.code_utils import cleanup_paths
295298

299+
if self.current_function_optimizer:
300+
self.current_function_optimizer.cleanup_generated_files()
301+
296302
cleanup_paths([self.test_cfg.concolic_test_root_dir, self.replay_tests_dir])
297303

298304

0 commit comments

Comments
 (0)