Skip to content

Commit 1ec3aff

Browse files
Merge pull request #120 from eliheady/feat/cluster-qos
add Slurm QOS parameter support
2 parents ab199f1 + 86fca42 commit 1ec3aff

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

Modules/Cluster.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
__CLUSTER_VPART__ = "v_partition"
6565
__CLUSTER_NPART__ = "partition_name"
6666
__CLUSTER_UPART__ = "use_partition"
67+
__CLUSTER_VQOS__ = "v_qos"
68+
__CLUSTER_NQOS__ = "qos_name"
69+
__CLUSTER_UQOS__ = "use_qos"
6770
__CLUSTER_INITSCRIPT__ = "init_script"
6871
__CLUSTER_MAXRECALC__ = "max_recalc"
6972
__CLUSTER_BATCHSIZE__ = "batch_size"
@@ -91,7 +94,8 @@
9194
__CLUSTER_UNODES__, __CLUSTER_VCPU__, __CLUSTER_NCPU__, __CLUSTER_UCPU__,
9295
__CLUSTER_VTIME__, __CLUSTER_NTIME__, __CLUSTER_UTIME__, __CLUSTER_VMEM__,
9396
__CLUSTER_NMEM__, __CLUSTER_UMEM__, __CLUSTER_VPART__, __CLUSTER_NPART__,
94-
__CLUSTER_UPART__, __CLUSTER_INITSCRIPT__, __CLUSTER_MAXRECALC__, __CLUSTER_BATCHSIZE__,
97+
__CLUSTER_UPART__, __CLUSTER_VQOS__, __CLUSTER_NQOS__, __CLUSTER_UQOS__,
98+
__CLUSTER_INITSCRIPT__, __CLUSTER_MAXRECALC__, __CLUSTER_BATCHSIZE__,
9599
__CLUSTER_LOCALWD__, __CLUSTER_VACCOUNT__, __CLUSTER_UACCOUNT__, __CLUSTER_SSHCMD__,
96100
__CLUSTER_SCPCMD__, __CLUSTER_WORKDIR__, __CLUSTER_TIMEOUT__,
97101
__CLUSTER_JOBNUMBER__, __CLUSTER_NPARALLEL__, __CLUSTER_NPOOLS__,
@@ -132,7 +136,7 @@ def parse_symbols(string):
132136
class Cluster(object):
133137

134138
def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
135-
account_name = "", partition_name = "", binary="pw.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo",
139+
account_name = "", partition_name = "", qos_name = "", binary="pw.x -npool NPOOL -i PREFIX.pwi > PREFIX.pwo",
136140
mpi_cmd=r"srun --mpi=pmi2 -n NPROC"):
137141
"""
138142
SETUP THE CLUSTER
@@ -163,6 +167,8 @@ def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
163167
The name of the account for the job submission
164168
partition_name:
165169
The partition name for the job submission
170+
qos_name:
171+
The QOS name for the job submission
166172
"""
167173

168174
self.hostname = hostname
@@ -189,6 +195,9 @@ def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
189195
self.partition_name = partition_name
190196
if partition_name:
191197
self.use_partition = True
198+
self.qos_name = qos_name
199+
if qos_name:
200+
self.use_qos = True
192201

193202
self.binary = binary
194203
self.mpi_cmd = mpi_cmd
@@ -209,6 +218,8 @@ def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
209218
self.use_memory = False
210219
self.v_partition="--partition="
211220
self.use_partition= False
221+
self.v_qos = "--qos="
222+
self.use_qos = False
212223
self.timeout = 1000
213224
self.use_timeout = False
214225

@@ -259,6 +270,9 @@ def __init__(self, hostname=None, pwd=None, extra_options="", workdir = "",
259270
# The default partition in which to submit calculations
260271
self.partition_name = ""
261272

273+
# The default qos in which to submit calculations
274+
self.qos_name = ""
275+
262276
# Still unused
263277
self.prefix_name = "prefix" # Variable in the calculator for differentiating the calculations
264278

@@ -481,6 +495,8 @@ def create_submission_script(self, labels):
481495
submission += "#%s %s%s\n" % (self.submit_name, self.v_memory, self.ram)
482496
if self.use_partition:
483497
submission += "#%s %s%s\n" % (self.submit_name, self.v_partition, self.partition_name)
498+
if self.use_qos:
499+
submission += "#%s %s%s\n" % (self.submit_name, self.v_qos, self.qos_name)
484500

485501
# Append the additional parameters
486502
for add_parameter in self.custom_params:
@@ -1303,6 +1319,13 @@ def setup_from_namelist(self, namelist):
13031319
self.use_partition = True
13041320
#if __CLUSTER_UPART__ in keys:
13051321
# self.use_partition = c_info[__CLUSTER_UPART__]
1322+
if __CLUSTER_VQOS__ in keys:
1323+
self.v_qos = c_info[__CLUSTER_VQOS__]
1324+
if __CLUSTER_NQOS__ in keys:
1325+
self.qos_name = c_info[__CLUSTER_NQOS__]
1326+
self.use_qos = True
1327+
if __CLUSTER_UQOS__ in keys:
1328+
self.use_qos = c_info[__CLUSTER_UQOS__]
13061329
if __CLUSTER_UACCOUNT__ in keys:
13071330
self.use_account = c_info[__CLUSTER_UACCOUNT__]
13081331
if __CLUSTER_VACCOUNT__ in keys:

0 commit comments

Comments
 (0)