-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'elementary-data:master' into master
- Loading branch information
Showing
11 changed files
with
243 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from .alerts_group import AlertsGroup | ||
from .base_alerts_group import BaseAlertsGroup | ||
from .grouped_by_table import GroupedByTableAlerts | ||
|
||
__all__ = [ | ||
"AlertsGroup", | ||
"BaseAlertsGroup", | ||
"GroupedByTableAlerts", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
elementary/monitor/alerts/alerts_groups/base_alerts_group.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from abc import ABC, abstractmethod | ||
from datetime import datetime | ||
from typing import Dict, List, Sequence, Union | ||
|
||
from elementary.monitor.alerts.model_alert import ModelAlertModel | ||
from elementary.monitor.alerts.source_freshness_alert import SourceFreshnessAlertModel | ||
from elementary.monitor.alerts.test_alert import TestAlertModel | ||
|
||
|
||
class BaseAlertsGroup(ABC): | ||
def __init__( | ||
self, | ||
alerts: Sequence[ | ||
Union[TestAlertModel, ModelAlertModel, SourceFreshnessAlertModel] | ||
], | ||
) -> None: | ||
self.alerts = alerts | ||
|
||
@property | ||
def summary(self) -> str: | ||
return f"{len(self.alerts)} issues detected" | ||
|
||
@property | ||
def detected_at(self) -> datetime: | ||
return min(alert.detected_at or datetime.max for alert in self.alerts) | ||
|
||
@property | ||
@abstractmethod | ||
def status(self) -> str: | ||
... | ||
|
||
@property | ||
def data(self) -> List[Dict]: | ||
return [alert.data for alert in self.alerts] | ||
|
||
@property | ||
def unified_meta(self) -> Dict: | ||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.