File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1010from pydantic .json import pydantic_encoder
1111
1212from codeflash .cli_cmds .console import console , logger
13+ from codeflash .code_utils .config_consts import get_n_candidates , get_n_candidates_lp
1314from codeflash .code_utils .env_utils import get_codeflash_api_key
1415from codeflash .code_utils .git_utils import get_last_commit_author_if_pr_exists , get_repo_owner_and_name
1516from codeflash .lsp .helpers import is_LSP_enabled
@@ -131,6 +132,7 @@ def optimize_python_code( # noqa: D417
131132 "current_username" : get_last_commit_author_if_pr_exists (None ),
132133 "repo_owner" : git_repo_owner ,
133134 "repo_name" : git_repo_name ,
135+ "n_candidates" : get_n_candidates (),
134136 }
135137
136138 logger .info ("Generating optimized candidates…" )
@@ -192,6 +194,7 @@ def optimize_python_code_line_profiler( # noqa: D417
192194 "experiment_metadata" : experiment_metadata ,
193195 "codeflash_version" : codeflash_version ,
194196 "lsp_mode" : is_LSP_enabled (),
197+ "n_candidates_lp" : get_n_candidates_lp (),
195198 }
196199
197200 logger .info ("Generating optimized candidates…" )
Original file line number Diff line number Diff line change 1111MIN_TESTCASE_PASSED_THRESHOLD = 6
1212REPEAT_OPTIMIZATION_PROBABILITY = 0.1
1313DEFAULT_IMPORTANCE_THRESHOLD = 0.001
14+ N_CANDIDATES_LP = 6
1415
1516# LSP-specific
1617N_CANDIDATES_LSP = 3
17- N_TESTS_TO_GENERATE_LSP = 1
18+ N_TESTS_TO_GENERATE_LSP = 2
1819TOTAL_LOOPING_TIME_LSP = 10.0 # Kept same timing for LSP mode to avoid in increase in performance reporting
20+ N_CANDIDATES_LP_LSP = 3
1921
2022
2123def get_n_candidates () -> int :
@@ -24,6 +26,12 @@ def get_n_candidates() -> int:
2426 return N_CANDIDATES_LSP if is_LSP_enabled () else N_CANDIDATES
2527
2628
29+ def get_n_candidates_lp () -> int :
30+ from codeflash .lsp .helpers import is_LSP_enabled
31+
32+ return N_CANDIDATES_LP_LSP if is_LSP_enabled () else N_CANDIDATES_LP
33+
34+
2735def get_n_tests_to_generate () -> int :
2836 from codeflash .lsp .helpers import is_LSP_enabled
2937
Original file line number Diff line number Diff line change 4545 INDIVIDUAL_TESTCASE_TIMEOUT ,
4646 REPEAT_OPTIMIZATION_PROBABILITY ,
4747 get_n_candidates ,
48+ get_n_candidates_lp ,
4849 get_n_tests_to_generate ,
4950 get_total_looping_time ,
5051)
@@ -476,7 +477,7 @@ def determine_best_candidate(
476477 dependency_code = code_context .read_only_context_code ,
477478 trace_id = self .function_trace_id [:- 4 ] + exp_type if self .experiment_id else self .function_trace_id ,
478479 line_profiler_results = original_code_baseline .line_profile_results ["str_out" ],
479- num_candidates = 10 ,
480+ num_candidates = get_n_candidates_lp () ,
480481 experiment_metadata = ExperimentMetadata (
481482 id = self .experiment_id , group = "control" if exp_type == "EXP0" else "experiment"
482483 )
You can’t perform that action at this time.
0 commit comments