Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cwltool/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,19 @@ def __init__(

loadingContext = loadingContext.copy()

parent_requirements = copy.deepcopy(getdefault(loadingContext.requirements, []))
loadingContext.requirements = copy.deepcopy(
getdefault(loadingContext.requirements, [])
toolpath_object.get("requirements", [])
)
assert loadingContext.requirements is not None # nosec
loadingContext.requirements.extend(toolpath_object.get("requirements", []))
for parent_req in parent_requirements:
found_in_step = False
for step_req in loadingContext.requirements:
if parent_req["class"] == step_req["class"]:
found_in_step = True
break
if not found_in_step:
loadingContext.requirements.append(parent_req)
loadingContext.requirements.extend(
cast(
List[CWLObjectType],
Expand Down
33 changes: 33 additions & 0 deletions tests/subgraph/steplevel-resreq.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.2

requirements:
ResourceRequirement:
coresMin: 4
coresMax: 4

inputs: []

steps:
step1:
requirements:
ResourceRequirement:
coresMin: 1
coresMax: 1
run:
class: CommandLineTool
inputs: []
outputs:
output:
type: stdout
baseCommand: echo
stdout: cores.txt
arguments: [ $(runtime.cores) ]
in: []
out: [output]

outputs:
out:
type: File
outputSource: step1/output
16 changes: 16 additions & 0 deletions tests/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ def test_single_process_inherit_reqs_collision() -> None:
)


def test_single_process_inherit_reqs_step_collision() -> None:
"""Inherit reqs and hints --single-process reqs collision."""
err_code, stdout, stderr = get_main_output(
[
"--single-process",
"step1",
get_data("tests/subgraph/steplevel-resreq.cwl"),
]
)
assert err_code == 0
assert (
json.loads(stdout)["output"]["checksum"]
== "sha1$e5fa44f2b31c1fb553b6021e7360d07d5d91ff5e"
)


def test_single_process_inherit_reqs_hints_collision() -> None:
"""Inherit reqs and hints --single-process reqs + hints collision."""
err_code, stdout, stderr = get_main_output(
Expand Down