Skip to content

[Chore] Notify via Email When codeflash --all Completes #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 23, 2025
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
13 changes: 13 additions & 0 deletions codeflash/api/cfapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,16 @@ 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)
response = requests.Response()
response.status_code = 500
return response
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() # TODO: Include more details in the email
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