Skip to content

Commit f3f93bb

Browse files
committed
add slurm option for qusb.detect_queuing_system and write_script
1 parent d96c34f commit f3f93bb

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

gromacs/qsub.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ def __repr__(self):
293293
QueuingSystem('Sun Gridengine', 'sge', '#$', array_variable='SGE_TASK_ID', array_option='-t %d-%d'),
294294
QueuingSystem('PBS', 'pbs', '#PBS', array_variable='PBS_ARRAY_INDEX', array_option='-J %d-%d'),
295295
QueuingSystem('LoadLeveler', 'll', '#@'), # no idea how to do arrays in LL
296+
QueuingSystem('Slurm', 'slu', '#SBATCH'), # will add array settings
296297
]
297298

298299
def detect_queuing_system(scriptfile):
@@ -365,19 +366,35 @@ def write_script(template):
365366
submitscript = os.path.join(dirname, prefix + os.path.basename(template))
366367
logger.info("Setting up queuing system script {submitscript!r}...".format(**vars()))
367368
# These substitution rules are documented for the user in the module doc string
368-
cbook.edit_txt(template,
369-
[('^ *DEFFNM=','(?<==)(.*)', deffnm),
370-
('^#.*(-N|job_name)', '((?<=-N\s)|(?<=job_name\s))\s*\w+', jobname),
371-
('^#.*(-A|account_no)', '((?<=-A\s)|(?<=account_no\s))\s*\w+', budget),
372-
('^#.*(-l walltime|wall_clock_limit)', '(?<==)(\d+:\d+:\d+)', walltime),
373-
('^ *WALL_HOURS=', '(?<==)(.*)', wall_hours),
374-
('^ *STARTDIR=', '(?<==)(.*)', startdir),
375-
('^ *NPME=', '(?<==)(.*)', npme),
376-
('^ *MDRUN_OPTS=', '(?<==)("")', mdrun_opts), # only replace literal ""
377-
('^# JOB_ARRAY_PLACEHOLDER', '^.*$', jobarray_string),
378-
],
379-
newname=submitscript)
380-
ext = os.path.splitext(submitscript)[1]
369+
qsystem = detect_queuing_system(template)
370+
if qsystem.name == 'Slurm':
371+
cbook.edit_txt(template,
372+
[('^ *DEFFNM=','(?<==)(.*)', deffnm),
373+
('^#.*(-J)', '((?<=-J\s))\s*\w+', jobname),
374+
('^#.*(-A|account_no)', '((?<=-A\s)|(?<=account_no\s))\s*\w+', budget),
375+
('^#.*(-t walltime)', '(?<==)(\d+:\d+:\d+)', walltime),
376+
('^ *WALL_HOURS=', '(?<==)(.*)', wall_hours),
377+
('^ *STARTDIR=', '(?<==)(.*)', startdir),
378+
('^ *NPME=', '(?<==)(.*)', npme),
379+
('^ *MDRUN_OPTS=', '(?<==)("")', mdrun_opts), # only replace literal ""
380+
('^# JOB_ARRAY_PLACEHOLDER', '^.*$', jobarray_string),
381+
],
382+
newname=submitscript)
383+
ext = os.path.splitext(submitscript)[1]
384+
else:
385+
cbook.edit_txt(template,
386+
[('^ *DEFFNM=','(?<==)(.*)', deffnm),
387+
('^#.*(-N|job_name)', '((?<=-N\s)|(?<=job_name\s))\s*\w+', jobname),
388+
('^#.*(-A|account_no)', '((?<=-A\s)|(?<=account_no\s))\s*\w+', budget),
389+
('^#.*(-l walltime|wall_clock_limit)', '(?<==)(\d+:\d+:\d+)', walltime),
390+
('^ *WALL_HOURS=', '(?<==)(.*)', wall_hours),
391+
('^ *STARTDIR=', '(?<==)(.*)', startdir),
392+
('^ *NPME=', '(?<==)(.*)', npme),
393+
('^ *MDRUN_OPTS=', '(?<==)("")', mdrun_opts), # only replace literal ""
394+
('^# JOB_ARRAY_PLACEHOLDER', '^.*$', jobarray_string),
395+
],
396+
newname=submitscript)
397+
ext = os.path.splitext(submitscript)[1]
381398
if ext in ('.sh', '.csh', '.bash'):
382399
os.chmod(submitscript, 0o755)
383400
return submitscript
@@ -430,4 +447,3 @@ def write_script(template):
430447

431448
# must use config.get_templates() because we need to access the file for detecting
432449
return [write_script(template) for template in config.get_templates(templates)]
433-

0 commit comments

Comments
 (0)