-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode.py
More file actions
208 lines (164 loc) · 5.3 KB
/
node.py
File metadata and controls
208 lines (164 loc) · 5.3 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Released under MIT License.
# Copyright (c) 2025-2026 Ladislav Bartos and Robert Vacha Lab
from abc import ABC, abstractmethod
from qq_lib.properties.size import Size
class BatchNodeInterface(ABC):
"""
Abstract base class for obtaining information about compute nodes.
The implementation of the constructor is arbitrary and should only
be used inside the corresponding implementation of `BatchInterface.getNodes`.
"""
@abstractmethod
def update(self) -> None:
"""
Refresh the stored node information from the batch system.
Raises:
QQError: If the node cannot be queried or its info updated.
"""
pass
@abstractmethod
def getName(self) -> str:
"""
Retrieve the name of the node.
Returns:
str: The name identifying the node in the batch system.
"""
pass
@abstractmethod
def getNCPUs(self) -> int | None:
"""
Retrieve the total number of CPU cores available on the node.
Returns:
int | None: Total CPU core count or `None` if not available.
"""
pass
@abstractmethod
def getNFreeCPUs(self) -> int | None:
"""
Retrieve the number of currently available (unallocated) CPU cores.
Returns:
int | None: Number of free CPU cores or `None` if not available.
"""
pass
@abstractmethod
def getNGPUs(self) -> int | None:
"""
Retrieve the total number of GPUs available on the node.
Returns:
int | None: Total GPU count or `None` if not available..
"""
pass
@abstractmethod
def getNFreeGPUs(self) -> int | None:
"""
Retrieve the number of currently available (unallocated) GPUs.
Returns:
int | None: Number of free GPUs or `None` if not available.
"""
pass
@abstractmethod
def getCPUMemory(self) -> Size | None:
"""
Retrieve the total CPU memory capacity of the node.
Returns:
Size | None: Total CPU memory available on the node or `None` if not available.
"""
pass
@abstractmethod
def getFreeCPUMemory(self) -> Size | None:
"""
Retrieve the currently available CPU memory.
Returns:
Size | None: Free (unused) CPU memory or `None` if not available.
"""
pass
@abstractmethod
def getGPUMemory(self) -> Size | None:
"""
Retrieve the total GPU memory capacity of the node.
Returns:
Size | None: Total GPU memory available or `None` if not available.
"""
pass
@abstractmethod
def getFreeGPUMemory(self) -> Size | None:
"""
Retrieve the currently available GPU memory.
Returns:
Size | None: Free (unused) GPU memory or `None` if not available.
"""
pass
@abstractmethod
def getLocalScratch(self) -> Size | None:
"""
Retrieve the total local scratch storage capacity of the node.
Returns:
Size | None: Total size of local scratch space or `None` if not available.
"""
pass
@abstractmethod
def getFreeLocalScratch(self) -> Size | None:
"""
Retrieve the available local scratch storage space.
Returns:
Size | None: Free local scratch space or `None` if not available.
"""
pass
@abstractmethod
def getSSDScratch(self) -> Size | None:
"""
Retrieve the total SSD-based scratch storage capacity.
Returns:
Size | None: Total SSD scratch capacity or `None` if not available.
"""
pass
@abstractmethod
def getFreeSSDScratch(self) -> Size | None:
"""
Retrieve the currently available SSD-based scratch storage space.
Returns:
Size | None: Free SSD scratch space or `None` if not available.
"""
pass
@abstractmethod
def getSharedScratch(self) -> Size | None:
"""
Retrieve the total capacity of shared scratch storage accessible from the node.
Returns:
Size | None: Total shared scratch capacity or `None` if not available.
"""
pass
@abstractmethod
def getFreeSharedScratch(self) -> Size | None:
"""
Retrieve the available space in shared scratch storage.
Returns:
Size | None: Free shared scratch space or `None` if not available.
"""
pass
@abstractmethod
def getProperties(self) -> list[str]:
"""
Get the list of properties or labels assigned to the node.
Returns:
list[str]: List of node property strings.
"""
pass
@abstractmethod
def isAvailableToUser(self, user: str) -> bool:
"""
Check if the node is available to the specified user.
Args:
user (str): The username to check access for.
Returns:
bool: True if the node is up and schedulable, False otherwise.
"""
pass
@abstractmethod
def toYaml(self) -> str:
"""
Return all information about the node in YAML format.
Returns:
str: YAML-formatted string of node metadata.
"""
pass