Skip to content

Commit 0d10398

Browse files
authored
Merge pull request #4 from bogdang989/feature/optional-secondary
Feature/optional secondary
2 parents d12c037 + 972ef42 commit 0d10398

File tree

6 files changed

+113
-20
lines changed

6 files changed

+113
-20
lines changed

CommandLineTool.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ $graph:
7777
input object documents.
7878
* Clarify behavior of `glob` for absolute paths and symlinks.
7979
* Clarify behavior of `glob` to include directories.
80+
* `secondaryFiles` can now be explicitly marked as `required` or not.
8081
8182
See also the [CWL Workflow Description, v1.1.0-dev1 changelog](Workflow.html#Changelog).
8283
@@ -207,7 +208,7 @@ $graph:
207208
`InputParameter.default` field) must be applied before evaluating the
208209
expression.
209210
210-
If the value of the associated input parameter is `null`, `valueFrom` is
211+
If the value of the associated input parameter is `null`, `valueFrom` is
211212
not evaluated and nothing is added to the command line.
212213
213214
When a binding is part of the `CommandLineTool.arguments` field,
@@ -249,7 +250,7 @@ $graph:
249250
items: string
250251
doc: |
251252
Find files or directories relative to the output directory, using POSIX
252-
glob(3) pathname matching. If an array is provided, find files or
253+
glob(3) pathname matching. If an array is provided, find files or
253254
directories that match any pattern in the array. If an expression is
254255
provided, the expression must return a string or an array of strings,
255256
which will then be evaluated as one or more glob patterns. Must only
@@ -932,14 +933,14 @@ $graph:
932933
- name: listing
933934
type:
934935
- type: array
935-
items:
936+
items:
936937
- "null"
937938
- File
938939
- type: array
939940
items:
940941
- File
941942
- Directory
942-
- Directory
943+
- Directory
943944
- Dirent
944945
- string
945946
- Expression

Process.yml

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ $graph:
237237
- "null"
238238
- type: array
239239
items: [File, Directory]
240-
jsonldPredicate: "cwl:secondaryFiles"
240+
jsonldPredicate:
241+
_id: "cwl:secondaryFiles"
242+
secondaryFilesDSL: true
241243
doc: |
242244
A list of additional files or directories that are associated with the
243245
primary file and must be transferred alongside the primary file.
@@ -458,20 +460,25 @@ $graph:
458460
secondaryFiles:
459461
type:
460462
- "null"
461-
- string
462-
- Expression
463+
- SecondaryFileSchema
463464
- type: array
464-
items: [string, Expression]
465-
jsonldPredicate: "cwl:secondaryFiles"
465+
items: SecondaryFileSchema
466+
jsonldPredicate:
467+
_id: "cwl:secondaryFiles"
468+
secondaryFilesDSL: true
466469
doc: |
467470
Only valid when `type: File` or is an array of `items: File`.
468471
469-
Provides a pattern or expression specifying files or directories that
470-
must be included alongside the primary file. An implementation must append
471-
these files/directories to the `secondaryFiles` property of the primary file.
472-
These files/directories must be transferred alongside the primary file.
473-
An implementation may fail workflow execution if an expected secondary file
474-
does not exist.
472+
Provides a pattern or expression specifying files or
473+
directories that should be included alongside the primary
474+
file. Secondary files may be required or optional. When not
475+
explicitly specified, secondary files specified for `inputs`
476+
are required and `outputs` are optional. An implementation
477+
must include matching Files and Directories in the
478+
`secondaryFiles` property of the primary file. These Files
479+
and Directories must be transferred and staged alongside the
480+
primary file. An implementation may fail workflow execution
481+
if a required secondary file does not exist.
475482
476483
If the value is an expression, the value of `self` in the expression
477484
must be the primary input or output File object to which this binding
@@ -482,6 +489,8 @@ $graph:
482489
`path` or `location` and `basename` fields set, or an array consisting
483490
of strings or File or Directory objects. It is legal to reference an
484491
unchanged File or Directory object taken from input as a secondaryFile.
492+
The expression may return "null" in which case there is no secondaryFile
493+
from that expression.
485494
486495
To work on non-filename-preserving storage systems, portable tool
487496
descriptions should avoid constructing new values from `location`, but
@@ -492,11 +501,13 @@ $graph:
492501
it specifies that the following pattern should be applied to the path
493502
of the primary file to yield a filename relative to the primary File:
494503
495-
1. If string begins with one or more caret `^` characters, for each
504+
1. If string ends with `?` character, remove the last `?` and mark
505+
the resulting secondary file as optional.
506+
2. If string begins with one or more caret `^` characters, for each
496507
caret, remove the last file extension from the path (the last
497508
period `.` and all following characters). If there are no file
498509
extensions, the path is unchanged.
499-
2. Append the remainder of the string to the end of the file path.
510+
3. Append the remainder of the string to the end of the file path.
500511
501512
streamable:
502513
type: boolean?
@@ -856,3 +867,50 @@ $graph:
856867
type: array
857868
items: CommandInputSchema
858869
doc: The list of type definitions.
870+
871+
- name: SecondaryFileSchema
872+
type: record
873+
fields:
874+
- name: pattern
875+
type:
876+
- string
877+
- Expression
878+
doc: |
879+
Provides a pattern or expression specifying files or directories that
880+
should be included alongside the primary file.
881+
882+
If the value is an expression, the value of `self` in the expression
883+
must be the primary input or output File object to which this binding
884+
applies. The `basename`, `nameroot` and `nameext` fields must be
885+
present in `self`. For `CommandLineTool` outputs the `path` field must
886+
also be present. The expression must return a filename string relative
887+
to the path to the primary File, a File or Directory object with either
888+
`path` or `location` and `basename` fields set, or an array consisting
889+
of strings or File or Directory objects. It is legal to reference an
890+
unchanged File or Directory object taken from input as a secondaryFile.
891+
The expression may return "null" in which case there is no secondaryFile
892+
from that expression.
893+
894+
To work on non-filename-preserving storage systems, portable tool
895+
descriptions should avoid constructing new values from `location`, but
896+
should construct relative references using `basename` or `nameroot`
897+
instead.
898+
899+
If a value in `secondaryFiles` is a string that is not an expression,
900+
it specifies that the following pattern should be applied to the path
901+
of the primary file to yield a filename relative to the primary File:
902+
903+
1. If string begins with one or more caret `^` characters, for each
904+
caret, remove the last file extension from the path (the last
905+
period `.` and all following characters). If there are no file
906+
extensions, the path is unchanged.
907+
2. If string ends with `?` character, remove the last `?` and mark
908+
the resulting secondary file as optional.
909+
3. Append the remainder of the string to the end of the file path.
910+
- name: required
911+
type: ["null", boolean, string, Expression]
912+
doc: |
913+
An implementation must not fail workflow execution if `required` is
914+
set to `false` and the expected secondary file does not exist.
915+
Default value for `required` field is `true` for secondary files on
916+
input and `false` for secondary files on output.

Workflow.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ $graph:
7171
* `WorkflowStepInput` now has a `label` field
7272
* [Addition](#Requirements_and_hints) of `cwl:requirments` field to
7373
input object documents
74+
* `secondaryFiles` can now be explicitly marked as `required` or not.
7475
7576
See also the [CWL Command Line Tool Description, v1.1.0-dev1 changelog](CommandLineTool.html#Changelog).
7677
@@ -331,7 +332,7 @@ $graph:
331332
1. `null` if there is no `source` field
332333
2. the value of the parameter(s) specified in the `source` field when this
333334
workflow input parameter **is not** specified in this workflow step's `scatter` field.
334-
3. an element of the parameter specified in the `source` field when this workflow input
335+
3. an element of the parameter specified in the `source` field when this workflow input
335336
parameter **is** specified in this workflow step's `scatter` field.
336337
337338
The value of `inputs` in the parameter reference or expression must be

conformance_tests.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,15 @@
13661366
tool: tests/docker-array-secondaryfiles.cwl
13671367
label: filesarray_secondaryfiles
13681368
id: 100
1369-
doc: Test secondaryFiles on array of files.
1369+
doc: Test required, optional and null secondaryFiles on array of files.
1370+
tags: [ docker, inline_javascript, shell_command, command_line_tool ]
1371+
1372+
- job: tests/docker-array-secondaryfiles-job2.json
1373+
should_fail: true
1374+
tool: tests/docker-array-secondaryfiles.cwl
1375+
label: filesarray_secondaryfiles2
1376+
id: 100
1377+
doc: Test required, optional and null secondaryFiles on array of files.
13701378
tags: [ docker, inline_javascript, shell_command, command_line_tool ]
13711379

13721380
- job: tests/dir7.yml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"fasta_path": [
3+
{
4+
"class": "File",
5+
"location": "ref.fasta"
6+
},
7+
{
8+
"class": "File",
9+
"location": "ref2.fasta"
10+
}
11+
],
12+
"require_dat": true
13+
}

tests/docker-array-secondaryfiles.cwl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ inputs:
1616
type: array
1717
items: File
1818
secondaryFiles:
19-
- .fai
19+
- pattern: .fai
20+
required: true
21+
- pattern: .crai
22+
required: false
23+
- .bai?
24+
- "${ if (inputs.require_dat) {return '.dat'} else {return null} }"
25+
- "${ return null; }"
26+
- pattern: .dat2
27+
required: $(inputs.require_dat)
28+
require_dat: boolean?
2029

2130
outputs:
2231
bai_list:
2332
type: File
2433
outputBinding:
2534
glob: "fai.list"
35+
secondaryFiles:
36+
- .bai?
37+
- pattern: "${ return null }"
2638

2739
arguments:
2840
- valueFrom: ${

0 commit comments

Comments
 (0)