Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def get_new_explanation( # noqa: D417
optimized_throughput: str | None = None,
throughput_improvement: str | None = None,
function_references: str | None = None,
codeflash_version: str = codeflash_version,
) -> str:
"""Optimize the given python code for performance by making a request to the Django endpoint.

Expand All @@ -330,6 +331,7 @@ def get_new_explanation( # noqa: D417
- original_throughput: str | None - throughput for the baseline code (operations per second)
- optimized_throughput: str | None - throughput for the optimized code (operations per second)
- throughput_improvement: str | None - throughput improvement percentage
- current codeflash version
- function_references: str | None - where the function is called in the codebase

Returns
Expand All @@ -354,6 +356,7 @@ def get_new_explanation( # noqa: D417
"optimized_throughput": optimized_throughput,
"throughput_improvement": throughput_improvement,
"function_references": function_references,
"codeflash_version": codeflash_version,
}
logger.info("loading|Generating explanation")
console.rule()
Expand Down Expand Up @@ -605,6 +608,7 @@ def get_optimization_review(
"benchmark_details": explanation.benchmark_details if explanation.benchmark_details else None,
"optimized_runtime": humanize_runtime(explanation.best_runtime_ns),
"original_runtime": humanize_runtime(explanation.original_runtime_ns),
"codeflash_version": codeflash_version,
"calling_fn_details": calling_fn_details,
"python_version": platform.python_version(),
}
Expand Down
10 changes: 6 additions & 4 deletions codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,11 +1411,13 @@ def process_review(
generated_tests, original_runtime_by_test, optimized_runtime_by_test, self.test_cfg.tests_project_rootdir
)

generated_tests_str = "\n#------------------------------------------------\n".join(
[test.generated_original_test_source for test in generated_tests.generated_tests]
)
generated_tests_str = ""
for test in generated_tests.generated_tests:
generated_tests_str += f"```python\n{test.generated_original_test_source}\n```"
generated_tests_str += "\n\n"

if concolic_test_str:
generated_tests_str += "\n#------------------------------------------------\n" + concolic_test_str
generated_tests_str += f"```python\n{concolic_test_str}\n```\n\n"

existing_tests, replay_tests, concolic_tests = existing_tests_source_for(
self.function_to_optimize.qualified_name_with_modules_from_root(self.project_root),
Expand Down
Loading