Skip to content

Commit 3d9cbca

Browse files
committed
draft schema for paramter restrictions extension
1 parent 84a297f commit 3d9cbca

File tree

5 files changed

+317
-1
lines changed

5 files changed

+317
-1
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ include cwltool/cwlNodeEngineJSConsole.js
5757
include cwltool/cwlNodeEngineWithContext.js
5858
include cwltool/extensions.yml
5959
include cwltool/extensions-v1.1.yml
60+
include cwltool/extensions-v1.2.yml
6061
include cwltool/jshint/jshint_wrapper.js
6162
include cwltool/jshint/jshint.js
6263
include cwltool/hello.simg

cwltool/extensions-v1.2.yml

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
$base: http://commonwl.org/cwltool#
2+
$namespaces:
3+
cwl: "https://w3id.org/cwl/cwl#"
4+
cwltool: "http://commonwl.org/cwltool#"
5+
$graph:
6+
- $import: https://w3id.org/cwl/CommonWorkflowLanguage.yml
7+
8+
- name: Secrets
9+
type: record
10+
inVocab: false
11+
extends: cwl:ProcessRequirement
12+
fields:
13+
class:
14+
type: string
15+
doc: "Always 'Secrets'"
16+
jsonldPredicate:
17+
"_id": "@type"
18+
"_type": "@vocab"
19+
secrets:
20+
type: string[]
21+
doc: |
22+
List one or more input parameters that are sensitive (such as passwords)
23+
which will be deliberately obscured from logging.
24+
jsonldPredicate:
25+
"_type": "@id"
26+
refScope: 0
27+
28+
29+
- name: ProcessGenerator
30+
type: record
31+
inVocab: true
32+
extends: cwl:Process
33+
documentRoot: true
34+
fields:
35+
- name: class
36+
jsonldPredicate:
37+
"_id": "@type"
38+
"_type": "@vocab"
39+
type: string
40+
- name: run
41+
type: [string, cwl:Process]
42+
jsonldPredicate:
43+
_id: "cwl:run"
44+
_type: "@id"
45+
subscope: run
46+
doc: |
47+
Specifies the process to run.
48+
49+
- name: MPIRequirement
50+
type: record
51+
inVocab: false
52+
extends: cwl:ProcessRequirement
53+
doc: |
54+
Indicates that a process requires an MPI runtime.
55+
fields:
56+
- name: class
57+
type: string
58+
doc: "Always 'MPIRequirement'"
59+
jsonldPredicate:
60+
"_id": "@type"
61+
"_type": "@vocab"
62+
- name: processes
63+
type: [int, cwl:Expression]
64+
doc: |
65+
The number of MPI processes to start. If you give a string,
66+
this will be evaluated as a CWL Expression and it must
67+
evaluate to an integer.
68+
69+
- name: CUDARequirement
70+
type: record
71+
extends: cwl:ProcessRequirement
72+
inVocab: false
73+
doc: |
74+
Require support for NVIDA CUDA (GPU hardware acceleration).
75+
fields:
76+
class:
77+
type: string
78+
doc: 'cwltool:CUDARequirement'
79+
jsonldPredicate:
80+
_id: "@type"
81+
_type: "@vocab"
82+
cudaVersionMin:
83+
type: string
84+
doc: |
85+
Minimum CUDA version to run the software, in X.Y format. This
86+
corresponds to a CUDA SDK release. When running directly on
87+
the host (not in a container) the host must have a compatible
88+
CUDA SDK (matching the exact version, or, starting with CUDA
89+
11.3, matching major version). When run in a container, the
90+
container image should provide the CUDA runtime, and the host
91+
driver is injected into the container. In this case, because
92+
CUDA drivers are backwards compatible, it is possible to
93+
use an older SDK with a newer driver across major versions.
94+
95+
See https://docs.nvidia.com/deploy/cuda-compatibility/ for
96+
details.
97+
cudaComputeCapability:
98+
type:
99+
- 'string'
100+
- 'string[]'
101+
doc: |
102+
CUDA hardware capability required to run the software, in X.Y
103+
format.
104+
105+
* If this is a single value, it defines only the minimum
106+
compute capability. GPUs with higher capability are also
107+
accepted.
108+
109+
* If it is an array value, then only select GPUs with compute
110+
capabilities that explicitly appear in the array.
111+
cudaDeviceCountMin:
112+
type: ['null', int, cwl:Expression]
113+
default: 1
114+
doc: |
115+
Minimum number of GPU devices to request. If not specified,
116+
same as `cudaDeviceCountMax`. If neither are specified,
117+
default 1.
118+
cudaDeviceCountMax:
119+
type: ['null', int, cwl:Expression]
120+
doc: |
121+
Maximum number of GPU devices to request. If not specified,
122+
same as `cudaDeviceCountMin`.
123+
124+
- name: intervalBase
125+
type: record
126+
abstract: true
127+
fields:
128+
low:
129+
type: [int, float, double]
130+
default: -.inf # negative infinity
131+
jsonldPredicate: "cwltool:low"
132+
high:
133+
type: [int, float, double]
134+
default: .inf # positive infinity
135+
jsonldPredicate: "cwltool:high"
136+
137+
- name: intInterval
138+
type: record
139+
extends: intervalBase
140+
doc: |
141+
Integer number interval specification. All integer intervals are inclusive.
142+
fields:
143+
class:
144+
type:
145+
type: enum
146+
name: intInterval_class
147+
symbols:
148+
- cwltool:intInterval
149+
jsonldPredicate:
150+
_id: "@type"
151+
_type: "@vocab"
152+
low:
153+
type: int
154+
default: -.inf # negative infinity
155+
jsonldPredicate: "cwltool:low"
156+
high:
157+
type: int
158+
default: .inf # positive infinity
159+
jsonldPredicate: "cwltool:high"
160+
# compact form proposal
161+
# doc: |
162+
# Examples:
163+
# "[0,3)" any real number between 0 (inclusive) and 3 (exclusive)
164+
# "[6,)" any real number greater than or equal to 6
165+
# "(0,1)" any real number between 0 and 1 (exclusive)
166+
167+
168+
- name: realInterval
169+
type: record
170+
extends: intervalBase
171+
doc: |
172+
Integer number interval
173+
fields:
174+
class:
175+
type:
176+
type: enum
177+
name: realInterval_class
178+
symbols:
179+
- cwltool:realInterval
180+
jsonldPredicate:
181+
_id: "@type"
182+
_type: "@vocab"
183+
low_inclusive:
184+
type: boolean
185+
default: true
186+
high_inclusive:
187+
type: boolean
188+
default: true
189+
# compact form proposal
190+
# doc: |
191+
# Use "(" or "[" to indicate an exclusive or inclusive beginning,
192+
# and ")" or "]" to indicate an exclusive or inclusive end.
193+
# Default is inclusive.
194+
# Examples:
195+
# "[0,3)" any real number between 0 (inclusive) and 3 (exclusive)
196+
# "[6,)" any real number greater than or equal to 6
197+
# "(0,1)" any real number between 0 and 1 (exclusive)
198+
199+
- name: regex
200+
type: record
201+
doc: |
202+
Regular Expression
203+
TODO: what type of regex?
204+
fields:
205+
class:
206+
type:
207+
type: enum
208+
name: regex_class
209+
symbols:
210+
- cwltool:regex
211+
jsonldPredicate:
212+
_id: "@type"
213+
_type: "@vocab"
214+
rpattern:
215+
type: string
216+
217+
218+
- name: Restrictions
219+
type: record
220+
fields:
221+
input:
222+
type: string
223+
jsonldPredicate:
224+
"_type": "@id"
225+
refScope: 2
226+
constraints:
227+
type:
228+
type: array
229+
items:
230+
- string
231+
- int
232+
- float
233+
- double
234+
- regex
235+
- cwl:Expression
236+
- intInterval
237+
- realInterval
238+
239+
- name: ParameterRestrictions
240+
type: record
241+
extends: cwl:ProcessRequirement
242+
inVocab: false
243+
doc: |
244+
Prototype of input value restrictions construct.
245+
fields:
246+
class:
247+
type:
248+
type: enum
249+
name: ParameterRestrictions_class
250+
symbols:
251+
- cwltool:ParameterRestrictions
252+
jsonldPredicate:
253+
_id: "@type"
254+
_type: "@vocab"
255+
restrictions:
256+
type: Restrictions[]
257+
jsonldPredicate:
258+
_id: "cwltool:restrictions"
259+
mapSubject: input
260+
mapPredicate: constraints
261+
doc: |
262+
(Only applicable for string, int, long, float and double parameters)
263+
List of restrictions that apply to the input parameter "id".
264+
A given parameter value should be accepted if any of the restrictions
265+
match the input. Restrictions can be
266+
single values (applies to all types),
267+
ranges of the same type (applies to int, float and double),
268+
regular expressions (for string parameters)
269+
or Expressions (if an expression is provided, the expression must
270+
return a boolean representing a match).
271+
If the parameter is an array type, every value has to match at least
272+
one of the restrictions.

cwltool/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,11 @@ def setup_schema(
661661
ext10 = res.read().decode("utf-8")
662662
with pkg_resources.resource_stream(__name__, "extensions-v1.1.yml") as res:
663663
ext11 = res.read().decode("utf-8")
664+
with pkg_resources.resource_stream(__name__, "extensions-v1.2.yml") as res:
665+
ext12 = res.read().decode("utf-8")
664666
use_custom_schema("v1.0", "http://commonwl.org/cwltool", ext10)
665667
use_custom_schema("v1.1", "http://commonwl.org/cwltool", ext11)
666-
use_custom_schema("v1.2", "http://commonwl.org/cwltool", ext11)
668+
use_custom_schema("v1.2", "http://commonwl.org/cwltool", ext12)
667669
use_custom_schema("v1.2.0-dev1", "http://commonwl.org/cwltool", ext11)
668670
use_custom_schema("v1.2.0-dev2", "http://commonwl.org/cwltool", ext11)
669671
use_custom_schema("v1.2.0-dev3", "http://commonwl.org/cwltool", ext11)

cwltool/process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def filter(self, record: logging.LogRecord) -> bool:
121121
"http://commonwl.org/cwltool#LoadListingRequirement",
122122
"http://commonwl.org/cwltool#InplaceUpdateRequirement",
123123
"http://commonwl.org/cwltool#CUDARequirement",
124+
"http://commonwl.org/cwltool#ParameterRestrictions",
124125
]
125126

126127
cwl_files = (

tests/parameter_restrictions.cwl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cwlVersion: v1.2
2+
class: CommandLineTool
3+
4+
doc: |
5+
Tests of paramater restrictions extension
6+
7+
inputs:
8+
one: double
9+
two: string
10+
11+
12+
hints:
13+
cwltool:ParameterRestrictions:
14+
restrictions:
15+
one:
16+
- class: cwltool:realInterval
17+
low: 0
18+
high: 3
19+
high_inclusive: false
20+
- class: cwltool:realInterval
21+
low: 6
22+
# high should be the default of positive infinity
23+
high_inclusive: false
24+
two:
25+
- class: cwltool:regex
26+
rpattern: "foo.*bar"
27+
28+
29+
baseCommand: echo
30+
31+
arguments:
32+
- $(inputs.one)
33+
- $(inputs.two)
34+
35+
outputs:
36+
result: stdout
37+
38+
$namespaces:
39+
cwltool: "http://commonwl.org/cwltool#"
40+

0 commit comments

Comments
 (0)