Skip to content

Commit cbdd9a9

Browse files
authored
Merge pull request #1818 from elementary-data/ele-4028-send-alerts-messages
Add support for displaying result messages in model alerts
2 parents f08fc9d + e0ec7ae commit cbdd9a9

File tree

31 files changed

+419
-42
lines changed

31 files changed

+419
-42
lines changed

elementary/monitor/alerts/alert_messages/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _get_alert_result_blocks(
534534
)
535535
title = "Test Result"
536536
elif isinstance(alert, ModelAlertModel):
537-
if alert.materialization == "snapshot":
537+
if alert.message:
538538
result_blocks = self._get_result_blocks(
539539
result_message=alert.message,
540540
)

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-None_link-False_tags-False_owners-True_path-False_suppression-True_materialization-table_full_refresh-True_env-True.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"actions": [
6767
{
6868
"type": "Action.ToggleVisibility",
69-
"title": "Model Configuration",
69+
"title": "Result",
7070
"targetElements": [
7171
"expandable-00000000-0000-0000-0000-000000000001"
7272
]
@@ -76,6 +76,52 @@
7676
{
7777
"type": "Container",
7878
"id": "expandable-00000000-0000-0000-0000-000000000001",
79+
"items": [
80+
{
81+
"type": "Container",
82+
"separator": true,
83+
"items": [
84+
{
85+
"type": "TextBlock",
86+
"text": "**Result Message**",
87+
"wrap": true
88+
},
89+
{
90+
"type": "Container",
91+
"style": "emphasis",
92+
"items": [
93+
{
94+
"type": "RichTextBlock",
95+
"inlines": [
96+
{
97+
"type": "TextRun",
98+
"text": "Database Error in table my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
99+
"fontType": "Monospace"
100+
}
101+
]
102+
}
103+
]
104+
}
105+
]
106+
}
107+
],
108+
"isVisible": false
109+
},
110+
{
111+
"type": "ActionSet",
112+
"actions": [
113+
{
114+
"type": "Action.ToggleVisibility",
115+
"title": "Model Configuration",
116+
"targetElements": [
117+
"expandable-00000000-0000-0000-0000-000000000002"
118+
]
119+
}
120+
]
121+
},
122+
{
123+
"type": "Container",
124+
"id": "expandable-00000000-0000-0000-0000-000000000002",
79125
"items": [
80126
{
81127
"type": "Container",

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-None_link-True_tags-False_owners-True_path-True_suppression-True_materialization-table_full_refresh-False_env-True.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"actions": [
7272
{
7373
"type": "Action.ToggleVisibility",
74-
"title": "Model Configuration",
74+
"title": "Result",
7575
"targetElements": [
7676
"expandable-00000000-0000-0000-0000-000000000001"
7777
]
@@ -81,6 +81,52 @@
8181
{
8282
"type": "Container",
8383
"id": "expandable-00000000-0000-0000-0000-000000000001",
84+
"items": [
85+
{
86+
"type": "Container",
87+
"separator": true,
88+
"items": [
89+
{
90+
"type": "TextBlock",
91+
"text": "**Result Message**",
92+
"wrap": true
93+
},
94+
{
95+
"type": "Container",
96+
"style": "emphasis",
97+
"items": [
98+
{
99+
"type": "RichTextBlock",
100+
"inlines": [
101+
{
102+
"type": "TextRun",
103+
"text": "Database Error in table my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
104+
"fontType": "Monospace"
105+
}
106+
]
107+
}
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"isVisible": false
114+
},
115+
{
116+
"type": "ActionSet",
117+
"actions": [
118+
{
119+
"type": "Action.ToggleVisibility",
120+
"title": "Model Configuration",
121+
"targetElements": [
122+
"expandable-00000000-0000-0000-0000-000000000002"
123+
]
124+
}
125+
]
126+
},
127+
{
128+
"type": "Container",
129+
"id": "expandable-00000000-0000-0000-0000-000000000002",
84130
"items": [
85131
{
86132
"type": "Container",

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-error_link-False_tags-True_owners-True_path-True_suppression-False_materialization-incremental_full_refresh-True_env-False.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"actions": [
6767
{
6868
"type": "Action.ToggleVisibility",
69-
"title": "Model Configuration",
69+
"title": "Result",
7070
"targetElements": [
7171
"expandable-00000000-0000-0000-0000-000000000001"
7272
]
@@ -76,6 +76,52 @@
7676
{
7777
"type": "Container",
7878
"id": "expandable-00000000-0000-0000-0000-000000000001",
79+
"items": [
80+
{
81+
"type": "Container",
82+
"separator": true,
83+
"items": [
84+
{
85+
"type": "TextBlock",
86+
"text": "**Result Message**",
87+
"wrap": true
88+
},
89+
{
90+
"type": "Container",
91+
"style": "emphasis",
92+
"items": [
93+
{
94+
"type": "RichTextBlock",
95+
"inlines": [
96+
{
97+
"type": "TextRun",
98+
"text": "Database Error in incremental my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
99+
"fontType": "Monospace"
100+
}
101+
]
102+
}
103+
]
104+
}
105+
]
106+
}
107+
],
108+
"isVisible": false
109+
},
110+
{
111+
"type": "ActionSet",
112+
"actions": [
113+
{
114+
"type": "Action.ToggleVisibility",
115+
"title": "Model Configuration",
116+
"targetElements": [
117+
"expandable-00000000-0000-0000-0000-000000000002"
118+
]
119+
}
120+
]
121+
},
122+
{
123+
"type": "Container",
124+
"id": "expandable-00000000-0000-0000-0000-000000000002",
79125
"items": [
80126
{
81127
"type": "Container",

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-error_link-True_tags-True_owners-False_path-False_suppression-True_materialization-view_full_refresh-True_env-True.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"actions": [
7272
{
7373
"type": "Action.ToggleVisibility",
74-
"title": "Model Configuration",
74+
"title": "Result",
7575
"targetElements": [
7676
"expandable-00000000-0000-0000-0000-000000000001"
7777
]
@@ -81,6 +81,52 @@
8181
{
8282
"type": "Container",
8383
"id": "expandable-00000000-0000-0000-0000-000000000001",
84+
"items": [
85+
{
86+
"type": "Container",
87+
"separator": true,
88+
"items": [
89+
{
90+
"type": "TextBlock",
91+
"text": "**Result Message**",
92+
"wrap": true
93+
},
94+
{
95+
"type": "Container",
96+
"style": "emphasis",
97+
"items": [
98+
{
99+
"type": "RichTextBlock",
100+
"inlines": [
101+
{
102+
"type": "TextRun",
103+
"text": "Database Error in view my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
104+
"fontType": "Monospace"
105+
}
106+
]
107+
}
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"isVisible": false
114+
},
115+
{
116+
"type": "ActionSet",
117+
"actions": [
118+
{
119+
"type": "Action.ToggleVisibility",
120+
"title": "Model Configuration",
121+
"targetElements": [
122+
"expandable-00000000-0000-0000-0000-000000000002"
123+
]
124+
}
125+
]
126+
},
127+
{
128+
"type": "Container",
129+
"id": "expandable-00000000-0000-0000-0000-000000000002",
84130
"items": [
85131
{
86132
"type": "Container",

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-fail_link-True_tags-False_owners-False_path-True_suppression-False_materialization-incremental_full_refresh-True_env-False.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"actions": [
7272
{
7373
"type": "Action.ToggleVisibility",
74-
"title": "Model Configuration",
74+
"title": "Result",
7575
"targetElements": [
7676
"expandable-00000000-0000-0000-0000-000000000001"
7777
]
@@ -81,6 +81,52 @@
8181
{
8282
"type": "Container",
8383
"id": "expandable-00000000-0000-0000-0000-000000000001",
84+
"items": [
85+
{
86+
"type": "Container",
87+
"separator": true,
88+
"items": [
89+
{
90+
"type": "TextBlock",
91+
"text": "**Result Message**",
92+
"wrap": true
93+
},
94+
{
95+
"type": "Container",
96+
"style": "emphasis",
97+
"items": [
98+
{
99+
"type": "RichTextBlock",
100+
"inlines": [
101+
{
102+
"type": "TextRun",
103+
"text": "Database Error in incremental my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
104+
"fontType": "Monospace"
105+
}
106+
]
107+
}
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"isVisible": false
114+
},
115+
{
116+
"type": "ActionSet",
117+
"actions": [
118+
{
119+
"type": "Action.ToggleVisibility",
120+
"title": "Model Configuration",
121+
"targetElements": [
122+
"expandable-00000000-0000-0000-0000-000000000002"
123+
]
124+
}
125+
]
126+
},
127+
{
128+
"type": "Container",
129+
"id": "expandable-00000000-0000-0000-0000-000000000002",
84130
"items": [
85131
{
86132
"type": "Container",

tests/unit/alerts/alert_messages/fixtures/adaptive_card_model_alert_status-fail_link-True_tags-True_owners-True_path-True_suppression-True_materialization-table_full_refresh-True_env-True.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"actions": [
7272
{
7373
"type": "Action.ToggleVisibility",
74-
"title": "Model Configuration",
74+
"title": "Result",
7575
"targetElements": [
7676
"expandable-00000000-0000-0000-0000-000000000001"
7777
]
@@ -81,6 +81,52 @@
8181
{
8282
"type": "Container",
8383
"id": "expandable-00000000-0000-0000-0000-000000000001",
84+
"items": [
85+
{
86+
"type": "Container",
87+
"separator": true,
88+
"items": [
89+
{
90+
"type": "TextBlock",
91+
"text": "**Result Message**",
92+
"wrap": true
93+
},
94+
{
95+
"type": "Container",
96+
"style": "emphasis",
97+
"items": [
98+
{
99+
"type": "RichTextBlock",
100+
"inlines": [
101+
{
102+
"type": "TextRun",
103+
"text": "Database Error in table my_failed_dbt_model\n(models/example/my_failed_dbt_model.sql)\n syntax error at or near \")\"\n LINE 19: \t); \n\t\t^",
104+
"fontType": "Monospace"
105+
}
106+
]
107+
}
108+
]
109+
}
110+
]
111+
}
112+
],
113+
"isVisible": false
114+
},
115+
{
116+
"type": "ActionSet",
117+
"actions": [
118+
{
119+
"type": "Action.ToggleVisibility",
120+
"title": "Model Configuration",
121+
"targetElements": [
122+
"expandable-00000000-0000-0000-0000-000000000002"
123+
]
124+
}
125+
]
126+
},
127+
{
128+
"type": "Container",
129+
"id": "expandable-00000000-0000-0000-0000-000000000002",
84130
"items": [
85131
{
86132
"type": "Container",

0 commit comments

Comments
 (0)