Skip to content

Commit 3cd9880

Browse files
authored
Merge pull request #202 from djarecka/ci/lazy_image
[ci] example for using image input in the wf connection
2 parents a3046ae + 16833c7 commit 3cd9880

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

pydra/engine/tests/test_dockertask.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,46 @@ def test_wf_docker_2(plugin, tmpdir):
593593
assert res.output.out == "Hello!"
594594

595595

596+
@need_docker
597+
@pytest.mark.parametrize("plugin", Plugins)
598+
def test_wf_docker_3(plugin, tmpdir):
599+
""" a workflow with two connected task
600+
the first one read the file that contains the name of the image,
601+
the output is passed to the second task as the image used to run the task
602+
"""
603+
with open(tmpdir.join("image.txt"), "w") as f:
604+
f.write("ubuntu")
605+
606+
wf = Workflow(name="wf", input_spec=["cmd1", "cmd2"])
607+
wf.inputs.cmd1 = ["cat", "/tmp_dir/image.txt"]
608+
wf.inputs.cmd2 = ["echo", "image passed to the second task:"]
609+
wf.add(
610+
DockerTask(
611+
name="docky_cat",
612+
image="busybox",
613+
executable=wf.lzin.cmd1,
614+
bindings=[(str(tmpdir), "/tmp_dir", "ro")],
615+
strip=True,
616+
)
617+
)
618+
wf.add(
619+
DockerTask(
620+
name="docky_echo",
621+
image=wf.docky_cat.lzout.stdout,
622+
executable=wf.lzin.cmd2,
623+
args=wf.docky_cat.lzout.stdout,
624+
strip=True,
625+
)
626+
)
627+
wf.set_output([("out", wf.docky_echo.lzout.stdout)])
628+
629+
with Submitter(plugin=plugin) as sub:
630+
wf(submitter=sub)
631+
632+
res = wf.result()
633+
assert res.output.out == "image passed to the second task: ubuntu"
634+
635+
596636
# tests with customized output_spec
597637

598638

0 commit comments

Comments
 (0)