|
12 | 12 | from pathlib import Path |
13 | 13 | from typing import TYPE_CHECKING |
14 | 14 |
|
15 | | -import isort |
16 | 15 | import libcst as cst |
17 | 16 | from rich.console import Group |
18 | 17 | from rich.panel import Panel |
19 | 18 | from rich.syntax import Syntax |
20 | 19 | from rich.tree import Tree |
21 | 20 |
|
22 | 21 | from codeflash.api.aiservice import AiServiceClient, AIServiceRefinerRequest, LocalAiServiceClient |
23 | | -from codeflash.api.cfapi import add_code_context_hash, create_staging, mark_optimization_success |
| 22 | +from codeflash.api.cfapi import CFAPI_BASE_URL, add_code_context_hash, create_staging, mark_optimization_success |
24 | 23 | from codeflash.benchmarking.utils import process_benchmark_data |
25 | 24 | from codeflash.cli_cmds.console import code_print, console, logger, lsp_log, progress_bar |
26 | 25 | from codeflash.code_utils import env_utils |
@@ -900,7 +899,7 @@ def reformat_code_and_helpers( |
900 | 899 | optimized_context: CodeStringsMarkdown, |
901 | 900 | ) -> tuple[str, dict[Path, str]]: |
902 | 901 | should_sort_imports = not self.args.disable_imports_sorting |
903 | | - if should_sort_imports and isort.code(original_code) != original_code: |
| 902 | + if should_sort_imports and sort_imports(code=original_code) != original_code: |
904 | 903 | should_sort_imports = False |
905 | 904 |
|
906 | 905 | optimized_code = "" |
@@ -1461,21 +1460,19 @@ def process_review( |
1461 | 1460 |
|
1462 | 1461 | if raise_pr or staging_review: |
1463 | 1462 | data["root_dir"] = git_root_dir() |
1464 | | - # try: |
1465 | | - # # modify argument of staging vs pr based on the impact |
1466 | | - # opt_impact_response = self.aiservice_client.get_optimization_impact(**data) |
1467 | | - # if opt_impact_response == "low": |
1468 | | - # raise_pr = False |
1469 | | - # staging_review = True |
1470 | | - # except Exception as e: |
1471 | | - # logger.debug(f"optimization impact response failed, investigate {e}") |
| 1463 | + opt_impact_response = "" |
| 1464 | + try: |
| 1465 | + opt_impact_response = self.aiservice_client.get_optimization_impact(**data) |
| 1466 | + except Exception as e: |
| 1467 | + logger.debug(f"optimization impact response failed, investigate {e}") |
| 1468 | + data["optimization_impact"] = opt_impact_response |
1472 | 1469 | if raise_pr and not staging_review: |
1473 | 1470 | data["git_remote"] = self.args.git_remote |
1474 | 1471 | check_create_pr(**data) |
1475 | 1472 | elif staging_review: |
1476 | 1473 | response = create_staging(**data) |
1477 | 1474 | if response.status_code == 200: |
1478 | | - staging_url = f"https://app.codeflash.ai/review-optimizations/{self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id}" |
| 1475 | + staging_url = f"{CFAPI_BASE_URL}/review-optimizations/{self.function_trace_id[:-4] + exp_type if self.experiment_id else self.function_trace_id}" |
1479 | 1476 | console.print( |
1480 | 1477 | Panel( |
1481 | 1478 | f"[bold green]✅ Staging created:[/bold green]\n[link={staging_url}]{staging_url}[/link]", |
|
0 commit comments