wnm 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wnm might be problematic. Click here for more details.

wnm/actions.py ADDED
@@ -0,0 +1,45 @@
1
+ """Action model for representing planned node operations.
2
+
3
+ This module defines the action types and data structures used by the decision engine
4
+ to represent planned operations on nodes.
5
+ """
6
+
7
+ from dataclasses import dataclass
8
+ from enum import Enum
9
+ from typing import Optional
10
+
11
+
12
+ class ActionType(Enum):
13
+ """Types of actions that can be performed on nodes."""
14
+
15
+ ADD_NODE = "add"
16
+ REMOVE_NODE = "remove"
17
+ UPGRADE_NODE = "upgrade"
18
+ START_NODE = "start"
19
+ STOP_NODE = "stop"
20
+ RESTART_NODE = "restart"
21
+ SURVEY_NODES = "survey"
22
+ RESURVEY_NODES = "resurvey"
23
+
24
+
25
+ @dataclass
26
+ class Action:
27
+ """Represents a planned action to be executed.
28
+
29
+ Attributes:
30
+ type: The type of action to perform
31
+ node_id: Optional node ID if action is node-specific
32
+ priority: Higher values indicate more urgent actions (default: 0)
33
+ reason: Human-readable explanation of why this action is needed
34
+ """
35
+
36
+ type: ActionType
37
+ node_id: Optional[int] = None
38
+ priority: int = 0
39
+ reason: str = ""
40
+
41
+ def __repr__(self) -> str:
42
+ """Return a string representation of the action."""
43
+ if self.node_id is not None:
44
+ return f"Action({self.type.value}, node={self.node_id}, reason={self.reason})"
45
+ return f"Action({self.type.value}, reason={self.reason})"
wnm/common.py ADDED
@@ -0,0 +1,21 @@
1
+ # Primary node for want of one
2
+ QUEEN = 1
3
+
4
+ # Donation address, default to faucet vault, can be overridden in config
5
+ DONATE = "0x00455d78f850b0358E8cea5be24d415E01E107CF"
6
+
7
+ # Keep these as strings so they can be grepped in logs
8
+ STOPPED = "STOPPED" # 0 Node is not responding to it's metrics port
9
+ RUNNING = "RUNNING" # 1 Node is responding to it's metrics port
10
+ UPGRADING = "UPGRADING" # 2 Upgrade in progress
11
+ DISABLED = "DISABLED" # -1 Do not start
12
+ RESTARTING = "RESTARTING" # 3 re/starting a server intionally
13
+ MIGRATING = "MIGRATING" # 4 Moving volumes in progress
14
+ REMOVING = "REMOVING" # 5 Removing node in progress
15
+ DEAD = "DEAD" # -86 Broken node to cleanup
16
+
17
+ # Magic numbers extracted from codebase
18
+ MIN_NODES_THRESHOLD = 0 # Minimum nodes before considering actions
19
+ PORT_MULTIPLIER = 1000 # Port calculation: PortStart * 1000 + node_id
20
+ METRICS_PORT_BASE = 13000 # Metrics port calculation: 13000 + node_id
21
+ DEFAULT_CRISIS_BYTES = 2 * 10**9 # Default crisis threshold in bytes (2GB)