Skip to content

Commit ddd997f

Browse files
authored
Merge branch 'main' into easier-benchmark
2 parents 609144f + cbd0c43 commit ddd997f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

codeflash/api/cfapi.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,16 @@ def mark_optimization_success(trace_id: str, *, is_optimization_found: bool) ->
261261
"""
262262
payload = {"trace_id": trace_id, "is_optimization_found": is_optimization_found}
263263
return make_cfapi_request(endpoint="/mark-as-success", method="POST", payload=payload)
264+
265+
266+
def send_completion_email() -> Response:
267+
"""Send an email notification when codeflash --all completes."""
268+
try:
269+
owner, repo = get_repo_owner_and_name()
270+
except Exception as e:
271+
sentry_sdk.capture_exception(e)
272+
response = requests.Response()
273+
response.status_code = 500
274+
return response
275+
payload = {"owner": owner, "repo": repo}
276+
return make_cfapi_request(endpoint="/send-completion-email", method="POST", payload=payload)

codeflash/optimization/optimizer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import TYPE_CHECKING
1010

1111
from codeflash.api.aiservice import AiServiceClient, LocalAiServiceClient
12+
from codeflash.api.cfapi import send_completion_email
1213
from codeflash.cli_cmds.console import console, logger, progress_bar
1314
from codeflash.code_utils import env_utils
1415
from codeflash.code_utils.code_utils import cleanup_paths, get_run_tmp_file
@@ -343,6 +344,11 @@ def run(self) -> None:
343344
logger.info("❌ No optimizations found.")
344345
elif self.args.all:
345346
logger.info("✨ All functions have been optimized! ✨")
347+
response = send_completion_email() # TODO: Include more details in the email
348+
if response.ok:
349+
logger.info("✅ Completion email sent successfully.")
350+
else:
351+
logger.warning("⚠️ Failed to send completion email. Status")
346352
finally:
347353
if function_optimizer:
348354
function_optimizer.cleanup_generated_files()

0 commit comments

Comments
 (0)