Skip to content

Commit 36f12cf

Browse files
AlexTatemr-c
authored andcommitted
Using a different approach to remove the "one job per core" resource constraint. The current ResourceRequirement implementation doesn't allow {coresMin: 0}. However, this can still be achieved with a custom RuntimeContext.select_resources()
1 parent 2b9d76a commit 36f12cf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tests/test_parallel.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import time
3+
import math
34
from pathlib import Path
45

56
from cwltool.context import RuntimeContext
@@ -34,8 +35,19 @@ def test_scattered_workflow() -> None:
3435

3536
def test_on_error_kill() -> None:
3637
test_file = "tests/wf/on-error_kill.cwl"
38+
def selectResources(request, _):
39+
# Remove the "one job per core" resource constraint so that
40+
# parallel jobs aren't withheld on machines with few cores
41+
return {
42+
"cores": 0,
43+
"ram": math.ceil(request["ramMin"]), # default
44+
"tmpdirSize": math.ceil(request["tmpdirMin"]), # default
45+
"outdirSize": math.ceil(request["outdirMin"]), # default
46+
}
47+
3748
runtime_context = RuntimeContext()
3849
runtime_context.on_error = "kill"
50+
runtime_context.select_resources = selectResources
3951
factory = Factory(MultithreadedJobExecutor(), None, runtime_context)
4052
ks_test = factory.make(get_data(test_file))
4153

tests/wf/on-error_kill.cwl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ requirements:
66
ScatterFeatureRequirement: {}
77
InlineJavascriptRequirement: {}
88
StepInputExpressionRequirement: {}
9-
ResourceRequirement: {coresMin: 0, ramMin: 0}
109

1110

1211
doc: |

0 commit comments

Comments
 (0)