Skip to content
Snippets Groups Projects
Commit cad7ac87 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #9623: Support "min,max" nr of nodes pair in the parset

parent 3764b4d7
Branches
Tags
No related merge requests found
......@@ -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():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment