Skip to content

Commit ac06f8c

Browse files
authored
Merge pull request #557 from yibeichan/fix-specs
allow more output types to use callables
2 parents eb48e0a + 2aecd6f commit ac06f8c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pydra/engine/specs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def generated_output_names(self, inputs, output_dir):
486486
inputs.check_fields_input_spec()
487487
output_names = ["return_code", "stdout", "stderr"]
488488
for fld in attr_fields(self, exclude_names=("return_code", "stdout", "stderr")):
489-
if fld.type is not File:
489+
if fld.type not in [File, MultiOutputFile, Directory]:
490490
raise Exception("not implemented (collect_additional_output)")
491491
# assuming that field should have either default or metadata, but not both
492492
if (

pydra/engine/tests/test_shelltask.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,12 @@ def gather_output(field, output_dir):
27692769

27702770
my_output_spec = SpecInfo(
27712771
name="Output",
2772-
fields=[("newfile", attr.ib(type=File, metadata={"callable": gather_output}))],
2772+
fields=[
2773+
(
2774+
"newfile",
2775+
attr.ib(type=MultiOutputFile, metadata={"callable": gather_output}),
2776+
)
2777+
],
27732778
bases=(ShellOutSpec,),
27742779
)
27752780
shelly = ShellCommandTask(
@@ -2781,6 +2786,11 @@ def gather_output(field, output_dir):
27812786
# newfile is a list
27822787
assert len(res.output.newfile) == 2
27832788
assert all([file.exists for file in res.output.newfile])
2789+
assert (
2790+
shelly.output_names
2791+
== shelly.generated_output_names
2792+
== ["return_code", "stdout", "stderr", "newfile"]
2793+
)
27842794

27852795

27862796
@pytest.mark.parametrize("results_function", [result_no_submitter, result_submitter])
@@ -3238,7 +3248,11 @@ def get_lowest_directory(directory_path):
32383248
cache_dir=tmpdir,
32393249
resultsDir="test", # Path(tmpdir) / "test" TODO: Not working without absolute path support
32403250
)
3241-
3251+
assert (
3252+
shelly.output_names
3253+
== shelly.generated_output_names
3254+
== ["return_code", "stdout", "stderr", "resultsDir"]
3255+
)
32423256
res = results_function(shelly, plugin)
32433257
print("Cache_dirr:", shelly.cache_dir)
32443258
assert (shelly.output_dir / Path("test")).exists() == True

0 commit comments

Comments
 (0)