Skip to content

Commit 51c5fb7

Browse files
mr-cSGSSGene
andcommitted
job loading: allow inputs named "id"
Co-authored-by: Simon Gene Gottlieb <[email protected]>
1 parent 5e5615b commit 51c5fb7

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

cwltool/load_tool.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,23 @@
4343
from .update import ALLUPDATES
4444
from .utils import CWLObjectType, ResolverType, visit_class
4545

46-
jobloaderctx: ContextType = {
46+
docloaderctx: ContextType = {
4747
"cwl": "https://w3id.org/cwl/cwl#",
4848
"cwltool": "http://commonwl.org/cwltool#",
4949
"path": {"@type": "@id"},
5050
"location": {"@type": "@id"},
5151
"id": "@id",
5252
}
5353

54+
jobloader_id_name = "__id"
55+
jobloaderctx: ContextType = {
56+
"cwl": "https://w3id.org/cwl/cwl#",
57+
"cwltool": "http://commonwl.org/cwltool#",
58+
"path": {"@type": "@id"},
59+
"location": {"@type": "@id"},
60+
jobloader_id_name: "@id",
61+
}
62+
5463

5564
overrides_ctx: ContextType = {
5665
"overrideTarget": {"@type": "@id"},
@@ -72,7 +81,7 @@ def default_loader(
7281
doc_cache: bool = True,
7382
) -> Loader:
7483
return Loader(
75-
jobloaderctx,
84+
docloaderctx,
7685
fetcher_constructor=fetcher_constructor,
7786
allow_attachments=lambda r: enable_dev,
7887
doc_cache=doc_cache,

cwltool/main.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
from .load_tool import (
7171
default_loader,
7272
fetch_document,
73+
jobloader_id_name,
7374
jobloaderctx,
7475
load_overrides,
7576
make_tool,
@@ -446,7 +447,7 @@ def init_job_order(
446447
_logger.exception("Failed to resolv job_order: %s", cmd_line["job_order"])
447448
exit(1)
448449
else:
449-
job_order_object = {"id": args.workflow}
450+
job_order_object = {jobloader_id_name: args.workflow}
450451

451452
del cmd_line["job_order"]
452453

@@ -506,7 +507,7 @@ def expand_formats(p: CWLObjectType) -> None:
506507
process.inputs_record_schema, job_order_object, discover_secondaryFiles=True
507508
)
508509
basedir: Optional[str] = None
509-
uri = cast(str, job_order_object["id"])
510+
uri = cast(str, job_order_object[jobloader_id_name])
510511
if uri == args.workflow:
511512
basedir = os.path.dirname(uri)
512513
uri = ""
@@ -529,8 +530,8 @@ def expand_formats(p: CWLObjectType) -> None:
529530

530531
if "cwl:tool" in job_order_object:
531532
del job_order_object["cwl:tool"]
532-
if "id" in job_order_object:
533-
del job_order_object["id"]
533+
if jobloader_id_name in job_order_object:
534+
del job_order_object[jobloader_id_name]
534535
return job_order_object
535536

536537

tests/test_examples.py

+13
Original file line numberDiff line numberDiff line change
@@ -1859,3 +1859,16 @@ def test_invalid_nested_array() -> None:
18591859
assert (
18601860
"tests/nested-array.cwl:6:5: Field 'type' references unknown identifier 'string[][]'"
18611861
) in stderr
1862+
1863+
1864+
def test_input_named_id() -> None:
1865+
"""Confirm that it is valid to have an input named "id"."""
1866+
exit_code, stdout, stderr = get_main_output(
1867+
[
1868+
"--validate",
1869+
"--debug",
1870+
get_data("tests/wf/input_named_id.cwl"),
1871+
get_data("tests/wf/input_named_id.yaml"),
1872+
]
1873+
)
1874+
assert exit_code == 0, stderr

tests/wf/input_named_id.cwl

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
label: FeatureFinderIdentification
2+
doc: ""
3+
inputs:
4+
id:
5+
doc: featureXML or consensusXML file
6+
type: File
7+
outputs:
8+
[]
9+
cwlVersion: v1.2
10+
class: CommandLineTool
11+
baseCommand:
12+
- FeatureFinderIdentification
13+

tests/wf/input_named_id.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id:
2+
class: File
3+
path: ../2.fastq

0 commit comments

Comments
 (0)