Setup slackker with Slack to report Keras model training

Siddhesh Gunjal
4 min readJan 14, 2023

--

Training our DL model is a time consuming process and watching it train is a time killer and it is addictive. We always find ourselves walking back and forth to computer screen to check the progress to only find that the current epoch is not finished.

All the time models are training, our brain usually works at 50% at most. To help you with this, I have introduced slackker.

slackker is a python package for monitoring your training in real-time on slack channel. It can send you update for your ML model training progress and send final report with graphs when the training finishes. So now you don’t have to sit in front of the machine all the time. You can quickly go and grab coffee ☕️ downstairs or run some errands and still keep tracking the progress while on the move.

slackker in action — Training progress notification on smart watch through slack

In this article we are gonna go through detailed explaination on how to setup slack with slackker to monitoring your ML training.

Let’s get slack ready for slackker

First of all we’ll have to create an app and install that app in our workspace. to create an app click on the link: https://api.slack.com/apps.

You’ll see below window upon openning the link. Click on “Create New App” button in top right corner

Click on the green “Create New App” button on the top right corner

Now a pop-up will open. Click on “From scratch” option.

Click on “From scratch” option

Now give a name of your choice to your app. Then select the workspace in which you want to deploy this app and then click on “Create App” button.

Please note that in future all the notifications from slackker will go through app and will be accessible only within this workspace, so select your workspace carefully.

Give name and selcet workspace for your app

Once the app is create, it can be directly installed to your workspace. BUT WAIT! Let’s first give all necessary permissions to your app. Permissions can be managed from your app page on browser. Select “OAuth & Permissions” from side menu on left side

Select OAuth & Permissions from side menu on left side

We must give below mention permission for slackker to work.

  1. chat:write
  2. chat:write.public
  3. files:read
  4. files:write

After adding all necessary permission it should look like this.

Permissions required for slackker to work

Now our app is ready to install to our workspace. Now head back to “Basic Information” tab from side menu and click on “Install to Workspace” button.

Click on “Install to Workspace” to install your app

You can now find your app automatically install in your workspace in slack under Apps section.

App install in Slack Workspace

Now you can integrate this app into any existing channel or create new channel to receive notification. To integrate this app to any channel just click on the description of the channel -> Go to Integrations tab -> Click on Add an App.

Integrate our app to any channel

Now we’re ready to use slack with slackker. Let’s head back to our code and setup slackker with keras.

Install slackker in your environment

pip install slackker

Now let’s import keras callback module from slackker:

from slackker.callbacks.keras import SlackUpdate

To Create an Object from SlackUpdate module. For this we need a Authentication token. This can be access from https://api.slack.com/apps/ page. Go to link -> select your app -> Go to OAuth & Permissions in side menu -> copy your Bot User OAuth Token. It should be in the following format.

xoxb-123234234235-123234234235-123234234235-adedce74748c3844747aed48499bb

We also need the channel ID in which we have integrated our app. It can be found from channel description in slack.

Copy/Paste both while creating a slackker object. Final code should look something like this:

# Slackker Checkpoint
slack_update = SlackUpdate(token="xoxb-123234234235-123234234235-adedce74748c3844747aed",
channel="A04AAB77ABC",
ModelName='Simple_NN',
export='png',
SendPlot=True)

We’re alomst done now! We just need to call this object inside the Keras Callbacks just like any other callback functions we normally use while model.fit() (e.g. ModelCheckpoint, TensorBoard, etc.) method. It should look something like below:

history = model.fit(x_train, 
y_train,
epochs = 10,
batch_size = 16,
verbose=1,
validation_data=(x_val,y_val),
callbacks=[checkpoints, slack_update])

Now start the training on that model you’ll see all the updates on your slack channel as the training progresses.

Report messages on slack channel from slackker callbacks

Hope this helped 🌟

Have anything in mind that can help become slackker better? or require any feature? Do visit the GitHub Repo for more details about contribution to the source code.

Would love to know your experience with slackker. Follow me & star the repo to get updates about the future releases of slackker.

--

--

Siddhesh Gunjal

ML Engineer | Creator of Slackker (PyPi pakage) | Former Adjunct Faculty @upGrad | Former Professor @BSE (Bombay stock exchange)