Skip to content

Commit

Permalink
Implement --batch-type None to run the job in the current process
Browse files Browse the repository at this point in the history
We actually support None and none as all the other batch options are lower case
  • Loading branch information
RobertLuptonTheGood committed Oct 6, 2016
1 parent a681abb commit db0ccc6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions python/lsst/ctrl/pool/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def submitCommand(self, scriptName):
return "exec %s" % scriptName


BATCH_TYPES = {'pbs': PbsBatch,
BATCH_TYPES = {'none' : None,
'None' : None,
'pbs': PbsBatch,
'slurm': SlurmBatch,
'smp': SmpBatch,
} # Mapping batch type --> Batch class
Expand Down Expand Up @@ -334,6 +336,10 @@ def makeBatch(self, args):
'submit': 'batchSubmit',
'options': 'batchOptions',
}

if BATCH_TYPES[args.batchType] is None:
return None

# kwargs is a dict that maps Batch init kwarg names to parsed arguments attribute *values*
kwargs = {k: getattr(args, v) for k, v in argMapping.items()}
return BATCH_TYPES[args.batchType](**kwargs)
Expand Down Expand Up @@ -404,11 +410,16 @@ def parseAndSubmit(cls, args=None, **kwargs):
if not cls.RunnerClass(cls, batchArgs.parent).precall(batchArgs.parent): # Write config, schema
taskParser.error("Error in task preparation")

numCores = batchArgs.cores if batchArgs.cores > 0 else batchArgs.nodes*batchArgs.procs
walltime = cls.batchWallTime(batchArgs.time, batchArgs.parent, numCores)
if batchArgs.batch is None: # don't use a batch system
sys.argv = [sys.argv[0]] + batchArgs.leftover # Remove all batch arguments

return cls.parseAndRun()
else:
numCores = batchArgs.cores if batchArgs.cores > 0 else batchArgs.nodes*batchArgs.procs
walltime = cls.batchWallTime(batchArgs.time, batchArgs.parent, numCores)

command = cls.batchCommand(batchArgs)
batchArgs.batch.run(command, walltime=walltime)
command = cls.batchCommand(batchArgs)
batchArgs.batch.run(command, walltime=walltime)

@classmethod
def batchWallTime(cls, time, parsedCmd, numCores):
Expand Down

0 comments on commit db0ccc6

Please sign in to comment.