Skip to content

refactor!: configure email alerts via notification channels - #2

Merged
oliverm91 merged 10 commits into
mainfrom
feature/notification-channels
Jun 14, 2026
Merged

oliverm91 merged 10 commits into
mainfrom
feature/notification-channels

Conversation

@oliverm91

Copy link
Copy Markdown
Owner

What

  • Introduce NotificationChannel, an abstract base class for delivering task log/failure notifications. New channels (Slack, Discord, Telegram, etc.) can be added later by subclassing it, with no changes to Task.
  • Wrap the existing destinations as channels: an internal _FileChannel (per-task log file) and a public EmailChannel (HTML email alert on logging.ERROR+).
  • Breaking change: Task.__init__ no longer accepts smtp_config or email_style. log_path remains the only logging-related argument (converted internally to a _FileChannel). All other notification configuration — including email — is passed via the new channels: list[NotificationChannel] | None = None parameter (positioned after dependencies, before timeout).
  • The traced-vars frame filter (_frame_filter) is now sourced from a frame_filter property on each channel (e.g. EmailChannel derives it from style.traced_vars_frame_filter), defaulting to None if no channel provides one.

Why:

Email and file logging were hardcoded into Task, making it awkward to add new alerting destinations. This refactor establishes a clean extension point for future channels while keeping the per-task file log and HTML email alert behavior unchanged for users who migrate to channels=[EmailChannel(...)].

Migration:

Before

Task(name, log_path, func, smtp_config=smtp, email_style=style)

After

from processes import EmailChannel
Task(name, log_path, func, channels=[EmailChannel(smtp, style)])

Type of change

  • feat — new feature
  • fix — bug fix
  • refactor — no behavior change
  • docs — documentation only
  • test — tests only
  • chore / ci / build

…onfig

Remove smtp_config and email_style from Task.__init__. log_path remains
the only logging-related argument and is converted internally into a
file channel; email alerts and any other notification channels are now
configured via the channels parameter (list[NotificationChannel]),
placed after dependencies and before timeout. EmailChannel is exported
publicly as the way to attach email alerts.

BREAKING CHANGE: Task no longer accepts smtp_config or email_style.
Pass channels=[EmailChannel(smtp_config, style)] instead.
typing.Self (used in process.py) is only available from Python 3.11.
The exact round-to-4 check left no margin for runner overhead, causing
intermittent failures on loaded CI runners.
@oliverm91 oliverm91 changed the title Notification channel abstraction for task alerts refactor!: configure email alerts via notification channels Jun 14, 2026
Inline comments after each type were being treated as part of the
allowed type strings, so no PR title type ever matched.
@oliverm91
oliverm91 merged commit 14cc8e1 into main Jun 14, 2026
16 checks passed
@oliverm91
oliverm91 deleted the feature/notification-channels branch June 20, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant