[core] handle unsatisfied node parallelization requirements

* catch error in case the required attribute is not found in preceding nodes
* set an empty list of chunks when this happens
* avoid uncatched exceptions in the middle of an update
This commit is contained in:
Yann Lanthony 2017-11-08 18:41:34 +01:00
parent ccaac43b34
commit 80cad9386a
2 changed files with 17 additions and 7 deletions

View file

@ -230,13 +230,17 @@ class Parallelization:
Returns: (blockSize, fullSize, nbBlocks)
"""
if self.inputListParamName:
# Look for this attribute on preceding nodes
parentNodes, edges = node.graph.dfsOnFinish(startNodes=[node])
for parentNode in parentNodes:
if self.inputListParamName in parentNode.getAttributes().keys():
fullSize = len(parentNode.attribute(self.inputListParamName))
nbBlocks = int(math.ceil(float(fullSize) / float(self.blockSize)))
return (self.blockSize, fullSize, nbBlocks)
raise RuntimeError('Cannot find the "inputListParamName": "{}" in the list of input nodes: {} for node: {}'.format(self.inputListParamName, parentNodes, node.name))
# No attribute has been found (parallelization won't work): raise
raise RuntimeError(
'Cannot find the "inputListParamName": "{}" in the list of input nodes: {} for node: {}'.format(
self.inputListParamName, parentNodes, node.name))
if self.staticNbBlocks:
return (1, self.staticNbBlocks, self.staticNbBlocks)
return None