|
2 | 2 | import pytest
|
3 | 3 | import attr
|
4 | 4 |
|
5 |
| -from ..task import DockerTask, ShellCommandTask |
| 5 | +from ..task import ShellCommandTask |
6 | 6 | from ..submitter import Submitter
|
7 | 7 | from ..core import Workflow
|
8 |
| -from ..specs import ShellOutSpec, SpecInfo, File, DockerSpec, ShellSpec |
| 8 | +from ..specs import ShellOutSpec, SpecInfo, File, ShellSpec |
9 | 9 | from ..environments import Docker
|
10 | 10 | from .utils import no_win, need_docker, result_submitter, result_no_submitter
|
11 | 11 |
|
@@ -113,202 +113,6 @@ def test_docker_st_1(results_function, plugin):
|
113 | 113 | assert res[0].output.return_code == res[1].output.return_code == 0
|
114 | 114 |
|
115 | 115 |
|
116 |
| -# tests with workflows |
117 |
| - |
118 |
| - |
119 |
| -# TODO: to remove or update |
120 |
| -# @no_win |
121 |
| -# @need_docker |
122 |
| -# @pytest.mark.skip(reason="we probably don't want to support bindings as an input") |
123 |
| -# def test_wf_docker_1(plugin, tmp_path): |
124 |
| -# """a workflow with two connected task |
125 |
| -# the first one read the file that is bounded to the container, |
126 |
| -# the second uses echo |
127 |
| -# """ |
128 |
| -# with open(tmp_path / "file_pydra.txt"), "w" as f: |
129 |
| -# f.write("hello from pydra") |
130 |
| -# |
131 |
| -# wf = Workflow(name="wf", input_spec=["cmd1", "cmd2"]) |
132 |
| -# wf.inputs.cmd1 = ["cat", "/tmp_dir/file_pydra.txt"] |
133 |
| -# wf.inputs.cmd2 = ["echo", "message from the previous task:"] |
134 |
| -# wf.add( |
135 |
| -# DockerTask( |
136 |
| -# name="docky_cat", |
137 |
| -# image="busybox", |
138 |
| -# executable=wf.lzin.cmd1, |
139 |
| -# bindings=[(str(tmp_path), "/tmp_dir", "ro")], |
140 |
| -# strip=True, |
141 |
| -# ) |
142 |
| -# ) |
143 |
| -# wf.add( |
144 |
| -# DockerTask( |
145 |
| -# name="docky_echo", |
146 |
| -# image="ubuntu", |
147 |
| -# executable=wf.lzin.cmd2, |
148 |
| -# args=wf.docky_cat.lzout.stdout, |
149 |
| -# strip=True, |
150 |
| -# ) |
151 |
| -# ) |
152 |
| -# wf.set_output([("out", wf.docky_echo.lzout.stdout)]) |
153 |
| -# |
154 |
| -# with pytest.raises(Exception) as excinfo: |
155 |
| -# wf.docky_echo.cmdline |
156 |
| -# assert "can't return cmdline" in str(excinfo.value) |
157 |
| -# |
158 |
| -# with Submitter(plugin=plugin) as sub: |
159 |
| -# wf(submitter=sub) |
160 |
| -# |
161 |
| -# res = wf.result() |
162 |
| -# assert res.output.out == "message from the previous task: hello from pydra" |
163 |
| -# |
164 |
| -# |
165 |
| -# @no_win |
166 |
| -# @need_docker |
167 |
| -# @pytest.mark.skip(reason="we probably don't want to support bindings as an input") |
168 |
| -# def test_wf_docker_1_dockerflag(plugin, tmp_path): |
169 |
| -# """a workflow with two connected task |
170 |
| -# the first one read the file that is bounded to the container, |
171 |
| -# the second uses echo |
172 |
| -# using ShellComandTask with container_info |
173 |
| -# """ |
174 |
| -# with open(tmp_path / "file_pydra.txt"), "w" as f: |
175 |
| -# f.write("hello from pydra") |
176 |
| -# |
177 |
| -# wf = Workflow(name="wf", input_spec=["cmd1", "cmd2"]) |
178 |
| -# wf.inputs.cmd1 = ["cat", "/tmp_dir/file_pydra.txt"] |
179 |
| -# wf.inputs.cmd2 = ["echo", "message from the previous task:"] |
180 |
| -# wf.add( |
181 |
| -# ShellCommandTask( |
182 |
| -# name="shocky_cat", |
183 |
| -# container_info=("docker", "busybox", [(str(tmp_path), "/tmp_dir", "ro")]), |
184 |
| -# executable=wf.lzin.cmd1, |
185 |
| -# strip=True, |
186 |
| -# ) |
187 |
| -# ) |
188 |
| -# wf.add( |
189 |
| -# ShellCommandTask( |
190 |
| -# name="shocky_echo", |
191 |
| -# executable=wf.lzin.cmd2, |
192 |
| -# args=wf.shocky_cat.lzout.stdout, |
193 |
| -# strip=True, |
194 |
| -# container_info=("docker", "ubuntu"), |
195 |
| -# ) |
196 |
| -# ) |
197 |
| -# wf.set_output([("out", wf.shocky_echo.lzout.stdout)]) |
198 |
| -# |
199 |
| -# with Submitter(plugin=plugin) as sub: |
200 |
| -# wf(submitter=sub) |
201 |
| -# |
202 |
| -# res = wf.result() |
203 |
| -# assert res.output.out == "message from the previous task: hello from pydra" |
204 |
| -# |
205 |
| -# |
206 |
| -# @no_win |
207 |
| -# @need_docker |
208 |
| -# @pytest.mark.skip(reason="we probably don't want to support bindings as an input") |
209 |
| -# def test_wf_docker_2pre(plugin, tmp_path, data_tests_dir): |
210 |
| -# """a workflow with two connected task that run python scripts |
211 |
| -# the first one creates a text file and the second one reads the file |
212 |
| -# """ |
213 |
| -# |
214 |
| -# cmd1 = ["python", "/scripts/saving.py", "-f", "/outputs/tmp.txt"] |
215 |
| -# dt = DockerTask( |
216 |
| -# name="save", |
217 |
| -# image="python:3.7-alpine", |
218 |
| -# executable=cmd1, |
219 |
| -# bindings=[(str(tmp_path), "/outputs"), (str(data_tests_dir), "/scripts", "ro")], |
220 |
| -# strip=True, |
221 |
| -# ) |
222 |
| -# res = dt(plugin=plugin) |
223 |
| -# assert res.output.stdout == "/outputs/tmp.txt" |
224 |
| -# |
225 |
| -# |
226 |
| -# @no_win |
227 |
| -# @need_docker |
228 |
| -# @pytest.mark.skip(reason="we probably don't want to support bindings as an input") |
229 |
| -# def test_wf_docker_2(plugin, tmp_path, data_tests_dir): |
230 |
| -# """a workflow with two connected task that run python scripts |
231 |
| -# the first one creates a text file and the second one reads the file |
232 |
| -# """ |
233 |
| -# |
234 |
| -# wf = Workflow(name="wf", input_spec=["cmd1", "cmd2"]) |
235 |
| -# wf.inputs.cmd1 = ["python", "/scripts/saving.py", "-f", "/outputs/tmp.txt"] |
236 |
| -# wf.inputs.cmd2 = ["python", "/scripts/loading.py", "-f"] |
237 |
| -# wf.add( |
238 |
| -# DockerTask( |
239 |
| -# name="save", |
240 |
| -# image="python:3.7-alpine", |
241 |
| -# executable=wf.lzin.cmd1, |
242 |
| -# bindings=[ |
243 |
| -# (str(tmp_path), "/outputs"), |
244 |
| -# (str(data_tests_dir), "/scripts", "ro"), |
245 |
| -# ], |
246 |
| -# strip=True, |
247 |
| -# ) |
248 |
| -# ) |
249 |
| -# wf.add( |
250 |
| -# DockerTask( |
251 |
| -# name="load", |
252 |
| -# image="python:3.7-alpine", |
253 |
| -# executable=wf.lzin.cmd2, |
254 |
| -# args=wf.save.lzout.stdout, |
255 |
| -# bindings=[ |
256 |
| -# (str(tmp_path), "/outputs"), |
257 |
| -# (str(data_tests_dir), "/scripts", "ro"), |
258 |
| -# ], |
259 |
| -# strip=True, |
260 |
| -# ) |
261 |
| -# ) |
262 |
| -# wf.set_output([("out", wf.load.lzout.stdout)]) |
263 |
| -# |
264 |
| -# with Submitter(plugin=plugin) as sub: |
265 |
| -# wf(submitter=sub) |
266 |
| -# |
267 |
| -# res = wf.result() |
268 |
| -# assert res.output.out == "Hello!" |
269 |
| -# |
270 |
| -# |
271 |
| -# @no_win |
272 |
| -# @need_docker |
273 |
| -# @pytest.mark.skip(reason="we probably don't want to support bindings as an input") |
274 |
| -# def test_wf_docker_3(plugin, tmp_path): |
275 |
| -# """a workflow with two connected task |
276 |
| -# the first one read the file that contains the name of the image, |
277 |
| -# the output is passed to the second task as the image used to run the task |
278 |
| -# """ |
279 |
| -# with open(tmp_path / "image.txt"), "w" as f: |
280 |
| -# f.write("ubuntu") |
281 |
| -# |
282 |
| -# wf = Workflow(name="wf", input_spec=["cmd1", "cmd2"]) |
283 |
| -# wf.inputs.cmd1 = ["cat", "/tmp_dir/image.txt"] |
284 |
| -# wf.inputs.cmd2 = ["echo", "image passed to the second task:"] |
285 |
| -# wf.add( |
286 |
| -# DockerTask( |
287 |
| -# name="docky_cat", |
288 |
| -# image="busybox", |
289 |
| -# executable=wf.lzin.cmd1, |
290 |
| -# bindings=[(str(tmp_path), "/tmp_dir", "ro")], |
291 |
| -# strip=True, |
292 |
| -# ) |
293 |
| -# ) |
294 |
| -# wf.add( |
295 |
| -# DockerTask( |
296 |
| -# name="docky_echo", |
297 |
| -# image=wf.docky_cat.lzout.stdout, |
298 |
| -# executable=wf.lzin.cmd2, |
299 |
| -# args=wf.docky_cat.lzout.stdout, |
300 |
| -# strip=True, |
301 |
| -# ) |
302 |
| -# ) |
303 |
| -# wf.set_output([("out", wf.docky_echo.lzout.stdout)]) |
304 |
| -# |
305 |
| -# with Submitter(plugin=plugin) as sub: |
306 |
| -# wf(submitter=sub) |
307 |
| -# |
308 |
| -# res = wf.result() |
309 |
| -# assert res.output.out == "image passed to the second task: ubuntu" |
310 |
| - |
311 |
| - |
312 | 116 | # tests with customized output_spec
|
313 | 117 |
|
314 | 118 |
|
|
0 commit comments