@@ -545,6 +545,10 @@ def replace_function_and_helpers_with_optimized_code(
545545 for helper_function in code_context .helper_functions :
546546 if helper_function .jedi_definition .type != "class" :
547547 read_writable_functions_by_file_path [helper_function .file_path ].add (helper_function .qualified_name )
548+ logger .debug ("Read writable functions by file path:" )
549+ logger .debug (read_writable_functions_by_file_path )
550+ logger .debug ("Optimized code:" )
551+ logger .debug (optimized_code )
548552 for module_abspath , qualified_names in read_writable_functions_by_file_path .items ():
549553 did_update |= replace_function_definitions_in_module (
550554 function_names = list (qualified_names ),
@@ -848,12 +852,12 @@ def establish_original_code_baseline(
848852 self .write_code_and_helpers (
849853 self .function_to_optimize_source_code , original_helper_code , self .function_to_optimize .file_path
850854 )
851- # if not behavioral_results:
852- # logger.warning(
853- # f"Couldn't run any tests for original function {self.function_to_optimize.function_name}. SKIPPING OPTIMIZING THIS FUNCTION."
854- # )
855- # console.rule()
856- # return Failure("Failed to establish a baseline for the original code - bevhavioral tests failed.")
855+ if not behavioral_results :
856+ logger .warning (
857+ f"Couldn't run any tests for original function { self .function_to_optimize .function_name } . SKIPPING OPTIMIZING THIS FUNCTION."
858+ )
859+ console .rule ()
860+ return Failure ("Failed to establish a baseline for the original code - bevhavioral tests failed." )
857861
858862 if test_framework == "pytest" :
859863 benchmarking_results , _ = self .run_and_parse_tests (
@@ -901,12 +905,6 @@ def establish_original_code_baseline(
901905 for result in behavioral_results
902906 if (result .test_type == TestType .GENERATED_REGRESSION and not result .did_pass )
903907 ]
904- if not behavioral_results :
905- logger .warning (
906- f"Couldn't run any tests for original function { self .function_to_optimize .function_name } . SKIPPING OPTIMIZING THIS FUNCTION."
907- )
908- console .rule ()
909- success = False
910908 if total_timing == 0 :
911909 logger .warning (
912910 "The overall summed benchmark runtime of the original function is 0, couldn't run tests."
@@ -962,6 +960,7 @@ def run_optimized_candidate(
962960 get_run_tmp_file (Path (f"test_return_values_{ optimization_candidate_index } .sqlite" )).unlink (missing_ok = True )
963961
964962 # Instrument codeflash capture
963+ candidate_fto_code = Path (function_to_optimize .file_path ).read_text ("utf-8" )
965964 candidate_helper_code = {}
966965 for module_abspath in original_helper_code :
967966 candidate_helper_code [module_abspath ] = Path (module_abspath ).read_text ("utf-8" )
@@ -981,7 +980,7 @@ def run_optimized_candidate(
981980 # Remove instrumentation
982981 finally :
983982 self .write_code_and_helpers (
984- self . function_to_optimize_source_code , candidate_helper_code , self .function_to_optimize .file_path
983+ candidate_fto_code , candidate_helper_code , self .function_to_optimize .file_path
985984 )
986985 console .print (
987986 TestResults .report_to_tree (
0 commit comments