Skip to content

Commit e42b76f

Browse files
committed
fix shadowing of outputEval for record types
1 parent 3d56459 commit e42b76f

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

cwltool/command_line_tool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,8 @@ def collect_output(
15811581
return None
15821582

15831583
if (
1584-
not empty_and_optional
1584+
not result
1585+
and not empty_and_optional
15851586
and isinstance(schema["type"], MutableMapping)
15861587
and schema["type"]["type"] == "record"
15871588
):

tests/test_examples.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,3 +1704,30 @@ def test_record_default_with_long() -> None:
17041704
assert (
17051705
result["sixth"]["checksum"] == "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376"
17061706
)
1707+
1708+
1709+
def test_record_outputeval() -> None:
1710+
"""Confirm that record types can be populated from outputEval."""
1711+
tool_path = get_data("tests/wf/record_outputeval.cwl")
1712+
err_code, stdout, stderr = get_main_output([tool_path])
1713+
assert err_code == 0
1714+
result = json.loads(stdout)["references"]
1715+
assert "genome_fa" in result
1716+
assert result["genome_fa"]["class"] == "File"
1717+
assert result["genome_fa"]["basename"] == "GRCm38.primary_assembly.genome.fa"
1718+
assert (
1719+
result["genome_fa"]["checksum"]
1720+
== "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709"
1721+
)
1722+
assert result["genome_fa"]["size"] == 0
1723+
assert "annotation_gtf" in result
1724+
assert result["annotation_gtf"]["class"] == "File"
1725+
assert (
1726+
result["annotation_gtf"]["basename"]
1727+
== "gencode.vM21.primary_assembly.annotation.gtf"
1728+
)
1729+
assert (
1730+
result["annotation_gtf"]["checksum"]
1731+
== "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709"
1732+
)
1733+
assert result["annotation_gtf"]["size"] == 0

tests/wf/record_outputeval.cwl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cwlVersion: v1.2
2+
class: CommandLineTool
3+
requirements:
4+
InlineJavascriptRequirement: {}
5+
6+
inputs:
7+
gtf_version:
8+
type: string
9+
default: M21
10+
organism:
11+
type: string
12+
default: mouse
13+
organism_prefix:
14+
type: string
15+
default: m
16+
17+
baseCommand:
18+
- bash
19+
- -c
20+
arguments:
21+
- touch GRC$(inputs.organism_prefix)38.primary_assembly.genome.fa ; touch gencode.v$(inputs.gtf_version).primary_assembly.annotation.gtf
22+
outputs:
23+
- id: references
24+
type:
25+
name: References
26+
fields:
27+
- name: genome_fa
28+
type: File
29+
- name: annotation_gtf
30+
type: File
31+
type: record
32+
outputBinding:
33+
outputEval: '$({ "genome_fa": { "class": "File", "path": runtime.outdir+"/"+"GRC"
34+
+ inputs.organism_prefix + "38.primary_assembly.genome.fa" }, "annotation_gtf":
35+
{ "class": "File", "path": runtime.outdir+"/"+"gencode.v" + inputs.gtf_version
36+
+ ".primary_assembly.annotation.gtf" } })'

0 commit comments

Comments
 (0)