Skip to content

Commit 281c8a8

Browse files
aseembits93Saga4
authored andcommitted
python side done, todo backend js/ts
1 parent 86e2570 commit 281c8a8

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

codeflash/api/cfapi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def suggest_changes(
130130
coverage_message: str,
131131
replay_tests: str = "",
132132
concolic_tests: str = "",
133+
optimization_impact: str = "",
133134
) -> Response:
134135
"""Suggest changes to a pull request.
135136
@@ -155,6 +156,7 @@ def suggest_changes(
155156
"coverage_message": coverage_message,
156157
"replayTests": replay_tests,
157158
"concolicTests": concolic_tests,
159+
"optimization_impact": optimization_impact,
158160
}
159161
return make_cfapi_request(endpoint="/suggest-pr-changes", method="POST", payload=payload)
160162

@@ -171,6 +173,7 @@ def create_pr(
171173
coverage_message: str,
172174
replay_tests: str = "",
173175
concolic_tests: str = "",
176+
optimization_impact: str = "",
174177
) -> Response:
175178
"""Create a pull request, targeting the specified branch. (usually 'main').
176179
@@ -195,6 +198,7 @@ def create_pr(
195198
"coverage_message": coverage_message,
196199
"replayTests": replay_tests,
197200
"concolicTests": concolic_tests,
201+
"optimization_impact": optimization_impact,
198202
}
199203
return make_cfapi_request(endpoint="/create-pr", method="POST", payload=payload)
200204

@@ -210,6 +214,7 @@ def create_staging(
210214
replay_tests: str,
211215
concolic_tests: str,
212216
root_dir: Path,
217+
optimization_impact: str = "",
213218
) -> Response:
214219
"""Create a staging pull request, targeting the specified branch. (usually 'staging').
215220
@@ -250,6 +255,7 @@ def create_staging(
250255
"coverage_message": coverage_message,
251256
"replayTests": replay_tests,
252257
"concolicTests": concolic_tests,
258+
"optimization_impact": optimization_impact,
253259
}
254260

255261
return make_cfapi_request(endpoint="/create-staging", method="POST", payload=payload)

codeflash/optimization/function_optimizer.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,14 +1461,12 @@ def process_review(
14611461

14621462
if raise_pr or staging_review:
14631463
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}")
1464+
opt_impact_response = ""
1465+
try:
1466+
opt_impact_response = self.aiservice_client.get_optimization_impact(**data)
1467+
except Exception as e:
1468+
logger.debug(f"optimization impact response failed, investigate {e}")
1469+
data["optimization_impact"] = opt_impact_response
14721470
if raise_pr and not staging_review:
14731471
data["git_remote"] = self.args.git_remote
14741472
check_create_pr(**data)

codeflash/result/create_pr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def check_create_pr(
185185
concolic_tests: str,
186186
root_dir: Path,
187187
git_remote: Optional[str] = None,
188+
optimization_impact: str = "",
188189
) -> None:
189190
pr_number: Optional[int] = env_utils.get_pr_number()
190191
git_repo = git.Repo(search_parent_directories=True)
@@ -226,6 +227,7 @@ def check_create_pr(
226227
coverage_message=coverage_message,
227228
replay_tests=replay_tests,
228229
concolic_tests=concolic_tests,
230+
optimization_impact=optimization_impact,
229231
)
230232
if response.ok:
231233
logger.info(f"Suggestions were successfully made to PR #{pr_number}")
@@ -275,6 +277,7 @@ def check_create_pr(
275277
coverage_message=coverage_message,
276278
replay_tests=replay_tests,
277279
concolic_tests=concolic_tests,
280+
optimization_impact=optimization_impact,
278281
)
279282
if response.ok:
280283
pr_id = response.text

0 commit comments

Comments
 (0)