diff --git a/MAC/Services/src/PipelineControl.py b/MAC/Services/src/PipelineControl.py index 3146d9467f8d4d2971caec06603bc438a66545f4..0f9e7682179a3a0238833420915839c0ede70a0e 100755 --- a/MAC/Services/src/PipelineControl.py +++ b/MAC/Services/src/PipelineControl.py @@ -143,10 +143,39 @@ class Parset(dict): return max(1, min(20, result)) def processingNumberOfTasks(self): - result = int(self[PARSET_PREFIX + "Observation.Cluster.ProcessingCluster.numberOfTasks"]) or "24" - if result < 1 or result > 48: - logger.warn('Invalid Observation.Cluster.ProcessingCluster.numberOfTasks: %s, defaulting to %s', result, max(1, min(48, result))) - return max(1, min(48, result)) + """ Parse the number of nodes to allocate from "Observation.Cluster.ProcessingCluster.numberOfTasks", + which can have either the format "{number}" or "{min},{max}". """ + + parsetValue = self[PARSET_PREFIX + "Observation.Cluster.ProcessingCluster.numberOfTasks"].strip() + + # force a number of nodes between bounds applicable for this cluster + def bound(n): + return max(1, min(48, n)) + + if "," in parsetValue: + # min,max + _min, _max = parsetValue.split(",") + + # apply bound + _min = bound(_min) + _max = bound(_max) + + # collapse if not min <= max + if _min > _max: + result = _min + else: + result = "%s,%s" % (_min, _max) + else: + # plain number + result = int(parsetValue) or 24 + + # apply bound + result = bound(result) + + if result != parsetValue: + logger.error('Invalid Observation.Cluster.ProcessingCluster.numberOfTasks: %s, defaulting to %s', parsetValue, result) + + return result @staticmethod def dockerRepository():