From cad7ac874c3ded18b374fa3218cbc07f3e8ca69d Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Thu, 7 Jul 2016 08:31:49 +0000 Subject: [PATCH] Task #9623: Support "min,max" nr of nodes pair in the parset --- MAC/Services/src/PipelineControl.py | 37 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/MAC/Services/src/PipelineControl.py b/MAC/Services/src/PipelineControl.py index 3146d9467f8..0f9e7682179 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(): -- GitLab