Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
clive
Commits
a1ac77fa
Commit
a1ac77fa
authored
9 months ago
by
Jakub Ziebinski
Browse files
Options
Downloads
Patches
Plain Diff
Implementation of a class to store alarms
parent
fd9e0288
No related branches found
No related tags found
2 merge requests
!399
V1.27.5.12 release
,
!367
Implementation of alarm management
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
clive/__private/core/alarms/alarms_storage.py
+34
-0
34 additions, 0 deletions
clive/__private/core/alarms/alarms_storage.py
clive/__private/storage/accounts.py
+22
-0
22 additions, 0 deletions
clive/__private/storage/accounts.py
with
56 additions
and
0 deletions
clive/__private/core/alarms/alarms_storage.py
0 → 100644
+
34
−
0
View file @
a1ac77fa
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
clive.__private.core.alarms.alarm
import
Alarm
,
AnyAlarm
from
clive.__private.core.alarms.specific_alarms
import
GovernanceVotingExpiration
if
TYPE_CHECKING
:
from
clive.__private.core.commands.data_retrieval.update_alarms_data
import
AccountAlarmsProcessedData
class
AlarmsStorage
:
def
__init__
(
self
)
->
None
:
self
.
governance_voting_expiration
=
GovernanceVotingExpiration
()
self
.
_is_updated
=
False
def
update_alarms_status
(
self
,
data
:
AccountAlarmsProcessedData
)
->
None
:
for
alarm
in
self
.
all_alarms
:
alarm
.
update_alarm_status
(
data
)
self
.
_is_updated
=
True
@property
def
harmful_alarms
(
self
)
->
list
[
AnyAlarm
]:
return
[
alarm
for
alarm
in
self
.
all_alarms
if
alarm
.
is_active
and
not
alarm
.
is_harmless
]
@property
def
all_alarms
(
self
)
->
list
[
AnyAlarm
]:
return
[
alarm
for
alarm
in
self
.
__dict__
.
values
()
if
isinstance
(
alarm
,
Alarm
)
]
# Use is_instance to avoid treat `is_updated` as an alarm
@property
def
is_alarms_data_available
(
self
)
->
bool
:
return
self
.
_is_updated
This diff is collapsed.
Click to expand it.
clive/__private/storage/accounts.py
+
22
−
0
View file @
a1ac77fa
...
...
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING
from
pydantic
import
ValidationError
from
clive.__private.core.alarms.alarms_storage
import
AlarmsStorage
from
clive.__private.core.keys
import
KeyManager
from
clive.__private.core.validate_schema_field
import
validate_schema_field
from
clive.exceptions
import
CliveError
...
...
@@ -38,6 +39,16 @@ To check if your account data is available, use the `is_node_data_available` pro
super
().
__init__
(
self
.
_MESSAGE
)
class
AccountAlarmsTooEarlyAccessError
(
AccountError
):
_MESSAGE
=
"""
You are trying to access account alarms too early.
To check if your account alarms are available, use the `is_account_alarms_available` property.
"""
def
__init__
(
self
)
->
None
:
super
().
__init__
(
self
.
_MESSAGE
)
class
AccountType
(
str
,
Enum
):
value
:
str
...
...
@@ -48,6 +59,7 @@ class AccountType(str, Enum):
@dataclass
class
Account
:
name
:
str
_alarms
:
AlarmsStorage
=
field
(
default_factory
=
AlarmsStorage
)
_data
:
NodeData
|
None
=
field
(
init
=
False
,
default
=
None
,
compare
=
False
)
def
__post_init__
(
self
)
->
None
:
...
...
@@ -62,10 +74,20 @@ class Account:
raise
AccountDataTooEarlyAccessError
return
self
.
_data
@property
def
alarms
(
self
)
->
AlarmsStorage
:
if
not
self
.
_alarms
.
is_alarms_data_available
:
raise
AccountDataTooEarlyAccessError
return
self
.
_alarms
@property
def
is_node_data_available
(
self
)
->
bool
:
return
self
.
_data
is
not
None
@property
def
is_alarms_data_available
(
self
)
->
bool
:
return
self
.
_alarms
.
is_alarms_data_available
@staticmethod
def
validate
(
name
:
str
)
->
None
:
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment