Skip to content

Commit 347311c

Browse files
authored
Merge pull request #3182 from daniel-ge/master
FIX: load_resultfile crashes if open resultsfile from crashed job
2 parents b75a7ce + 4a6d6b8 commit 347311c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

nipype/pipeline/engine/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def load_resultfile(results_file, resolve=True):
291291
raise FileNotFoundError(results_file)
292292

293293
result = loadpkl(results_file)
294-
if resolve and result.outputs:
294+
if resolve and getattr(result, "outputs", None):
295295
try:
296296
outputs = result.outputs.get()
297297
except TypeError: # This is a Bunch
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from nipype.pipeline.plugins.base import SGELikeBatchManagerBase
2+
from nipype.interfaces.utility import Function
3+
import nipype.pipeline.engine as pe
4+
import pytest
5+
from unittest.mock import patch
6+
import subprocess
7+
8+
9+
def crasher():
10+
raise ValueError()
11+
12+
13+
def submit_batchtask(self, scriptfile, node):
14+
self._pending[1] = node.output_dir()
15+
subprocess.call(["bash", scriptfile])
16+
return 1
17+
18+
19+
def is_pending(self, taskid):
20+
return False
21+
22+
23+
@patch.object(SGELikeBatchManagerBase, "_submit_batchtask", new=submit_batchtask)
24+
@patch.object(SGELikeBatchManagerBase, "_is_pending", new=is_pending)
25+
def test_crashfile_creation(tmp_path):
26+
pipe = pe.Workflow(name="pipe", base_dir=str(tmp_path))
27+
pipe.config["execution"]["crashdump_dir"] = str(tmp_path)
28+
pipe.add_nodes([pe.Node(interface=Function(function=crasher), name="crasher")])
29+
sgelike_plugin = SGELikeBatchManagerBase("")
30+
with pytest.raises(RuntimeError) as e:
31+
assert pipe.run(plugin=sgelike_plugin)
32+
assert str(e.value) == "Workflow did not execute cleanly. Check log for details"
33+
34+
crashfiles = tmp_path.glob("crash*crasher*.pklz")
35+
assert len(list(crashfiles)) == 1

0 commit comments

Comments
 (0)