-
Notifications
You must be signed in to change notification settings - Fork 168
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
Ele 3893 alert rules operators #1768
Conversation
👋 @MikaKerman |
…on_alert function
- Updated test cases in `test_alert_filters.py` to replace direct calls to individual filter functions with the new `filter_alerts` method. - Enhanced alert data structures to use `datetime` objects instead of string representations for timestamps. - Improved the handling of alert statuses by using the `AlertStatus` enum. - Adjusted test data to ensure consistency and correctness in the alert filtering logic.
…nd 'ALL' operator logic for value filtering.
…r 'IS_NOT' filter types across tags, owners, models, and statuses.
…ding logic in apply_filter function. Enhance unit tests to validate behavior of the new filter type in FilterSchema.
5920f35
to
b965c08
Compare
alert_node_name = None | ||
alert_type = AlertTypes(alert.type) | ||
if alert_type is AlertTypes.TEST: | ||
alert_node_name = alert.data.test_name # type: ignore[union-attr] |
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.
i think you can remove this type ignore by adding type hints in line 32: alert_node_name: Optional[str] = None
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.
Apparently not :(
def _get_alert_node_name(alert: PendingAlertSchema) -> Optional[str]:
alert_node_name: Optional[str] = None
alert_type = AlertTypes(alert.type)
if alert_type is AlertTypes.TEST:
alert_node_name = alert.data.test_name
elementary/monitor/api/alerts/alert_filters.py:31: error: Item "ModelAlertDataSchema" of "Union[TestAlertDataSchema, ModelAlertDataSchema, SourceFreshnessAlertDataSchema]" has no attribute "test_name" [union-attr]
elementary/monitor/api/alerts/alert_filters.py:31: error: Item "SourceFreshnessAlertDataSchema" of "Union[TestAlertDataSchema, ModelAlertDataSchema, SourceFreshnessAlertDataSchema]" has no attribute "test_name" [union-attr]
It's from the earlier version.
|
||
class StatusFilterSchema(FilterSchema): | ||
class StatusFilterSchema(FilterSchema[Status]): | ||
values: List[Status] |
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.
you can remove the re-definition of values
here
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.
I thought so too, but apparently not.
pydantic/pydantic#4171
values: List[Status] | ||
|
||
|
||
class ResourceTypeFilterSchema(FilterSchema): | ||
class ResourceTypeFilterSchema(FilterSchema[ResourceType]): | ||
values: List[ResourceType] |
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.
here too
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.
Commented above.
else [] | ||
) | ||
|
||
return ( |
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.
move this to separate function
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.
Done.
null