-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbase.py
More file actions
78 lines (63 loc) · 2.06 KB
/
base.py
File metadata and controls
78 lines (63 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import abc
import logging
import typing
class SimvueBaseClass(abc.ABC):
@abc.abstractmethod
def __init__(
self,
name: str | None,
uniq_id: str,
suppress_errors: bool,
) -> None:
self._logger = logging.getLogger(f"simvue.{self.__class__.__name__}")
self._suppress_errors: bool = suppress_errors
self._uuid: str = uniq_id
self.name: str | None = name
self.id: int | None = None
self._aborted: bool = False
def _error(self, message: str) -> None:
"""
Raise an exception if necessary and log error
"""
if not self._suppress_errors:
raise RuntimeError(message)
self._logger.error(message)
self._aborted = True
@abc.abstractmethod
def list_tags(self) -> list[str] | None:
pass
@abc.abstractmethod
def create_run(self, data: dict[str, typing.Any]) -> tuple[str, str | None]:
pass
@abc.abstractmethod
def update(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def set_folder_details(self, data) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def save_file(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def add_alert(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def set_alert_state(
self, alert_id: str, status: str
) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def list_alerts(self) -> list[dict[str, typing.Any]]:
pass
@abc.abstractmethod
def send_metrics(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def send_event(self, data: dict[str, typing.Any]) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def send_heartbeat(self) -> dict[str, typing.Any] | None:
pass
@abc.abstractmethod
def get_abort_status(self) -> bool:
pass