Skip to content

Commit 55223a6

Browse files
authored
Fix all_non_null single source element (#2220)
1 parent 99516ea commit 55223a6

5 files changed

Lines changed: 106 additions & 1 deletion

File tree

cwltool/checker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ def _check_all_types(
395395

396396
if pickValue in ["first_non_null", "the_only_non_null"]:
397397
linkMerge = None
398+
elif pickValue == "all_non_null" and linkMerge is None:
399+
sink["linkMerge"] = "merge_nested"
400+
linkMerge = cast(Optional[str], sink["linkMerge"])
398401

399402
srcs_of_sink: list[CWLObjectType] = []
400403
for parm_id in cast(MutableSequence[str], sink[sourceField]):

cwltool/workflow_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def object_from_state(
403403
a_state,
404404
iid,
405405
inputobj,
406-
cast(
406+
linkMerge=cast(
407407
Optional[str],
408408
inp.get(
409409
"linkMerge",

tests/single_all_non_null.cwl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cwlVersion: v1.2
2+
class: Workflow
3+
4+
requirements:
5+
MultipleInputFeatureRequirement: {}
6+
InlineJavascriptRequirement: {}
7+
8+
inputs:
9+
inp:
10+
type: string?
11+
default: null
12+
13+
outputs:
14+
out:
15+
type: int[]
16+
outputSource:
17+
- root/out
18+
pickValue: all_non_null
19+
20+
steps:
21+
root:
22+
run:
23+
class: ExpressionTool
24+
inputs:
25+
strs: string[]
26+
outputs:
27+
out:
28+
type: int
29+
expression: |
30+
${
31+
return {"out": inputs.strs.length}
32+
}
33+
in:
34+
strs:
35+
source:
36+
- inp
37+
pickValue: all_non_null
38+
out: [out]

tests/single_all_non_null_err.cwl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cwlVersion: v1.2
2+
class: Workflow
3+
4+
requirements:
5+
MultipleInputFeatureRequirement: {}
6+
InlineJavascriptRequirement: {}
7+
8+
inputs:
9+
inp:
10+
type: string?
11+
default: null
12+
13+
outputs:
14+
out:
15+
type: int[]
16+
outputSource:
17+
- root/out
18+
pickValue: all_non_null
19+
20+
steps:
21+
root:
22+
run:
23+
class: ExpressionTool
24+
inputs:
25+
strs: string
26+
outputs:
27+
out:
28+
type: int
29+
expression: |
30+
${
31+
return {"out": inputs.strs.length}
32+
}
33+
in:
34+
strs:
35+
source:
36+
- inp
37+
pickValue: all_non_null
38+
out: [out]

tests/test_examples.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,3 +1997,29 @@ def test_anonymous_record_mismatch_error() -> None:
19971997
assert exit_code == 1, stderr
19981998
assert "tests/2205.cwl:11:9: Record comparison failure between this record and " in stdout
19991999
assert "tests/2205.cwl:24:14: Did not match fields for 'missing': None and string." in stdout
2000+
2001+
2002+
def test_all_non_null() -> None:
2003+
"""Test pickValue: all_non_null with a single element source"""
2004+
exit_code, stdout, stderr = get_main_output(
2005+
[
2006+
get_data("tests/single_all_non_null.cwl"),
2007+
get_data("tests/echo-job.yaml"),
2008+
]
2009+
)
2010+
assert exit_code == 0
2011+
assert json.loads(stdout)["out"] == [1]
2012+
exit_code, stdout, stderr = get_main_output(
2013+
[
2014+
get_data("tests/single_all_non_null.cwl"),
2015+
]
2016+
)
2017+
assert exit_code == 0
2018+
assert json.loads(stdout)["out"] == [0]
2019+
exit_code, stdout, stderr = get_main_output(
2020+
[
2021+
get_data("tests/single_all_non_null_err.cwl"),
2022+
get_data("tests/echo-job.yaml"),
2023+
]
2024+
)
2025+
assert exit_code == 1

0 commit comments

Comments
 (0)