gnomad.utils.slack

gnomad.utils.slack.SlackClient(token)

Slack API client.

gnomad.utils.slack.slack_notifications(token, to)

Send a Slack notification after some code runs.

class gnomad.utils.slack.SlackClient(token)[source]

Slack API client.

Parameters:

token (str) – Slack API token

send_file(to, file=None, content=None, filename='data.txt', filetype='text', comment=None)[source]

Send a file to Slack channel(s) and/or user(s).

Parameters:
  • to (Union[str, Iterable[str]]) – Channel(s) (prefixed with ‘#’) and/or user(s) (prefixed with ‘@’) to send message to

  • file (Optional[str]) – Path of file to upload

  • content (Optional[str]) – File content to upload

  • filename (str) – Filename of file

  • filetype (str) – File type identifier

  • comment (Optional[str]) – Text for message sharing file

send_message(to, message, icon_emoji=None)[source]

Send a message to Slack channel(s) and/or user(s).

Parameters:
  • to (Union[str, Iterable[str]]) – Channel(s) (prefixed with ‘#’) and/or user(s) (prefixed with ‘@’) to send message to

  • message (str) – Message content (long messages will be converted to snippets)

  • icon_emoji (Optional[str]) – Emoji to use as icon for message

gnomad.utils.slack.slack_notifications(token, to)[source]

Send a Slack notification after some code runs.

If the wrapped code block raises an exception, the notification will include the exception and stack trace.

Example usage:

with slack_notifications(token, "@username"):
    run_analysis()
Parameters:
  • token (str) – Slack API token

  • to (Union[str, Iterable[str]]) – Channel(s) (prefixed with ‘#’) and/or user(s) (prefixed with ‘@’) to send notification to