Skip to content

Commit 33bcab6

Browse files
committed
merge conflicts
1 parent ca313a1 commit 33bcab6

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

codeflash/api/aiservice.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,13 @@ def get_optimization_impact(
577577
]
578578
)
579579
code_diff = f"```diff\n{diff_str}\n```"
580+
# TODO get complexity metrics and fn call heuristics -> constructing a complete static call graph can be expensive for really large repos
581+
# grep function name in codebase -> ast parser to get no of calls and no of calls in loop -> radon lib to get complexity metrics -> send as additional context to the AI service
582+
# metric 1 -> call count - how many times the function is called in the codebase
583+
# metric 2 -> loop call count - how many times the function is called in a loop in the codebase
584+
# metric 3 -> presence of decorators like @profile, @cache -> this means the owner of the repo cares about the performance of this function
585+
# metric 4 -> cyclomatic complexity (https://en.wikipedia.org/wiki/Cyclomatic_complexity)
586+
# metric 5 (for future) -> halstead complexity (https://en.wikipedia.org/wiki/Halstead_complexity_measures)
580587
logger.info("!lsp|Computing Optimization Impact…")
581588
payload = {
582589
"code_diff": code_diff,

codeflash/optimization/function_optimizer.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from codeflash.benchmarking.utils import process_benchmark_data
2525
from codeflash.cli_cmds.console import code_print, console, logger, lsp_log, progress_bar
2626
from codeflash.code_utils import env_utils
27-
from codeflash.code_utils.code_extractor import get_opt_impact_metrics
2827
from codeflash.code_utils.code_replacer import (
2928
add_custom_marker_to_all_tests,
3029
modify_autouse_fixture,
@@ -1462,19 +1461,14 @@ def process_review(
14621461

14631462
if raise_pr or staging_review:
14641463
data["root_dir"] = git_root_dir()
1465-
opt_impact_response = ""
1466-
try:
1467-
opt_impact_response = self.aiservice_client.get_optimization_impact(**data)
1468-
except Exception as e:
1469-
logger.debug(f"optimization impact response failed, investigate {e}")
1470-
data["optimization_impact"] = opt_impact_response
1471-
data["impact_metrics"] = get_opt_impact_metrics(
1472-
self.function_to_optimize_source_code,
1473-
self.function_to_optimize.file_path,
1474-
self.function_to_optimize.qualified_name,
1475-
self.project_root,
1476-
self.test_cfg.tests_root,
1477-
)
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}")
14781472
if raise_pr and not staging_review:
14791473
data["git_remote"] = self.args.git_remote
14801474
check_create_pr(**data)

0 commit comments

Comments
 (0)