Skip to content

Commit 8f9a9ef

Browse files
ThomasHickmanmr-c
authored andcommitted
Fix #811 (SchemaDefRequirements not working in workflows)
1 parent 23c5aab commit 8f9a9ef

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

cwltool/workflow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ def __init__(
243243
validation_errors = []
244244
self.tool = toolpath_object = copy.deepcopy(toolpath_object)
245245
bound = set()
246+
247+
if self.embedded_tool.get_requirement("SchemaDefRequirement")[0]:
248+
if "requirements" not in toolpath_object:
249+
toolpath_object["requirements"] = []
250+
toolpath_object["requirements"].append(
251+
self.embedded_tool.get_requirement("SchemaDefRequirement")[0]
252+
)
253+
246254
for stepfield, toolfield in (("in", "inputs"), ("out", "outputs")):
247255
toolpath_object[toolfield] = []
248256
for index, step_entry in enumerate(toolpath_object[stepfield]):

tests/test_examples.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,3 +1576,14 @@ def test_staging_files_in_any() -> None:
15761576
[get_data("tests/wf/816_wf.cwl"), "--file", get_data("tests/echo-job.yaml")]
15771577
)
15781578
assert err_code == 0
1579+
1580+
1581+
def test_custom_type_in_step_process() -> None:
1582+
"""Test that any needed custom types are available when processing a WorkflowStep."""
1583+
err_code, _, stderr = get_main_output(
1584+
[
1585+
get_data("tests/wf/811.cwl"),
1586+
get_data("tests/wf/811_inputs.yml"),
1587+
]
1588+
)
1589+
assert err_code == 0

tests/wf/811.cwl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cwlVersion: v1.0
2+
class: Workflow
3+
4+
inputs:
5+
- id: hello
6+
type: Any
7+
outputs: []
8+
9+
steps:
10+
step:
11+
id: step
12+
run: schemadef-tool.cwl
13+
in:
14+
hello: hello
15+
out: []

tests/wf/811_inputs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hello:
2+
a: one
3+
b: two
4+

tests/wf/schemadef-tool.cwl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env cwl-runner
2+
class: CommandLineTool
3+
cwlVersion: v1.0
4+
hints:
5+
ResourceRequirement:
6+
ramMin: 8
7+
8+
requirements:
9+
- $import: schemadef-type.yml
10+
11+
inputs:
12+
- id: hello
13+
type: "schemadef-type.yml#HelloType"
14+
inputBinding:
15+
valueFrom: $(self.a)/$(self.b)
16+
17+
outputs:
18+
- id: output
19+
type: File
20+
outputBinding:
21+
glob: output.txt
22+
23+
stdout: output.txt
24+
baseCommand: echo

tests/wf/schemadef-type.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class: SchemaDefRequirement
2+
types:
3+
- name: HelloType
4+
type: record
5+
fields:
6+
- name: a
7+
type: string
8+
- name: b
9+
type: string

0 commit comments

Comments
 (0)