Skip to content

Commit

Permalink
refactor: move alert models to daq.alert.models module
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Nov 12, 2024
1 parent ede5f9d commit 3c24da8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/daq/alert/alert_slack.py
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
22 changes: 1 addition & 21 deletions src/daq/alert/base.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
22 changes: 22 additions & 0 deletions src/daq/alert/models.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/daq/jobs/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 3c24da8

Please sign in to comment.