class_docstr: Create a monitoring service that alerts on Task failures / completion in a Slack channel
class_docstr_tok: ["Create","a","monitoring","service","that","alerts","on","Task","failures","\/","completion","in","a","Slack","channel"]
docstr: Check we have the correct credentials for the slack channel
docstr_tok: ["Check","we","have","the","correct","credentials","for","the","slack","channel"]
code: def check_credentials(self):
      # type: () -> ()
      """
      Check we have the correct credentials for the slack channel
      """
      self.slack_client.api_test()
  
      # Find channel ID
      channels = []
      cursor = None
      while True:
          response = self.slack_client.conversations_list(cursor=cursor)
          channels.extend(response.data["channels"])
          cursor = response.data["response_metadata"].get("next_cursor")
          if not cursor:
              break
      channel_id = [
          channel_info.get("id")
          for channel_info in channels
          if channel_info.get("name") == self.channel
      ]
      if not channel_id:
          raise ValueError(
              "Error: Could not locate channel name '{}'".format(
                  self.channel
              )
          )
  
      # test bot permission (join channel)
      self._channel_id = channel_id[0]
      self.slack_client.conversations_join(channel=self._channel_id)
  
file_path: clearml/examples/services/monitoring/slack_alerts.py
imports: import argparse
  import os
  from pathlib import Path
  from time import sleep
  from typing import Optional, Callable, List, Union
  from slack_sdk import WebClient
  from slack_sdk.errors import SlackApiError
  from clearml import Task
  from clearml.automation.monitor import Monitor
label_desc: Use image node_id 2 for calling the SlackMonitor obj's underlying member method code with example usage: obj.check_credentials() without return types