Skip to content

Commit e74df48

Browse files
authored
Permit fractional storage values in ResourceRequirement (#1327)
* Add 1.2.0-dev5 * Permit fractional storage values in ResourceRequirement * Make sure parallel executor sets tmpdirSize and outdirSize
1 parent eba8091 commit e74df48

File tree

111 files changed

+67813
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+67813
-68
lines changed

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ include cwltool/schemas/v1.2.0-dev4/*.yml
3737
include cwltool/schemas/v1.2.0-dev4/*.md
3838
include cwltool/schemas/v1.2.0-dev4/salad/schema_salad/metaschema/*.yml
3939
include cwltool/schemas/v1.2.0-dev4/salad/schema_salad/metaschema/*.md
40+
include cwltool/schemas/v1.2.0-dev5/*.yml
41+
include cwltool/schemas/v1.2.0-dev5/*.md
42+
include cwltool/schemas/v1.2.0-dev5/salad/schema_salad/metaschema/*.yml
43+
include cwltool/schemas/v1.2.0-dev5/salad/schema_salad/metaschema/*.md
4044
include cwltool/cwlNodeEngine.js
4145
include cwltool/cwlNodeEngineJSConsole.js
4246
include cwltool/cwlNodeEngineWithContext.js

cwltool/executors.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Single and multi-threaded executors."""
33
import datetime
44
import logging
5+
import math
56
import os
67
import tempfile
78
import threading
@@ -303,10 +304,13 @@ def select_resources(
303304
% (request[rsc + "Min"], rsc, maxrsc[rsc])
304305
)
305306
if request[rsc + "Max"] < maxrsc[rsc]:
306-
result[rsc] = request[rsc + "Max"]
307+
result[rsc] = math.ceil(request[rsc + "Max"])
307308
else:
308309
result[rsc] = maxrsc[rsc]
309310

311+
result["tmpdirSize"] = math.ceil(request["tmpdirMin"])
312+
result["outdirSize"] = math.ceil(request["outdirMin"])
313+
310314
return result
311315

312316
def _runner(self, job, runtime_context, TMPDIR_LOCK):

cwltool/process.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import hashlib
66
import json
77
import logging
8+
import math
89
import os
910
import shutil
1011
import stat
@@ -1004,9 +1005,9 @@ def evalResources(
10041005
return runtimeContext.select_resources(request, runtimeContext)
10051006
return {
10061007
"cores": request["coresMin"],
1007-
"ram": request["ramMin"],
1008-
"tmpdirSize": request["tmpdirMin"],
1009-
"outdirSize": request["outdirMin"],
1008+
"ram": math.ceil(request["ramMin"]),
1009+
"tmpdirSize": math.ceil(request["tmpdirMin"]),
1010+
"outdirSize": math.ceil(request["outdirMin"]),
10101011
}
10111012

10121013
def validate_hints(

cwltool/schemas/v1.2.0-dev4/CommandLineTool.yml

Lines changed: 123 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ $graph:
5353
5454
* `coresMin` and `coresMax` of
5555
[ResourceRequirement](#ResourceRequirement) may now request fractional CPUs.
56+
* `ramMin`, `ramMax`, `tmpdirMin`, `tmpdirMax`, `outdirMin`, and `outdirMax` of
57+
[ResourceRequirement](#ResourceRequirement) now accept floating point values.
5658
* (CommandLineTool)[#CommandLineTool] can now express `intent`
5759
with an identifier for the type of computational operation.
5860
* Added conformance tests for order of operations evaluating `secondaryFiles` on input
@@ -68,10 +70,20 @@ $graph:
6870
* Note that only enum and record types can be typedef-ed
6971
* Added conformance tests for order of operations evaluating `secondaryFiles` on input
7072
and ensure that input and output secondaryFiles expressions can return a File object.
71-
* Escaping in "string interpolation":#String_Interpolation has
73+
* Escaping in [string interpolation](#String_Interpolation) has
7274
been added to the specification along with conformance tests.
75+
* It is now possible to have an absolute path in the `entryname`
76+
field in
77+
[InitialWorkDirRequirement](#InitialWorkDirRequirement) when
78+
running in a mandatory container. Together with
79+
`DockerRequirement.dockerOutputDirectory` this it possible to
80+
control the locations of both input and output files when
81+
running in containers.
82+
* Specify default success/fail interpretation of exit codes when not given.
7383
7484
See also the [CWL Workflow Description, v1.2.0-dev4 changelog](Workflow.html#Changelog).
85+
For other changes since CWL v1.0, see the
86+
[CWL Command Line Tool Description, v1.1 changelog](https://www.commonwl.org/v1.1/CommandLineTool.html#Changelog)
7587
7688
## Purpose
7789
@@ -305,7 +317,7 @@ $graph:
305317
306318
If a tool needs to return a large amount of structured data to
307319
the workflow, loading the output object from `cwl.output.json`
308-
bypasses `outputEval` but is not subject to the 64 KiB
320+
bypasses `outputEval` and is not subject to the 64 KiB
309321
`loadContents` limit.
310322
311323
- name: CommandLineBindable
@@ -693,20 +705,26 @@ $graph:
693705
doc: |
694706
Exit codes that indicate the process completed successfully.
695707
708+
If not specified, only exit code 0 is considered success.
709+
696710
- name: temporaryFailCodes
697711
type: int[]?
698712
doc: |
699713
Exit codes that indicate the process failed due to a possibly
700714
temporary condition, where executing the process with the same
701715
runtime environment and inputs may produce different results.
702716
717+
If not specified, no exit codes are considered temporary failure.
718+
703719
- name: permanentFailCodes
704720
type: int[]?
705721
doc:
706722
Exit codes that indicate the process failed due to a permanent logic
707723
error, where executing the process with the same runtime environment and
708724
same inputs is expected to always fail.
709725

726+
If not specified, all exit codes except 0 are considered permanent failure.
727+
710728

711729
- type: record
712730
name: DockerRequirement
@@ -883,25 +901,46 @@ $graph:
883901
- name: Dirent
884902
type: record
885903
doc: |
886-
Define a file or subdirectory that must be placed in the designated output
887-
directory prior to executing the command line tool. May be the result of
888-
executing an expression, such as building a configuration file from a
889-
template.
904+
Define a file or subdirectory that must be staged to a particular
905+
place prior to executing the command line tool. May be the result
906+
of executing an expression, such as building a configuration file
907+
from a template.
908+
909+
Usually files are staged within the [designated output directory](#Runtime_environment).
910+
However, under certain circumstances, files may be staged at
911+
arbitrary locations, see discussion for `entryname`.
912+
890913
fields:
891914
- name: entryname
892915
type: ["null", string, Expression]
893916
jsonldPredicate:
894917
_id: cwl:entryname
895918
doc: |
896-
The name of the file or subdirectory to create in the output
897-
directory. If `entry` is a File or Directory, the `entryname`
898-
field overrides the value of `basename` of the File or
899-
Directory object.
919+
The "target" name of the file or subdirectory. If `entry` is
920+
a File or Directory, the `entryname` field overrides the value
921+
of `basename` of the File or Directory object.
900922
901923
* Required when `entry` evaluates to file contents only
902924
* Optional when `entry` evaluates to a File or Directory object with a `basename`
903925
* Invalid when `entry` evaluates to an array of File or Directory objects.
904926
927+
If `entryname` is a relative path, it specifies a name within
928+
the designated output directory. A relative path starting
929+
with `../` or that resolves to location above the designated output directory is an error.
930+
931+
If `entryname` is an absolute path (starts with a slash `/`)
932+
it is an error unless the following conditions are met:
933+
934+
* `DockerRequirement` is present in `requirements`
935+
* The program is will run inside a software container
936+
where, from the perspective of the program, the root
937+
filesystem is not shared with any other user or
938+
running program.
939+
940+
In this case, and the above conditions are met, then
941+
`entryname` may specify the absolute path within the container
942+
where the file or directory must be placed.
943+
905944
- name: entry
906945
type: [string, Expression]
907946
jsonldPredicate:
@@ -956,9 +995,16 @@ $graph:
956995
type: record
957996
extends: ProcessRequirement
958997
doc:
959-
Define a list of files and subdirectories that must be created by the
960-
workflow platform in the designated output directory prior to executing the
961-
command line tool.
998+
Define a list of files and subdirectories that must be staged by
999+
the workflow platform prior to executing the command line tool.
1000+
1001+
Normally files are staged within the designated output directory.
1002+
However, when running inside containers, files may be staged at
1003+
arbitrary locations, see discussion for `Dirent.entryname`.
1004+
Together with `DockerRequirement.dockerOutputDirectory` this it
1005+
possible to control the locations of both input and output files
1006+
when running in containers.
1007+
9621008
fields:
9631009
- name: class
9641010
type: string
@@ -983,8 +1029,8 @@ $graph:
9831029
jsonldPredicate:
9841030
_id: "cwl:listing"
9851031
doc: |
986-
The list of files or subdirectories that must be placed in the
987-
designated output directory prior to executing the command line tool.
1032+
The list of files or subdirectories that must be staged prior
1033+
to executing the command line tool.
9881034
9891035
Return type of each expression must validate as `["null",
9901036
File, Directory, Dirent, {type: array, items: [File,
@@ -1000,12 +1046,13 @@ $graph:
10001046
10011047
Expressions may return null, in which case they have no effect.
10021048
1003-
Files or Directories which are listed in the input parameters and
1004-
appear in the `InitialWorkDirRequirement` listing must have their
1005-
`path` set to their staged location in the designated output directory.
1006-
If the same File or Directory appears more than once in the
1007-
`InitialWorkDirRequirement` listing, the implementation must choose
1008-
exactly one value for `path`; how this value is chosen is undefined.
1049+
Files or Directories which are listed in the input parameters
1050+
and appear in the `InitialWorkDirRequirement` listing must
1051+
have their `path` set to their staged location. If the same
1052+
File or Directory appears more than once in the
1053+
`InitialWorkDirRequirement` listing, the implementation must
1054+
choose exactly one value for `path`; how this value is chosen
1055+
is undefined.
10091056
10101057
10111058
- name: EnvVarRequirement
@@ -1055,15 +1102,20 @@ $graph:
10551102
doc: |
10561103
Specify basic hardware resource requirements.
10571104
1058-
"min" is the minimum amount of a resource that must be reserved to schedule
1059-
a job. If "min" cannot be satisfied, the job should not be run.
1105+
"min" is the minimum amount of a resource that must be reserved to
1106+
schedule a job. If "min" cannot be satisfied, the job should not
1107+
be run.
1108+
1109+
"max" is the maximum amount of a resource that the job shall be
1110+
allocated. If a node has sufficient resources, multiple jobs may
1111+
be scheduled on a single node provided each job's "max" resource
1112+
requirements are met. If a job attempts to exceed its resource
1113+
allocation, an implementation may deny additional resources, which
1114+
may result in job failure.
10601115
1061-
"max" is the maximum amount of a resource that the job shall be permitted
1062-
to use. If a node has sufficient resources, multiple jobs may be scheduled
1063-
on a single node provided each job's "max" resource requirements are
1064-
met. If a job attempts to exceed its "max" resource allocation, an
1065-
implementation may deny additional resources, which may result in job
1066-
failure.
1116+
If both "min" and "max" are specified, an implementation may
1117+
choose to allocate any amount between "min" and "max", with the
1118+
actual allocation provided in the `runtime` object.
10671119
10681120
If "min" is specified but "max" is not, then "max" == "min"
10691121
If "max" is specified by "min" is not, then "min" == "max".
@@ -1118,28 +1170,58 @@ $graph:
11181170
See `coresMin` for discussion about fractional CPU requests.
11191171
11201172
- name: ramMin
1121-
type: ["null", long, Expression]
1122-
doc: Minimum reserved RAM in mebibytes (2**20) (default is 256)
1173+
type: ["null", long, float, Expression]
1174+
doc: |
1175+
Minimum reserved RAM in mebibytes (2**20) (default is 256)
1176+
1177+
May be a fractional value. If so, the actual RAM request must
1178+
be rounded up to the next whole number. The reported amount of
1179+
RAM reserved for the process, which is available to
1180+
expressions on the CommandLineTool as `runtime.ram`, must be a
1181+
non-zero integer.
11231182
11241183
- name: ramMax
1125-
type: ["null", long, Expression]
1126-
doc: Maximum reserved RAM in mebibytes (2**20)
1184+
type: ["null", long, float, Expression]
1185+
doc: |
1186+
Maximum reserved RAM in mebibytes (2**20)
1187+
1188+
See `ramMin` for discussion about fractional RAM requests.
11271189
11281190
- name: tmpdirMin
1129-
type: ["null", long, Expression]
1130-
doc: Minimum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20) (default is 1024)
1191+
type: ["null", long, float, Expression]
1192+
doc: |
1193+
Minimum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20) (default is 1024)
1194+
1195+
May be a fractional value. If so, the actual storage request
1196+
must be rounded up to the next whole number. The reported
1197+
amount of storage reserved for the process, which is available
1198+
to expressions on the CommandLineTool as `runtime.tmpdirSize`,
1199+
must be a non-zero integer.
11311200
11321201
- name: tmpdirMax
1133-
type: ["null", long, Expression]
1134-
doc: Maximum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20)
1202+
type: ["null", long, float, Expression]
1203+
doc: |
1204+
Maximum reserved filesystem based storage for the designated temporary directory, in mebibytes (2**20)
1205+
1206+
See `tmpdirMin` for discussion about fractional storage requests.
11351207
11361208
- name: outdirMin
1137-
type: ["null", long, Expression]
1138-
doc: Minimum reserved filesystem based storage for the designated output directory, in mebibytes (2**20) (default is 1024)
1209+
type: ["null", long, float, Expression]
1210+
doc: |
1211+
Minimum reserved filesystem based storage for the designated output directory, in mebibytes (2**20) (default is 1024)
1212+
1213+
May be a fractional value. If so, the actual storage request
1214+
must be rounded up to the next whole number. The reported
1215+
amount of storage reserved for the process, which is available
1216+
to expressions on the CommandLineTool as `runtime.outdirSize`,
1217+
must be a non-zero integer.
11391218
11401219
- name: outdirMax
1141-
type: ["null", long, Expression]
1142-
doc: Maximum reserved filesystem based storage for the designated output directory, in mebibytes (2**20)
1220+
type: ["null", long, float, Expression]
1221+
doc: |
1222+
Maximum reserved filesystem based storage for the designated output directory, in mebibytes (2**20)
1223+
1224+
See `outdirMin` for discussion about fractional storage requests.
11431225
11441226
11451227
- type: record

0 commit comments

Comments
 (0)