A Metaflow plugin that sends detailed error notifications to Slack when a flow step fails. This helps teams monitor their Metaflow pipelines and quickly respond to failures.
- Automatic Slack notifications on step failures
- Detailed error information including:
- Flow details
- Retry count and limits
- Flow parameters
- Input data
- Full stack trace
- Easy integration with existing Metaflow pipelines
pip install metaflow-slack-notifierSet the following environment variables:
export METAFLOW_SLACK_APP_TOKEN="xoxb-your-token"
export METAFLOW_SLACK_CHANNEL="your-channel"or use @environment decorator:
@environment(vars={"METAFLOW_SLACK_APP_TOKEN": "xoxb-your-token", "METAFLOW_SLACK_CHANNEL": "your-channel"})
@slack()
@step
def some_step(self):
# write your code
print("end")Add the @slack decorator to any step that you want to monitor.
from metaflow import FlowSpec, slack, step
import os
token = os.getenv("METAFLOW_SLACK_APP_TOKEN")
channel = os.getenv("METAFLOW_SLACK_CHANNEL")
class MyFlow(FlowSpec):
@step
def start(self):
print("start")
self.next(self.end)
@slack(token=token, channel=channel)
@step
def end(self):
# This will trigger a Slack notification due to ZeroDivisionError
1 / 0
print("end")
if __name__ == "__main__":
MyFlow()When the step fails, you'll receive a notification in your Slack channel with the error details.
- Create a new Slack App in your workspace
- Enable the following OAuth scopes:
- chat:write
- chat:write.public (if sending to public channels)
- Install the app to your workspace
- Copy the Bot User OAuth Token (starts with xoxb-)
MIT License