Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions codeflash/api/cfapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,14 @@ def mark_optimization_success(trace_id: str, *, is_optimization_found: bool) ->
"""
payload = {"trace_id": trace_id, "is_optimization_found": is_optimization_found}
return make_cfapi_request(endpoint="/mark-as-success", method="POST", payload=payload)


def send_completion_email() -> Response:
"""Send an email notification when codeflash --all completes."""
try:
owner, repo = get_repo_owner_and_name()
except Exception as e:
sentry_sdk.capture_exception(e)
return {}
payload = {"owner": owner, "repo": repo}
return make_cfapi_request(endpoint="/send-completion-email", method="POST", payload=payload)
6 changes: 6 additions & 0 deletions codeflash/optimization/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import TYPE_CHECKING

from codeflash.api.aiservice import AiServiceClient, LocalAiServiceClient
from codeflash.api.cfapi import send_completion_email
from codeflash.cli_cmds.console import console, logger, progress_bar
from codeflash.code_utils import env_utils
from codeflash.code_utils.code_utils import cleanup_paths, get_run_tmp_file
Expand Down Expand Up @@ -342,6 +343,11 @@ def run(self) -> None:
logger.info("❌ No optimizations found.")
elif self.args.all:
logger.info("✨ All functions have been optimized! ✨")
response = send_completion_email()
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: Aren't we sending the mail with some details on optimization?
Or is it planned in TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is planned as a TODO

Copy link
Contributor

Choose a reason for hiding this comment

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

So Can you please add it as a comment for TODO here.

if response.ok:
logger.info("✅ Completion email sent successfully.")
else:
logger.warning("⚠️ Failed to send completion email. Status")
finally:
if function_optimizer:
function_optimizer.cleanup_generated_files()
Expand Down
Loading