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: Create a Slack Monitoring object.
  It will alert on any Task/Experiment that failed or completed
  
  :param slack_api_token: Slack bot API Token. Token should start with "xoxb-"
  :param channel: Name of the channel to post alerts to
  :param message_prefix: optional message prefix to add before any message posted
      For example: message_prefix="Hey <!here>,"
  :param filters: An optional collection of callables that will be passed a Task
      object and return True/False if it should be filtered away
docstr_tok: ["Create","a","Slack","Monitoring","object",".","It","will","alert","on","any","Task\/Experiment","that","failed","or","completed",":","param","slack_api_token",":","Slack","bot","API","Token",".","Token","should","start","with","``","xoxb-","''",":","param","channel",":","Name","of","the","channel","to","post","alerts","to",":","param","message_prefix",":","optional","message","prefix","to","add","before","any","message","posted","For","example",":","message_prefix=","''","Hey","<","!","here",">",",","''",":","param","filters",":","An","optional","collection","of","callables","that","will","be","passed","a","Task","object","and","return","True\/False","if","it","should","be","filtered","away"]
code: def __init__(
      self, slack_api_token, channel, message_prefix=None, filters=None
  ):
      # type: (str, str, Optional[str], Optional[List[Callable[[Task], bool]]]) -> ()
      """
      Create a Slack Monitoring object.
      It will alert on any Task/Experiment that failed or completed
  
      :param slack_api_token: Slack bot API Token. Token should start with "xoxb-"
      :param channel: Name of the channel to post alerts to
      :param message_prefix: optional message prefix to add before any message posted
          For example: message_prefix="Hey <!here>,"
      :param filters: An optional collection of callables that will be passed a Task
          object and return True/False if it should be filtered away
      """
      super(SlackMonitor, self).__init__()
      self.channel = "{}".format(
          channel[1:] if channel[0] == "#" else channel
      )
      self.slack_client = WebClient(token=slack_api_token)
      self.min_num_iterations = 0
      self.filters = filters or list()
      self.status_alerts = [
          "failed",
      ]
      self.include_manual_experiments = False
      self.include_archived = False
      self.verbose = False
      self._channel_id = None
      self._message_prefix = (
          "{} ".format(message_prefix) if message_prefix else ""
      )
      self.check_credentials()
  
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 1 to create a new SlackMonitor object from inherited base classes: Monitor with example: obj = SlackMonitor(slack_api_token, channel, message_prefix, filters)