You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by ianbenlolo June 25, 2024
Hey,
This may be a duplicate but I have not found this exact question so apologies in advance.
I have a pipeline that i would like to add an exithandler that runs some cleanup code and sends an email.
This is how I've done it so far:
@dsl.component
def dummy_print_action(action: str):
print(action)
@dsl.pipeline
def send_failure_email(
email_recipients
):
# this was a hack required to use the VertexNotificationEmailOp component only when the pipeline fails
exit_handler_task = vertex_notification_email.VertexNotificationEmailOp(recipients=email_recipients)
with dsl.ExitHandler(exit_task=exit_handler_task, name="Dummy exit handler"):
_ = dummy_print_action(
action=f"Failed pipeline, sending notification email to {email_recipients}"
)
@dsl.pipeline
def exit_handler(
email_recipients: List[str],
status: dsl.PipelineTaskFinalStatus,
):
get_run_state_task = get_run_state(status=status)
with dsl.Condition(
get_run_state_task.output != "SUCCEEDED", name="state != SUCCEEDED"
):
_ = cleanup()
_ = send_failure_email(
email_recipients=email_recipients,
)
@dsl.pipeline
def pipeline(args):
exit_handler_task = exit_handler(email_recipients=["[email protected]"],)
with dsl.ExitHandler(exit_task=exit_handler_task, name="Pipeline"):
pipeline_stuff()
But this is a little cumbersome. I was wondering if there is an easier way to do this?
Furthermore, i'd like to send a slack notification on failure and haven't found a way to other than the link but I'm unsure how to set up the necessary image.
Thank you!
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Discussed in #10955
Originally posted by ianbenlolo June 25, 2024
Hey,
This may be a duplicate but I have not found this exact question so apologies in advance.
I have a pipeline that i would like to add an exithandler that runs some cleanup code and sends an email.
This is how I've done it so far:
But this is a little cumbersome. I was wondering if there is an easier way to do this?
Furthermore, i'd like to send a slack notification on failure and haven't found a way to other than the link but I'm unsure how to set up the necessary image.
Thank you!
The text was updated successfully, but these errors were encountered: