@@ -107,6 +107,22 @@ def run_benchmarks(
107107
108108 return function_benchmark_timings , total_benchmark_timings
109109
110+ def get_optimizable_functions (self ) -> tuple [dict [Path , list [FunctionToOptimize ]], int ]:
111+ """Discover functions to optimize."""
112+ from codeflash .discovery .functions_to_optimize import get_functions_to_optimize
113+
114+ return get_functions_to_optimize (
115+ optimize_all = self .args .all ,
116+ replay_test = self .args .replay_test ,
117+ file = self .args .file ,
118+ only_get_this_function = self .args .function ,
119+ test_cfg = self .test_cfg ,
120+ ignore_paths = self .args .ignore_paths ,
121+ project_root = self .args .project_root ,
122+ module_root = self .args .module_root ,
123+ previous_checkpoint_functions = self .args .previous_checkpoint_functions ,
124+ )
125+
110126 def create_function_optimizer (
111127 self ,
112128 function_to_optimize : FunctionToOptimize ,
@@ -139,7 +155,6 @@ def run(self) -> None:
139155 get_first_top_level_function_or_method_ast ,
140156 )
141157 from codeflash .discovery .discover_unit_tests import discover_unit_tests
142- from codeflash .discovery .functions_to_optimize import get_functions_to_optimize
143158
144159 ph ("cli-optimize-run-start" )
145160 logger .info ("Running optimizer." )
@@ -154,20 +169,7 @@ def run(self) -> None:
154169 return
155170
156171 function_optimizer = None
157- file_to_funcs_to_optimize : dict [Path , list [FunctionToOptimize ]]
158- num_optimizable_functions : int
159- # discover functions
160- (file_to_funcs_to_optimize , num_optimizable_functions ) = get_functions_to_optimize (
161- optimize_all = self .args .all ,
162- replay_test = self .args .replay_test ,
163- file = self .args .file ,
164- only_get_this_function = self .args .function ,
165- test_cfg = self .test_cfg ,
166- ignore_paths = self .args .ignore_paths ,
167- project_root = self .args .project_root ,
168- module_root = self .args .module_root ,
169- previous_checkpoint_functions = self .args .previous_checkpoint_functions ,
170- )
172+ file_to_funcs_to_optimize , num_optimizable_functions = self .get_optimizable_functions ()
171173 function_benchmark_timings , total_benchmark_timings = self .run_benchmarks (
172174 file_to_funcs_to_optimize , num_optimizable_functions
173175 )
0 commit comments