File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ def load_resultfile(results_file, resolve=True):
291
291
raise FileNotFoundError (results_file )
292
292
293
293
result = loadpkl (results_file )
294
- if resolve and result . outputs :
294
+ if resolve and getattr ( result , " outputs" , None ) :
295
295
try :
296
296
outputs = result .outputs .get ()
297
297
except TypeError : # This is a Bunch
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments