-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueue.py
More file actions
178 lines (142 loc) · 4.79 KB
/
queue.py
File metadata and controls
178 lines (142 loc) · 4.79 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
# Released under MIT License.
# Copyright (c) 2025-2026 Ladislav Bartos and Robert Vacha Lab
from abc import ABC, abstractmethod
from datetime import timedelta
from qq_lib.properties.resources import Resources
class BatchQueueInterface(ABC):
"""
Abstract base class for retrieving and maintaining queue information
from a batch scheduling system.
The implementation of the constructor is arbitrary and should only
be used inside the corresponding implementation of `BatchInterface.getQueues`.
"""
@abstractmethod
def update(self) -> None:
"""
Refresh the stored queue information from the batch system.
Raises:
QQError: If the queue cannot be queried or its info updated.
"""
pass
@abstractmethod
def getName(self) -> str:
"""
Retrieve the name of the queue.
Returns:
str: The name identifying this queue in the batch system.
"""
pass
@abstractmethod
def getPriority(self) -> str | None:
"""
Retrieve the scheduling priority of the queue.
Returns:
str | None: The queue priority, or None if priority information
is not available.
"""
pass
@abstractmethod
def getTotalJobs(self) -> int | None:
"""
Retrieve the total number of jobs currently in the queue.
Returns:
int | None: The total count of jobs, regardless of status
or `None` if the information is not available.
"""
pass
@abstractmethod
def getRunningJobs(self) -> int | None:
"""
Retrieve the number of jobs currently running in the queue.
Returns:
int | None: The number of running jobs or `None`
if the information is not available.
"""
pass
@abstractmethod
def getQueuedJobs(self) -> int | None:
"""
Retrieve the number of jobs waiting to start in the queue.
Returns:
int | None: The number of queued jobs or `None`
if the information is not available.
"""
pass
@abstractmethod
def getOtherJobs(self) -> int | None:
"""
Retrieve the number of jobs in other states (non-running and non-queued).
Returns:
int | None: The number of jobs that are neither running nor queued,
such as exiting or suspended jobs.
Returns `None` if the information is not available.
"""
pass
@abstractmethod
def getMaxWalltime(self) -> timedelta | None:
"""
Retrieve the maximum walltime allowed for jobs in the queue.
Returns:
timedelta | None: The walltime limit, or None if unlimited or unknown.
"""
pass
@abstractmethod
def getMaxNNodes(self) -> int | None:
"""
Retrieve the maximum number of nodes that can be requested in the queue.
Returns:
int | None: The maximum number of nodes that can be requested, or None if unlimited or unknown.
"""
pass
@abstractmethod
def getComment(self) -> str | None:
"""
Retrieve the comment or description associated with the queue.
Returns:
str | None: The human-readable comment or note about the queue
or `None` if the information is not available.
"""
pass
@abstractmethod
def isAvailableToUser(self, user: str) -> bool:
"""
Check whether the specified user has access to this queue.
Args:
user (str): The username to check access for.
Returns:
bool: True if the user can submit jobs to this queue, False otherwise.
"""
pass
@abstractmethod
def getDestinations(self) -> list[str]:
"""
Retrieve all destinations available for this queue route.
Returns:
list[str]: A list of destination queue names associated with the queue.
"""
pass
@abstractmethod
def fromRouteOnly(self) -> bool:
"""
Determine whether this queue can only be accessed via a route.
Returns:
bool: True if the queue is accessible exclusively through a route,
False otherwise.
"""
pass
@abstractmethod
def toYaml(self) -> str:
"""
Return all information about the queue from the batch system in YAML format.
Returns:
str: YAML-formatted string of queue metadata.
"""
pass
@abstractmethod
def getDefaultResources(self) -> Resources:
"""
Return the default resource definitions for this queue.
Returns:
Resources: Default resources allocated for jobs submitted to this queue.
"""
pass