Skip to content

Commit

Permalink
AIP-8098 ExitHandler doesn't notify on Workflow Error
Browse files Browse the repository at this point in the history
  • Loading branch information
talebzeghmi committed Feb 29, 2024
1 parent fcaad77 commit c845c99
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions metaflow/plugins/kfp/kfp_exit_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,22 @@ def send_sqs_message(queue_url: str, message_body: str, *, role_arn: str = None)
notify_on_success = get_env("METAFLOW_NOTIFY_ON_SUCCESS")

print(f"Flow completed with status={status}")
if notify_on_error and status == "Failed":
email_notify(notify_on_error)
elif notify_on_success and status == "Succeeded":
# AIP-8098 ExitHandler and Ops notification NOT called on Workflow.status == Error
# available statuses of Succeeded, Failed, Error
if notify_on_success and status == "Succeeded":
email_notify(notify_on_success)
elif notify_on_error:
email_notify(notify_on_error)
else:
print("No notification is necessary!")

# Send message to SQS if 'METAFLOW_SQS_URL_ON_ERROR' is set
metaflow_sqs_url_on_error = get_env("METAFLOW_SQS_URL_ON_ERROR")

if metaflow_sqs_url_on_error:
if status == "Failed":
if status == "Succeeded":
print("Workflow succeeded, thus no SQS message is sent to SQS!")
else:
message_body = sqs_message_json
metaflow_sqs_role_arn_on_error = get_env("METAFLOW_SQS_ROLE_ARN_ON_ERROR")
send_sqs_message(
Expand All @@ -160,8 +164,6 @@ def send_sqs_message(queue_url: str, message_body: str, *, role_arn: str = None)
role_arn=metaflow_sqs_role_arn_on_error,
)
print(f"message was sent to: {metaflow_sqs_url_on_error} successfully")
else:
print("Workflow succeeded, thus no SQS message is sent to SQS!")
else:
print("SQS is not configured!")

Expand Down

0 comments on commit c845c99

Please sign in to comment.