-
Notifications
You must be signed in to change notification settings - Fork 11
Notification docs #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Notification docs #886
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -279,6 +279,167 @@ You can attach multiple triggers to a single task by providing a list of trigger | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| You can mix and match trigger types, combining predefined triggers with those that use `flyte.Cron`, and `flyte.FixedRate` automations (see below for explanations of these concepts). | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Notifications | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| You can attach notifications to a trigger using the `notifications` parameter of `flyte.Trigger`. | ||||||||||||||||||||||||||||||
| Notifications fire when a triggered run reaches a terminal execution phase. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||
| import flyte | ||||||||||||||||||||||||||||||
| from flyte import notify | ||||||||||||||||||||||||||||||
| from flyte.models import ActionPhase | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| env = flyte.TaskEnvironment(name="my_task_env") | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| trigger_with_notifications = flyte.Trigger( | ||||||||||||||||||||||||||||||
| name="daily_report", | ||||||||||||||||||||||||||||||
| automation=flyte.Cron("0 9 * * 1-5"), | ||||||||||||||||||||||||||||||
| notifications=( | ||||||||||||||||||||||||||||||
| notify.Slack( | ||||||||||||||||||||||||||||||
| on_phase=ActionPhase.FAILED, | ||||||||||||||||||||||||||||||
| webhook_url="https://hooks.slack.com/services/YOUR/WEBHOOK/URL", | ||||||||||||||||||||||||||||||
| message="Run {{.Run.Name}} failed with: {{.Error}}", | ||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||
| notify.Email( | ||||||||||||||||||||||||||||||
| on_phase=ActionPhase.SUCCEEDED, | ||||||||||||||||||||||||||||||
| recipients=["oncall@example.com"], | ||||||||||||||||||||||||||||||
| subject="Run {{.Run.Name}} succeeded", | ||||||||||||||||||||||||||||||
| body="Run: {{.Run.Name}}", | ||||||||||||||||||||||||||||||
|
Comment on lines
+301
to
+307
|
||||||||||||||||||||||||||||||
| message="Run {{.Run.Name}} failed with: {{.Error}}", | |
| ), | |
| notify.Email( | |
| on_phase=ActionPhase.SUCCEEDED, | |
| recipients=["oncall@example.com"], | |
| subject="Run {{.Run.Name}} succeeded", | |
| body="Run: {{.Run.Name}}", | |
| message="Run {run.name} failed with: {run.error}", | |
| ), | |
| notify.Email( | |
| on_phase=ActionPhase.SUCCEEDED, | |
| recipients=["oncall@example.com"], | |
| subject="Run {run.name} succeeded", | |
| body="Run: {run.name}", |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template variable syntax and names here (e.g., {{.Run.Name}}, {{.Error}}) don’t match the Flyte Notifications API reference in this repo, which documents Python-format placeholders like {run.name}, {run.error}, {run.url}, {project}, {domain} (see content/api-reference/flyte-sdk/packages/flyte.notify/_index.md). As written, users will likely get literal {{...}} text in delivered notifications. Please align the variable table (and the examples in this section) with the documented placeholder format/keys.
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the template variable description: “whan” → “when”.
| | `{{.Error}}` | Error message when failed or abort reason whan aborted | | |
| | `{{.Error}}` | Error message when failed or abort reason when aborted | |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,144 @@ | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
| title: Run with notifications | ||||||||||||||||||||||||||||||
| weight: 11 | ||||||||||||||||||||||||||||||
| variants: +flyte +union | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Run with notifications | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| You can attach notifications to a single run by passing them to `flyte.with_runcontext()`. | ||||||||||||||||||||||||||||||
| Notifications fire when the run reaches the terminal execution phase — no trigger or persistent deployment is required. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```python | ||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||
| import flyte | ||||||||||||||||||||||||||||||
| from flyte import notify | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| from flyte import notify | |
| import flyte.notify as notify |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example uses {{.Run.Name}} / {{.Error}} placeholders, but the Flyte Notifications API reference in this repo shows {run.name} / {run.error} placeholders for notification message templating. Please update the example strings so they match the real template syntax.
| message="Run {{.Run.Name}} succeeded.", | |
| ), | |
| notify.Email( | |
| on_phase=ActionPhase.FAILED, | |
| recipients=[NOTIFICATION_EMAIL], | |
| subject="ALERT: Run {{.Run.Name}} failed", | |
| body="Run: {{.Run.Name}}\nError: {{.Error}}", | |
| message="Run {run.name} succeeded.", | |
| ), | |
| notify.Email( | |
| on_phase=ActionPhase.FAILED, | |
| recipients=[NOTIFICATION_EMAIL], | |
| subject="ALERT: Run {run.name} failed", | |
| body="Run: {run.name}\nError: {run.error}", |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line says “All notification types from flyte.notify are supported” but the flyte.notify module also documents types like NamedRule in the API reference. Either include all supported types (including whether NamedRule is supported here) or reword this to avoid an exhaustive claim (e.g., “Common notification types include ...”).
| Pass a single notification or a tuple of notifications. All notification types from `flyte.notify` are supported: `Slack`, `Email`, `Teams`, `Webhook`, and `NamedDelivery`. | |
| Pass a single notification or a tuple of notifications. Common notification types from `flyte.notify` include: `Slack`, `Email`, `Teams`, `Webhook`, and `NamedDelivery`. |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template variable syntax and keys in this page (e.g., {{.Run.Name}}, {{.Phase}}, {{.Error}}) don’t match the Flyte Notifications API reference in this repo, which documents placeholders like {run.name}, {run.phase}, {run.error}, {run.url}, {project}, {domain} (see content/api-reference/flyte-sdk/packages/flyte.notify/_index.md). As written, notification messages will likely not render as intended when users copy/paste them. Please update the examples and the variable table to the documented placeholder format.
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For local SMTP testing, recommending sudo python ... localhost:25 encourages running Python as root. Since the text already mentions 1025 as an alternative, consider making the non-root option the default command (and mention 25 only as an optional privileged-port variant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snippets import notifications as
from flyte import notify, but elsewhere in this docs repo the documented pattern isimport flyte.notify as notify(e.g.,content/api-reference/flyte-sdk/packages/flyte/_index.md:820-822). Using the module import form avoids relying onflytere-exportingnotifyand is more consistent for readers.