Skip to content

Commit

Permalink
Merge pull request #557 from yibeichan/fix-specs
Browse files Browse the repository at this point in the history
allow more output types to use callables
  • Loading branch information
djarecka authored Jul 22, 2022
2 parents eb48e0a + 2aecd6f commit ac06f8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pydra/engine/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def generated_output_names(self, inputs, output_dir):
inputs.check_fields_input_spec()
output_names = ["return_code", "stdout", "stderr"]
for fld in attr_fields(self, exclude_names=("return_code", "stdout", "stderr")):
if fld.type is not File:
if fld.type not in [File, MultiOutputFile, Directory]:
raise Exception("not implemented (collect_additional_output)")
# assuming that field should have either default or metadata, but not both
if (
Expand Down
18 changes: 16 additions & 2 deletions pydra/engine/tests/test_shelltask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,12 @@ def gather_output(field, output_dir):

my_output_spec = SpecInfo(
name="Output",
fields=[("newfile", attr.ib(type=File, metadata={"callable": gather_output}))],
fields=[
(
"newfile",
attr.ib(type=MultiOutputFile, metadata={"callable": gather_output}),
)
],
bases=(ShellOutSpec,),
)
shelly = ShellCommandTask(
Expand All @@ -2781,6 +2786,11 @@ def gather_output(field, output_dir):
# newfile is a list
assert len(res.output.newfile) == 2
assert all([file.exists for file in res.output.newfile])
assert (
shelly.output_names
== shelly.generated_output_names
== ["return_code", "stdout", "stderr", "newfile"]
)


@pytest.mark.parametrize("results_function", [result_no_submitter, result_submitter])
Expand Down Expand Up @@ -3238,7 +3248,11 @@ def get_lowest_directory(directory_path):
cache_dir=tmpdir,
resultsDir="test", # Path(tmpdir) / "test" TODO: Not working without absolute path support
)

assert (
shelly.output_names
== shelly.generated_output_names
== ["return_code", "stdout", "stderr", "resultsDir"]
)
res = results_function(shelly, plugin)
print("Cache_dirr:", shelly.cache_dir)
assert (shelly.output_dir / Path("test")).exists() == True
Expand Down

0 comments on commit ac06f8c

Please sign in to comment.