Skip to content

Commit d6c8a0a

Browse files
authored
Merge pull request #1854 from codeflash-ai/cleanup/remove-dead-code
remove dead code
2 parents a0a2a85 + b2ccf4c commit d6c8a0a

20 files changed

Lines changed: 28 additions & 567 deletions

codeflash/api/aiservice.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = {

codeflash/api/schemas.py

Lines changed: 0 additions & 258 deletions
This file was deleted.

codeflash/cli_cmds/cli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pathlib import Path
77

88
from codeflash.cli_cmds import logging_config
9-
from codeflash.cli_cmds.console import logger
9+
from codeflash.cli_cmds.console import apologize_and_exit, logger
1010
from codeflash.code_utils import env_utils
1111
from codeflash.code_utils.code_utils import exit_with_message, normalize_ignore_paths
1212
from codeflash.code_utils.config_parser import parse_config_file
@@ -234,8 +234,6 @@ def handle_optimize_all_arg_parsing(args: Namespace) -> Namespace:
234234
f"I couldn't find a git repository in the current directory. "
235235
f"I need a git repository to run {mode} and open PRs for optimizations. Exiting..."
236236
)
237-
from codeflash.cli_cmds.cli_common import apologize_and_exit
238-
239237
apologize_and_exit()
240238
git_remote = getattr(args, "git_remote", None)
241239
if not check_and_push_branch(git_repo, git_remote=git_remote):

0 commit comments

Comments
 (0)