Skip to content

Commit a30b00b

Browse files
authored
Merge branch 'main' into cuda-request-gpu-device-expr
2 parents 0325231 + 4c65bdf commit a30b00b

File tree

8 files changed

+183
-9
lines changed

8 files changed

+183
-9
lines changed

cwltool/argparser.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,18 @@ def arg_parser() -> argparse.ArgumentParser:
478478
conda_dependencies = argparse.SUPPRESS
479479

480480
if SOFTWARE_REQUIREMENTS_ENABLED:
481-
dependency_resolvers_configuration_help = "Dependency resolver "
482-
"configuration file describing how to adapt 'SoftwareRequirement' "
483-
"packages to current system."
481+
dependency_resolvers_configuration_help = (
482+
"Dependency resolver "
483+
"configuration file describing how to adapt 'SoftwareRequirement' "
484+
"packages to current system."
485+
)
484486
dependencies_directory_help = (
485-
"Defaut root directory used by dependency resolvers configuration."
487+
"Default root directory used by dependency resolvers configuration."
488+
)
489+
use_biocontainers_help = (
490+
"Use biocontainers for tools without an "
491+
"explicitly annotated Docker container."
486492
)
487-
use_biocontainers_help = "Use biocontainers for tools without an "
488-
"explicitly annotated Docker container."
489493
conda_dependencies = (
490494
"Short cut to use Conda to resolve 'SoftwareRequirement' packages."
491495
)
@@ -869,12 +873,24 @@ def add_argument(
869873
fieldname = name + "." + shortname(field["name"])
870874
fieldtype = field["type"]
871875
fielddescription = field.get("doc", "")
872-
add_argument(toolparser, fieldname, fieldtype, records, fielddescription)
876+
add_argument(
877+
toolparser,
878+
fieldname,
879+
fieldtype,
880+
records,
881+
fielddescription,
882+
default=default.get(shortname(field["name"]), None)
883+
if default
884+
else None,
885+
input_required=required,
886+
)
873887
return
874888
elif inptype == "string":
875889
atype = str
876890
elif inptype == "int":
877891
atype = int
892+
elif inptype == "long":
893+
atype = int
878894
elif inptype == "double":
879895
atype = float
880896
elif inptype == "float":

cwltool/checker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ def check_all_types(
389389
)
390390
else:
391391
parm_id = cast(str, sink[sourceField])
392+
if parm_id not in src_dict:
393+
raise SourceLine(sink, sourceField, ValidationException).makeError(
394+
f"{sourceField} not found: {parm_id}"
395+
)
396+
392397
srcs_of_sink = [src_dict[parm_id]]
393398
linkMerge = None
394399

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
):

cwltool/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ def main(
13031303
tool, job_order_object = tool.result(tfjob_order, tfout, runtimeContext)
13041304
if not job_order_object:
13051305
job_order_object = None
1306-
13071306
try:
13081307
initialized_job_order_object = init_job_order(
13091308
job_order_object,

tests/checker_wf/broken-wf4.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.0
4+
inputs:
5+
letters0:
6+
type: string
7+
default: "a0"
8+
9+
outputs:
10+
all:
11+
type: File
12+
outputSource: echo_w
13+
14+
steps:
15+
echo_w:
16+
run: echo.cwl
17+
in:
18+
echo_in: letters0
19+
out: [txt]
20+

tests/test_examples.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,3 +1685,59 @@ def test_command_line_tool_class() -> None:
16851685
tool_path = get_data("tests/echo.cwl")
16861686
expression_tool = factory.make(tool_path).t
16871687
assert str(expression_tool) == f"CommandLineTool: file://{tool_path}"
1688+
1689+
1690+
def test_record_default_with_long() -> None:
1691+
"""Confirm that record defaults are respected."""
1692+
tool_path = get_data("tests/wf/paramref_arguments_roundtrip.cwl")
1693+
err_code, stdout, stderr = get_main_output([tool_path])
1694+
assert err_code == 0
1695+
result = json.loads(stdout)["same_record"]
1696+
assert result["first"] == "y"
1697+
assert result["second"] == 23
1698+
assert result["third"] == 2.3
1699+
assert result["fourth"] == 4242424242
1700+
assert result["fifth"] == 4200000000000000000000000000000000000000000
1701+
assert result["sixth"]["class"] == "File"
1702+
assert result["sixth"]["basename"] == "whale.txt"
1703+
assert result["sixth"]["size"] == 1111
1704+
assert (
1705+
result["sixth"]["checksum"] == "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376"
1706+
)
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
1734+
1735+
1736+
def tests_outputsource_valid_identifier_invalid_source() -> None:
1737+
"""Confirm error for invalid source that was also a valid identifier."""
1738+
tool_path = get_data("tests/checker_wf/broken-wf4.cwl")
1739+
err_code, stdout, stderr = get_main_output([tool_path])
1740+
assert err_code == 1
1741+
stderr = re.sub(r"\s\s+", " ", stderr)
1742+
assert "tests/checker_wf/broken-wf4.cwl:12:5: outputSource not found" in stderr
1743+
assert "tests/checker_wf/broken-wf4.cwl#echo_w" in stderr
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.0
3+
class: CommandLineTool
4+
inputs:
5+
a_record:
6+
type:
7+
- "null"
8+
- type: record
9+
fields:
10+
first: string
11+
second: int
12+
third: float
13+
fourth: long
14+
fifth: double
15+
sixth: File
16+
default:
17+
first: y
18+
second: 23
19+
third: 2.3
20+
fourth: 4242424242
21+
fifth: 4200000000000000000000000000000000000000000
22+
sixth:
23+
class: File
24+
path: whale.txt
25+
arguments:
26+
- '{'
27+
- '"same_record": $(inputs.a_record)'
28+
- '}'
29+
outputs:
30+
same_record:
31+
type:
32+
type: record
33+
fields:
34+
first: string
35+
second: int
36+
third: float
37+
fourth: long
38+
fifth: double
39+
sixth: File
40+
baseCommand: echo
41+
stdout: cwl.output.json

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)