Skip to content

Commit

Permalink
Fix #811 (SchemaDefRequirements not working in workflows)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHickman authored and mr-c committed Sep 6, 2021
1 parent 23c5aab commit 8f9a9ef
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ def __init__(
validation_errors = []
self.tool = toolpath_object = copy.deepcopy(toolpath_object)
bound = set()

if self.embedded_tool.get_requirement("SchemaDefRequirement")[0]:
if "requirements" not in toolpath_object:
toolpath_object["requirements"] = []
toolpath_object["requirements"].append(
self.embedded_tool.get_requirement("SchemaDefRequirement")[0]
)

for stepfield, toolfield in (("in", "inputs"), ("out", "outputs")):
toolpath_object[toolfield] = []
for index, step_entry in enumerate(toolpath_object[stepfield]):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,3 +1576,14 @@ def test_staging_files_in_any() -> None:
[get_data("tests/wf/816_wf.cwl"), "--file", get_data("tests/echo-job.yaml")]
)
assert err_code == 0


def test_custom_type_in_step_process() -> None:
"""Test that any needed custom types are available when processing a WorkflowStep."""
err_code, _, stderr = get_main_output(
[
get_data("tests/wf/811.cwl"),
get_data("tests/wf/811_inputs.yml"),
]
)
assert err_code == 0
15 changes: 15 additions & 0 deletions tests/wf/811.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cwlVersion: v1.0
class: Workflow

inputs:
- id: hello
type: Any
outputs: []

steps:
step:
id: step
run: schemadef-tool.cwl
in:
hello: hello
out: []
4 changes: 4 additions & 0 deletions tests/wf/811_inputs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello:
a: one
b: two

24 changes: 24 additions & 0 deletions tests/wf/schemadef-tool.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env cwl-runner
class: CommandLineTool
cwlVersion: v1.0
hints:
ResourceRequirement:
ramMin: 8

requirements:
- $import: schemadef-type.yml

inputs:
- id: hello
type: "schemadef-type.yml#HelloType"
inputBinding:
valueFrom: $(self.a)/$(self.b)

outputs:
- id: output
type: File
outputBinding:
glob: output.txt

stdout: output.txt
baseCommand: echo
9 changes: 9 additions & 0 deletions tests/wf/schemadef-type.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class: SchemaDefRequirement
types:
- name: HelloType
type: record
fields:
- name: a
type: string
- name: b
type: string

0 comments on commit 8f9a9ef

Please sign in to comment.