Skip to content
Merged
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
26 changes: 20 additions & 6 deletions codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,9 @@ def process_review(
"concolic_tests": concolic_tests,
}

if not self.args.no_pr and not self.args.staging_review:
raise_pr = not self.args.no_pr

if raise_pr and not self.args.staging_review:
data["git_remote"] = self.args.git_remote
check_create_pr(**data)
elif self.args.staging_review:
Expand All @@ -1252,12 +1254,24 @@ def process_review(
trace_id=self.function_trace_id, is_optimization_found=best_optimization is not None
)

if ((not self.args.no_pr) or not self.args.staging_review) and (
self.args.all or env_utils.get_pr_number() or (self.args.file and not self.args.function)
if raise_pr and (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could have just merged the condition (self.args.staging_review:) in same conditional statement here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I kept them separated for readability

self.args.all
or env_utils.get_pr_number()
or self.args.replay_test
or (self.args.file and not self.args.function)
):
self.write_code_and_helpers(
self.function_to_optimize_source_code, original_helper_code, self.function_to_optimize.file_path
)
self.revert_code_and_helpers(original_helper_code)
return

if self.args.staging_review:
# always revert code and helpers when staging review
self.revert_code_and_helpers(original_helper_code)
return

def revert_code_and_helpers(self, original_helper_code: dict[Path, str]) -> None:
self.write_code_and_helpers(
self.function_to_optimize_source_code, original_helper_code, self.function_to_optimize.file_path
)

def establish_original_code_baseline(
self,
Expand Down
Loading