3
3
from pathlib import Path
4
4
import pytest
5
5
6
+ from ..core import Workflow
7
+ from ..submitter import Submitter
6
8
from ..boutiques import BoshTask
9
+ from .utils import result_no_submitter , result_submitter
7
10
8
11
need_bosh_docker = pytest .mark .skipif (
9
12
shutil .which ("docker" ) is None
10
13
or sp .call (["docker" , "info" ] or sp .call (["bosh" , "version" ])),
11
14
reason = "requires docker and bosh" ,
12
15
)
13
16
17
+ if bool (shutil .which ("sbatch" )):
18
+ Plugins = ["cf" , "slurm" ]
19
+ else :
20
+ Plugins = ["cf" ]
21
+
22
+ Infile = Path (__file__ ).resolve ().parent / "data_tests" / "test.nii.gz"
23
+
14
24
15
25
@need_bosh_docker
16
26
@pytest .mark .parametrize (
17
27
"maskfile" , ["test_brain.nii.gz" , "test_brain" , "test_brain.nii" ]
18
28
)
19
- def test_boutiques_1 (maskfile ):
29
+ @pytest .mark .parametrize ("results_function" , [result_no_submitter , result_submitter ])
30
+ @pytest .mark .parametrize ("plugin" , Plugins )
31
+ def test_boutiques_1 (maskfile , plugin , results_function ):
32
+ """ simple task to run fsl.bet using BoshTask"""
20
33
btask = BoshTask (name = "NA" , zenodo = "zenodo.1482743" )
21
- btask .inputs .infile = Path ( __file__ ). resolve (). parent / "data_tests" / "test.nii.gz"
34
+ btask .inputs .infile = Infile
22
35
btask .inputs .maskfile = maskfile
23
- res = btask ( )
36
+ res = results_function ( btask , plugin )
24
37
25
38
assert res .output .return_code == 0
26
39
@@ -30,3 +43,76 @@ def test_boutiques_1(maskfile):
30
43
# other files should also have proper names, but they do not exist
31
44
assert res .output .out_outskin_off .name == "test_brain_outskin_mesh.off"
32
45
assert not res .output .out_outskin_off .exists ()
46
+
47
+
48
+ @need_bosh_docker
49
+ @pytest .mark .parametrize (
50
+ "maskfile" , ["test_brain.nii.gz" , "test_brain" , "test_brain.nii" ]
51
+ )
52
+ @pytest .mark .parametrize ("plugin" , Plugins )
53
+ def test_boutiques_wf_1 (maskfile , plugin ):
54
+ """ wf with one task that runs fsl.bet using BoshTask"""
55
+ wf = Workflow (name = "wf" , input_spec = ["maskfile" , "infile" ])
56
+ wf .inputs .maskfile = maskfile
57
+ wf .inputs .infile = Infile
58
+
59
+ wf .add (
60
+ BoshTask (
61
+ name = "bet" ,
62
+ zenodo = "zenodo.1482743" ,
63
+ infile = wf .lzin .infile ,
64
+ maskfile = wf .lzin .maskfile ,
65
+ )
66
+ )
67
+
68
+ wf .set_output ([("outfile" , wf .bet .lzout .outfile )])
69
+
70
+ with Submitter (plugin = plugin ) as sub :
71
+ wf (submitter = sub )
72
+
73
+ res = wf .result ()
74
+ assert res .output .outfile .name == "test_brain.nii.gz"
75
+ assert res .output .outfile .exists ()
76
+
77
+
78
+ @need_bosh_docker
79
+ @pytest .mark .parametrize (
80
+ "maskfile" , ["test_brain.nii.gz" , "test_brain" , "test_brain.nii" ]
81
+ )
82
+ @pytest .mark .parametrize ("plugin" , Plugins )
83
+ def test_boutiques_wf_2 (maskfile , plugin ):
84
+ """ wf with two tasks that run fsl.bet and fsl.stats using BoshTask"""
85
+ wf = Workflow (name = "wf" , input_spec = ["maskfile" , "infile" ])
86
+ wf .inputs .maskfile = maskfile
87
+ wf .inputs .infile = Infile
88
+
89
+ wf .add (
90
+ BoshTask (
91
+ name = "bet" ,
92
+ zenodo = "zenodo.1482743" ,
93
+ infile = wf .lzin .infile ,
94
+ maskfile = wf .lzin .maskfile ,
95
+ )
96
+ )
97
+ wf .add (
98
+ BoshTask (
99
+ name = "stat" ,
100
+ zenodo = "zenodo.3240521" ,
101
+ input_file = wf .bet .lzout .outfile ,
102
+ v = True ,
103
+ )
104
+ )
105
+
106
+ wf .set_output (
107
+ [("outfile_bet" , wf .bet .lzout .outfile ), ("out_stat" , wf .stat .lzout .output )]
108
+ )
109
+
110
+ with Submitter (plugin = plugin ) as sub :
111
+ wf (submitter = sub )
112
+
113
+ res = wf .result ()
114
+ assert res .output .outfile_bet .name == "test_brain.nii.gz"
115
+ assert res .output .outfile_bet .exists ()
116
+
117
+ assert res .output .out_stat .name == "output.txt"
118
+ assert res .output .out_stat .exists ()
0 commit comments