gnomad.utils.slack
Slack API client. |
|
|
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 tofile (
Optional
[str
]) – Path of file to uploadcontent (
Optional
[str
]) – File content to uploadfilename (
str
) – Filename of filefiletype (
str
) – File type identifiercomment (
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 tomessage (
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 tokento (
Union
[str
,Iterable
[str
]]) – Channel(s) (prefixed with ‘#’) and/or user(s) (prefixed with ‘@’) to send notification to