SlackReporter
Note
The SlackReporter
is still in development and lacks some features, such as specifying the token via environment variables, file attachments, detailed reporting, and reporting of the in-run capsule.
The SlackReporter
reports the capsule to a Slack channel. Capsules with the same run name will be reported to the same thread.
It can be created using the capsula.SlackReporter.builder
method or the capsula.SlackReporter.__init__
method.
capsula.SlackReporter.builder
classmethod
builder(
*, channel: str, token: str
) -> Callable[[CapsuleParams], SlackReporter]
Source code in capsula/_reporter/_slack.py
capsula.SlackReporter.__init__
Configuration example
Via capsula.toml
[pre-run]
reporters = [{ type = "SlackReporter", channel = "<channel>", token = "<token>" }]
[in-run] # the reporting of an in-run capsule is not yet supported
reporters = [{ type = "SlackReporter", channel = "<channel>", token = "<token>" }]
[post-run]
reporters = [{ type = "SlackReporter", channel = "<channel>", token = "<token>" }]
Via @capsula.reporter
decorator
import capsula
@capsula.run()
@capsula.reporter(capsula.SlackReporter.builder(channel="<channel>", token="<token>"), mode="all")
def func(): ...
Output
It will send a simple message to the specified Slack channel.
For example, for the pre-run capsule:
For the post-run capsule: