Skip to content

notify-completion

Sends completion notifications for pipeline stages via SNS and optionally Slack.

Overview

Property Value
Trigger Step Functions / EventBridge / Direct
Runtime Python 3.11
Timeout 30 seconds
Memory 128 MB

Input Schema

{
    "notification_type": "RETRAINING_SUCCESS",
    "title": "Model Retraining Complete",
    "message": "PascalStrategy model has been retrained successfully",
    "model_name": "PascalStrategy",       # Optional
    "strategy_name": "PascalStrategy",    # Optional
    "details": {                          # Optional
        "duration_minutes": 45,
        "metrics": {"sharpe": 1.85}
    },
    "severity": "INFO"                    # INFO | WARNING | ERROR | CRITICAL
}

Notification Types: - RETRAINING_SUCCESS / RETRAINING_FAILED - BACKTEST_COMPLETE - DEPLOYMENT_SUCCESS / DEPLOYMENT_FAILED - DATA_COLLECTION - MODEL_PROMOTED - DRIFT_DETECTED - GENERIC

Output Schema

{
    "sent": true,
    "sns": true,
    "slack": true,
    "notification_type": "RETRAINING_SUCCESS"
}

Environment Variables

Variable Required Default Description
NOTIFICATION_STATE_TABLE No "tradai-notifications" Throttle state table
ENABLE_SLACK No "false" Enable Slack notifications
SLACK_WEBHOOK_URL No - Slack webhook URL
NOTIFICATION_THROTTLE_MINUTES No 5 Throttle window
ALERT_SNS_TOPIC_ARN Yes - SNS topic ARN
ENVIRONMENT No "dev" Environment name

Severity Levels

Severity Color (Slack) Throttled
INFO Green Yes
WARNING Yellow Yes
ERROR Red No
CRITICAL Purple No

Key Features

  • Throttles non-critical notifications (ERROR/CRITICAL bypass)
  • Color-coded severity in Slack
  • DynamoDB-backed throttling to prevent spam
  • 24-hour TTL on notification records

Slack Message Format

{
    "attachments": [{
        "color": "#36a64f",
        "title": "Model Retraining Complete",
        "text": "PascalStrategy model has been retrained successfully",
        "fields": [
            {"title": "Environment", "value": "prod", "short": true},
            {"title": "Model", "value": "PascalStrategy", "short": true}
        ],
        "footer": "TradAI Notifications",
        "ts": 1704067200
    }]
}

Step Functions Integration

{
  "NotifySuccess": {
    "Type": "Task",
    "Resource": "arn:aws:lambda:...:notify-completion",
    "Parameters": {
      "notification_type": "RETRAINING_SUCCESS",
      "title": "Retraining Complete",
      "message.$": "States.Format('Model {} retrained', $.model_name)",
      "model_name.$": "$.model_name",
      "severity": "INFO"
    },
    "End": true
  }
}
  • All pipeline Lambdas use this for notifications