Skip to content

Commit

Permalink
SlurmBatch: fix --time for large walltime
Browse files Browse the repository at this point in the history
Now format walltime as days-hours:minutes instead of just minutes.
  • Loading branch information
PaulPrice committed Feb 22, 2018
1 parent 6b8b9f6 commit 53cf898
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion python/lsst/ctrl/pool/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ def submitCommand(self, scriptName):
class SlurmBatch(Batch):
"""Batch submission with Slurm"""

@staticmethod
def formatWalltime(walltime):
"""Format walltime (in seconds) as days-hours:minutes"""
secInDay = 3600*24
secInHour = 3600
secInMinute = 60
days = walltime//secInDay
walltime -= days*secInDay
hours = walltime//secInHour
walltime -= hours*secInHour
minutes = walltime//secInMinute
walltime -= minutes*secInMinute
if walltime > 0:
minutes += 1
return "%d-%d:%d" % (days, hours, minutes)

def preamble(self, walltime=None):
if walltime is None:
walltime = self.walltime
Expand All @@ -234,7 +250,7 @@ def preamble(self, walltime=None):
("#SBATCH --ntasks-per-node=%d" % self.numProcsPerNode) if
self.numProcsPerNode > 0 else "",
("#SBATCH --ntasks=%d" % self.numCores) if self.numCores > 0 else "",
"#SBATCH --time=%d" % max(walltime/60.0 + 0.5, 1) if walltime is not None else "",
"#SBATCH --time=%s" % self.formatWalltime(walltime),
"#SBATCH --job-name=%s" % self.jobName if self.jobName is not None else "",
"#SBATCH -p %s" % self.queue if self.queue is not None else "",
"#SBATCH --output=%s" % filename,
Expand Down

0 comments on commit 53cf898

Please sign in to comment.