less than 1 minute read

There is a Python library called knockknock that allows you to get a notification when your training is complete or when it crashes during the process. All it takes to get a notification is two additional lines of code.

To send an email, simply insert a decorator @email_sender() above your … function:

from knockknock import email_sender


@email_sender(
    recipient_emails=["youremail@gmail.com"], sender_email="anotheremail@gmail.com"
)
def main():
    ...

To send a notification to your Slack:

from knockknock import slack_sender


@slack_sender(
    webhook_url="webhook_url_to_your_slack_room",
    channel="<your_favorite_slack_channel>",
    user_mentions=["<your_slack_id>"],
)
def main():
    ...

Via Khuyen Tran.

Comments