@@ -221,73 +221,6 @@ def optimize_code(
221221 console .rule ()
222222 return []
223223
224- # Backward-compatible alias
225- def optimize_python_code (
226- self ,
227- source_code : str ,
228- dependency_code : str ,
229- trace_id : str ,
230- experiment_metadata : ExperimentMetadata | None = None ,
231- * ,
232- is_async : bool = False ,
233- n_candidates : int = 5 ,
234- ) -> list [OptimizedCandidate ]:
235- """Backward-compatible alias for optimize_code() with language='python'."""
236- return self .optimize_code (
237- source_code = source_code ,
238- dependency_code = dependency_code ,
239- trace_id = trace_id ,
240- experiment_metadata = experiment_metadata ,
241- language = "python" ,
242- is_async = is_async ,
243- n_candidates = n_candidates ,
244- )
245-
246- def get_jit_rewritten_code (self , source_code : str , trace_id : str ) -> list [OptimizedCandidate ]:
247- """Rewrite the given python code for performance via jit compilation by making a request to the Django endpoint.
248-
249- Parameters
250- ----------
251- - source_code (str): The python code to optimize.
252- - trace_id (str): Trace id of optimization run
253-
254- Returns
255- -------
256- - List[OptimizationCandidate]: A list of Optimization Candidates.
257-
258- """
259- start_time = time .perf_counter ()
260- git_repo_owner , git_repo_name = safe_get_repo_owner_and_name ()
261-
262- payload = {
263- "source_code" : source_code ,
264- "trace_id" : trace_id ,
265- "dependency_code" : "" , # dummy value to please the api endpoint
266- "python_version" : platform .python_version (), # backward compat
267- "current_username" : get_last_commit_author_if_pr_exists (None ),
268- "repo_owner" : git_repo_owner ,
269- "repo_name" : git_repo_name ,
270- }
271-
272- logger .info ("!lsp|Rewriting as a JIT function…" )
273- console .rule ()
274- try :
275- response = self .make_ai_service_request ("/rewrite_jit" , payload = payload , timeout = self .timeout )
276- except requests .exceptions .RequestException as e :
277- logger .exception (f"Error generating jit rewritten candidate: { e } " )
278- ph ("cli-jit-rewrite-error-caught" , {"error" : str (e )})
279- return []
280-
281- if response .status_code == 200 :
282- optimizations_json = response .json ()["optimizations" ]
283- console .rule ()
284- end_time = time .perf_counter ()
285- logger .debug (f"!lsp|Generating jit rewritten code took { end_time - start_time :.2f} seconds." )
286- return self ._get_valid_candidates (optimizations_json , OptimizedCandidateSource .JIT_REWRITE )
287- self .log_error_response (response , "generating jit rewritten candidate" , "cli-jit-rewrite-error-response" )
288- console .rule ()
289- return []
290-
291224 def optimize_python_code_line_profiler (
292225 self ,
293226 source_code : str ,
@@ -441,20 +374,7 @@ def optimize_code_refinement(self, request: list[AIServiceRefinerRequest]) -> li
441374 console .rule ()
442375 return []
443376
444- # Alias for backward compatibility
445- optimize_python_code_refinement = optimize_code_refinement
446-
447377 def code_repair (self , request : AIServiceCodeRepairRequest ) -> OptimizedCandidate | None :
448- """Repair the optimization candidate that is not matching the test result of the original code.
449-
450- Args:
451- request: candidate details for repair
452-
453- Returns:
454- -------
455- - OptimizedCandidate: new fixed candidate.
456-
457- """
458378 console .rule ()
459379 try :
460380 payload = {
0 commit comments