|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 | from ..task import ShellCommandTask
|
6 |
| -from ..specs import ShellOutSpec, ShellSpec, SpecInfo, File, MultiInputObj |
| 6 | +from ..specs import ( |
| 7 | + ShellOutSpec, |
| 8 | + ShellSpec, |
| 9 | + SpecInfo, |
| 10 | + File, |
| 11 | + MultiInputObj, |
| 12 | + MultiInputFile, |
| 13 | + MultiOutputFile, |
| 14 | +) |
7 | 15 | from .utils import use_validator
|
| 16 | +from ..core import Workflow |
| 17 | +from ..submitter import Submitter |
8 | 18 |
|
9 | 19 |
|
10 | 20 | def test_shell_cmd_execargs_1():
|
@@ -1653,6 +1663,57 @@ def test_shell_cmd_inputs_template_10():
|
1653 | 1663 | assert shelly.output_names == ["return_code", "stdout", "stderr", "outA"]
|
1654 | 1664 |
|
1655 | 1665 |
|
| 1666 | +def test_shell_cmd_inputs_template_11(): |
| 1667 | + input_fields = [ |
| 1668 | + ( |
| 1669 | + "inputFiles", |
| 1670 | + attr.ib( |
| 1671 | + type=MultiInputFile, |
| 1672 | + metadata={ |
| 1673 | + "argstr": "--inputFiles ...", |
| 1674 | + "help_string": "The list of input image files to be segmented.", |
| 1675 | + }, |
| 1676 | + ), |
| 1677 | + ) |
| 1678 | + ] |
| 1679 | + |
| 1680 | + output_fields = [ |
| 1681 | + ( |
| 1682 | + "outputFiles", |
| 1683 | + attr.ib( |
| 1684 | + type=MultiOutputFile, |
| 1685 | + metadata={ |
| 1686 | + "help_string": "Corrected Output Images: should specify the same number of images as inputVolume, if only one element is given, then it is used as a file pattern where %s is replaced by the imageVolumeType, and %d by the index list location.", |
| 1687 | + "output_file_template": "{inputFiles}", |
| 1688 | + }, |
| 1689 | + ), |
| 1690 | + ) |
| 1691 | + ] |
| 1692 | + |
| 1693 | + input_spec = SpecInfo(name="Input", fields=input_fields, bases=(ShellSpec,)) |
| 1694 | + output_spec = SpecInfo(name="Output", fields=output_fields, bases=(ShellOutSpec,)) |
| 1695 | + |
| 1696 | + task = ShellCommandTask( |
| 1697 | + name="echoMultiple", |
| 1698 | + executable="echo", |
| 1699 | + input_spec=input_spec, |
| 1700 | + output_spec=output_spec, |
| 1701 | + ) |
| 1702 | + wf = Workflow(name="wf", input_spec=["inputFiles"], inputFiles=["test1", "test2"]) |
| 1703 | + |
| 1704 | + task.inputs.inputFiles = wf.lzin.inputFiles |
| 1705 | + |
| 1706 | + wf.add(task) |
| 1707 | + wf.set_output([("out", wf.echoMultiple.lzout.outputFiles)]) |
| 1708 | + |
| 1709 | + with Submitter(plugin="cf") as sub: |
| 1710 | + sub(wf) |
| 1711 | + result = wf.result() |
| 1712 | + |
| 1713 | + for out_file in result.output.out: |
| 1714 | + assert out_file.name == "test1" or out_file.name == "test2" |
| 1715 | + |
| 1716 | + |
1656 | 1717 | # TODO: after deciding how we use requires/templates
|
1657 | 1718 | def test_shell_cmd_inputs_di(tmpdir, use_validator):
|
1658 | 1719 | """ example from #279 """
|
|
0 commit comments