Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: #3288. Added a simple retry for inputs for a node. #3289

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from copy import deepcopy
from glob import glob
from logging import INFO
import time

from tempfile import mkdtemp

Expand Down Expand Up @@ -605,19 +606,36 @@ def _get_inputs(self):
output_value = outputs.dictcopy()[output_name]
logger.debug("output: %s", output_name)

try:
self.set_input(key, deepcopy(output_value))
except traits.TraitError as e:
traits_err = None
# input_tries = 1 # Default no reties
# input_retry_delay = 5
# input_retry_exponential_backoff_factor = 1
input_tries = int(self.config["execution"]["input_tries"])
input_retry_delay = int(self.config["execution"]["input_retry_delay"])
input_retry_exp_backoff_factor = int(self.config["execution"]["input_retry_exp_backoff_factor"])
for try_n in range(input_tries):
try:
self.set_input(key, deepcopy(output_value))
break
except traits.TraitError as e:
traits_err = e
if input_tries != 1:
sleep_time = input_retry_delay*try_n*input_retry_exp_backoff_factor
logger.warning("Input set failed for : {0} -> {1}. Retrying in {2} secs. ".format(key,
results_fname,
sleep_time))
time.sleep(sleep_time)
if traits_err is not None:
msg = (
e.args[0],
traits_err.args[0],
"",
"Error setting node input:",
"Node: %s" % self.name,
"input: %s" % key,
"results_file: %s" % results_fname,
"value: %s" % str(output_value),
)
e.args = ("\n".join(msg),)
traits_err.args = ("\n".join(msg),)
raise

# Successfully set inputs
Expand Down
3 changes: 3 additions & 0 deletions nipype/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
poll_sleep_duration = 2
xvfb_max_wait = 10
check_version = true
input_tries = 1
input_retry_delay = 5
input_retry_exp_backoff_factor = 1

[monitoring]
enabled = false
Expand Down