Created
March 7, 2019 05:18
-
-
Save aczzdx/875d42fa21bd214909f9d98a1250b5c4 to your computer and use it in GitHub Desktop.
Simple logger for sending updates to Slack using incoming webhook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Change the following url as the webhook requested from the Slack App | |
SLACK_WEBHOOK = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" | |
import requests | |
def slack_msg(text): | |
return requests.post(SLACK_MSG_HOOK, json={"text":text}) | |
# a sample to send | |
epoch = 1 | |
loss = 1234.567891 | |
acc = 0.9874245 | |
slack_msg("[Epoch {}]\tloss:{:.4f}\tacc:{:.4f}".format(epoch, loss, acc)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment