It takes hours to process machine learning at Kaggle competitions. .. If you have a high-spec VM, the monthly fee will be quite high, so please let us know in order to stop the VM or perform another process when the process is finished! Here's how to notify Slack of processing status!
Terminal
pip install slackweb
** Example of slack web installation on Jupyter Lab on GCP **
#slackweb module import
import slackweb
#Specifying Slack's Incoming Webhook
slack = slackweb.Slack(url="URL of Slack's Incoming Webhook") #Rewrite it to your own URL
#Send with comment
slack.notify(text="It's a test")
** Example on Jupyter Lab on GCP **
It's definitely coming in real time!
#Import of required module
import slackweb
import datetime
#Classify Slack notifications
class Slack_notice():
start = 0
def __init__(self):
self.slack = slackweb.Slack(url="URL of Slack's Incoming Webhook") #Rewrite it to your own URL
def begin(self):
self.start = datetime.datetime.now()
self.slack.notify(text='[Notice] ' + str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) + '\n Processing has started!')
def end(self):
elapsed_time = datetime.datetime.now() - self.start
self.slack.notify(text='[Notice] ' + str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) + '\n Processing is finished! \n Time required'+ str(elapsed_time) + 'is')
# Slack_notice class call
slack_notice = Slack_notice()
#Pre-execution notification
slack_notice.begin()
#The process you want to execute-------------------------------------------------------------------------
#This time, for the sake of clarity, I just printed every second.
from time import sleep
for num in range(10):
print(num)
sleep(1)
# -------------------------------------------------------------------------------------
#Pre-execution notification
slack_notice.end()
** Example on Jupyter Lab on GCP **
[Qiita] Post to slack with Python 3
[Qiita] Let's easily make a screen video to upload to Qiita with gif animation
Recommended Posts