Skip to content

Commit 94c5c17

Browse files
committed
Issue nipy#3288. Implementing input delayed retry for all inputs of the node. Simplified implementation for all inputs (not just File type). Need to be improved for File type later on.
1 parent 47fe00b commit 94c5c17

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

nipype/pipeline/engine/nodes.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from copy import deepcopy
1515
from glob import glob
1616
from logging import INFO
17+
import time
1718

1819
from tempfile import mkdtemp
1920

@@ -605,19 +606,32 @@ def _get_inputs(self):
605606
output_value = outputs.dictcopy()[output_name]
606607
logger.debug("output: %s", output_name)
607608

608-
try:
609-
self.set_input(key, deepcopy(output_value))
610-
except traits.TraitError as e:
609+
traits_err = None
610+
# input_tries = 1 # Default no reties
611+
# input_retry_delay = 5
612+
# input_retry_exponential_backoff_factor = 1
613+
input_tries = self.config["execution"]["input_tries"]
614+
input_retry_delay = self.config["execution"]["input_retry_delay"]
615+
input_retry_exp_backoff_factor = self.config["execution"]["input_retry_exp_backoff_factor"]
616+
for try_n in range(input_tries):
617+
try:
618+
self.set_input(key, deepcopy(output_value))
619+
break
620+
except traits.TraitError as e:
621+
traits_err = e
622+
if input_tries != 1:
623+
time.sleep(input_retry_delay*try_n*input_retry_exp_backoff_factor)
624+
if traits_err is not None:
611625
msg = (
612-
e.args[0],
626+
traits_err.args[0],
613627
"",
614628
"Error setting node input:",
615629
"Node: %s" % self.name,
616630
"input: %s" % key,
617631
"results_file: %s" % results_fname,
618632
"value: %s" % str(output_value),
619633
)
620-
e.args = ("\n".join(msg),)
634+
traits_err.args = ("\n".join(msg),)
621635
raise
622636

623637
# Successfully set inputs

nipype/utils/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
poll_sleep_duration = 2
6363
xvfb_max_wait = 10
6464
check_version = true
65+
input_tries = 1
66+
input_retry_delay = 5
67+
input_retry_exp_backoff_factor = 1
6568
6669
[monitoring]
6770
enabled = false

0 commit comments

Comments
 (0)