-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3182 from daniel-ge/master
FIX: load_resultfile crashes if open resultsfile from crashed job
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from nipype.pipeline.plugins.base import SGELikeBatchManagerBase | ||
from nipype.interfaces.utility import Function | ||
import nipype.pipeline.engine as pe | ||
import pytest | ||
from unittest.mock import patch | ||
import subprocess | ||
|
||
|
||
def crasher(): | ||
raise ValueError() | ||
|
||
|
||
def submit_batchtask(self, scriptfile, node): | ||
self._pending[1] = node.output_dir() | ||
subprocess.call(["bash", scriptfile]) | ||
return 1 | ||
|
||
|
||
def is_pending(self, taskid): | ||
return False | ||
|
||
|
||
@patch.object(SGELikeBatchManagerBase, "_submit_batchtask", new=submit_batchtask) | ||
@patch.object(SGELikeBatchManagerBase, "_is_pending", new=is_pending) | ||
def test_crashfile_creation(tmp_path): | ||
pipe = pe.Workflow(name="pipe", base_dir=str(tmp_path)) | ||
pipe.config["execution"]["crashdump_dir"] = str(tmp_path) | ||
pipe.add_nodes([pe.Node(interface=Function(function=crasher), name="crasher")]) | ||
sgelike_plugin = SGELikeBatchManagerBase("") | ||
with pytest.raises(RuntimeError) as e: | ||
assert pipe.run(plugin=sgelike_plugin) | ||
assert str(e.value) == "Workflow did not execute cleanly. Check log for details" | ||
|
||
crashfiles = tmp_path.glob("crash*crasher*.pklz") | ||
assert len(list(crashfiles)) == 1 |