diff --git a/src/daq/alert/alert_slack.py b/src/daq/alert/alert_slack.py index 1a485e5..286b02b 100644 --- a/src/daq/alert/alert_slack.py +++ b/src/daq/alert/alert_slack.py @@ -1,6 +1,7 @@ from slack_webhook import Slack -from daq.alert.base import DAQAlertSeverity, DAQJobAlert, DAQJobMessageAlert +from daq.alert.base import DAQJobAlert +from daq.alert.models import DAQAlertSeverity, DAQJobMessageAlert from daq.models import DAQJobConfig ALERT_SEVERITY_TO_SLACK_COLOR = { diff --git a/src/daq/alert/base.py b/src/daq/alert/base.py index 5dc78d2..1df193a 100644 --- a/src/daq/alert/base.py +++ b/src/daq/alert/base.py @@ -1,27 +1,7 @@ -from datetime import datetime -from enum import Enum from typing import Any -from msgspec import Struct - +from daq.alert.models import DAQJobMessageAlert from daq.base import DAQJob -from daq.models import DAQJobMessage - - -class DAQAlertSeverity(str, Enum): - INFO = "info" - WARNING = "warning" - ERROR = "error" - - -class DAQAlertInfo(Struct): - message: str - severity: DAQAlertSeverity - - -class DAQJobMessageAlert(DAQJobMessage): - date: datetime - alert_info: DAQAlertInfo class DAQJobAlert(DAQJob): diff --git a/src/daq/alert/models.py b/src/daq/alert/models.py new file mode 100644 index 0000000..f1c77c5 --- /dev/null +++ b/src/daq/alert/models.py @@ -0,0 +1,22 @@ +from datetime import datetime + +from msgspec import Struct +from zmq import Enum + +from daq.models import DAQJobMessage + + +class DAQAlertSeverity(str, Enum): + INFO = "info" + WARNING = "warning" + ERROR = "error" + + +class DAQAlertInfo(Struct): + message: str + severity: DAQAlertSeverity + + +class DAQJobMessageAlert(DAQJobMessage): + date: datetime + alert_info: DAQAlertInfo diff --git a/src/daq/jobs/healthcheck.py b/src/daq/jobs/healthcheck.py index a5a4dcd..e2baef4 100644 --- a/src/daq/jobs/healthcheck.py +++ b/src/daq/jobs/healthcheck.py @@ -6,7 +6,8 @@ import msgspec from msgspec import Struct -from daq.alert.base import DAQAlertInfo, DAQAlertSeverity, DAQJobMessageAlert +from daq.alert.base import DAQJobMessageAlert +from daq.alert.models import DAQAlertInfo, DAQAlertSeverity from daq.base import DAQJob from daq.jobs.handle_stats import DAQJobMessageStats, DAQJobStatsDict from daq.models import DAQJobConfig, DAQJobStats diff --git a/src/tests/test_healthcheck.py b/src/tests/test_healthcheck.py index 85336ae..dfc683d 100644 --- a/src/tests/test_healthcheck.py +++ b/src/tests/test_healthcheck.py @@ -2,7 +2,7 @@ from datetime import datetime, timedelta from unittest.mock import MagicMock, patch -from daq.alert.base import DAQAlertInfo, DAQAlertSeverity +from daq.alert.models import DAQAlertInfo, DAQAlertSeverity from daq.jobs.healthcheck import ( AlertCondition, DAQJobHealthcheck, diff --git a/src/tests/test_slack.py b/src/tests/test_slack.py index e3b8989..39ecdf2 100644 --- a/src/tests/test_slack.py +++ b/src/tests/test_slack.py @@ -3,7 +3,7 @@ from unittest.mock import patch from daq.alert.alert_slack import DAQJobAlertSlack, DAQJobAlertSlackConfig -from daq.alert.base import DAQAlertInfo, DAQAlertSeverity, DAQJobMessageAlert +from daq.alert.models import DAQAlertInfo, DAQAlertSeverity, DAQJobMessageAlert from daq.base import DAQJobInfo