Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CWL 1.x) WIP Feature/add metadata #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions CommandLineTool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ $graph:
- loadContents
- outputEval
- secondaryFiles
- addMetadata
fields:
- name: glob
type:
Expand Down Expand Up @@ -251,6 +252,23 @@ $graph:
array of a single element. Additionally, if `loadContents` is `true`,
the File objects must include up to the first 64 KiB of file contents
in the `contents` field.
- name: addMetadata
type:
- "null"
- string
- Expression
- string[]
doc: |
If the value is an expression, expression should return a key-value map.
Returned map should be set as the `metadata` property of the output file
or files. The same map should be set as the `metadata` property of all
secondary files.

If the value is a string or an array of strings, these must be input
parameter references. The `metadata` fields for the referenced inputs are
intersected and the resulting key-value map is set as the `metadata`
property of the output file or files. The same map should be set as the
`metadata` property of all secondary files.

- name: CommandLineBindable
type: record
Expand Down
8 changes: 8 additions & 0 deletions Process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ $graph:
If `loadContents` of `inputBinding` or `outputBinding` is true and
`location` is valid, the implementation must read up to the first 64
KiB of text from the file and place it in the "contents" field.
- name: metadata
type: Any?
doc: |
Metadata should be a key-value map further describing a `File`.
Metadata can be propagated from inputs to outputs of a tool using
`addMetadata` option in the `CommandOutputBinding`. It is up to the
implementation to make use of the `metadata` property of final outputs
of the execution.


- name: Directory
Expand Down
58 changes: 58 additions & 0 deletions conformance_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1768,3 +1768,61 @@
tool: tests/networkaccess2.cwl
doc: Test networkaccess is disabled by default
tags: [ networkaccess ]



- job: tests/inherit-metadata-job.yml
output: {
"out": {
"basename": "out",
"checksum": "sha1$4a7edca069beb3fbdcc3ce9d8626025d262c046a",
"class": "File",
"location": "out",
"metadata": {
"foo": 1,
"hello": "world"
},
"secondaryFiles": [
{
"basename": "out",
"checksum": "sha1$4a7edca069beb3fbdcc3ce9d8626025d262c046a",
"class": "File",
"location": "out",
"metadata": {
"foo": 1,
"hello": "world"
},
"size": 23
}
],
"size": 23
},
"out_intersected": [
{
"basename": "out",
"checksum": "sha1$4a7edca069beb3fbdcc3ce9d8626025d262c046a",
"class": "File",
"location": "out",
"metadata": {
"hello": "world"
},
"secondaryFiles": [
{
"basename": "out",
"checksum": "sha1$4a7edca069beb3fbdcc3ce9d8626025d262c046a",
"class": "File",
"location": "out",
"metadata": {
"hello": "world"
},
"size": 23
}
],
"size": 23
}
]
}
tool: tests/inherit-metadata.cwl
doc: Test addmetadata via expression or input id
tags: [ addmetadata ]

12 changes: 12 additions & 0 deletions tests/inherit-metadata-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
input_file:
class: File
path: hello.txt
metadata:
hello: world
foo: 1
input_list:
- class: File
path: whale.txt
metadata:
hello: world
foo: 2
37 changes: 37 additions & 0 deletions tests/inherit-metadata.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env cwl-runner

class: CommandLineTool
cwlVersion: v1.1.0-dev1
baseCommand:
- echo
- this
- file
- has
- metadata
inputs:
- id: input_file
type: File
- id: input_list
type: File[]
outputs:
- id: out
type: File
secondaryFiles:
- $(self.basename)
outputBinding:
glob: out
addMetadata: $(inputs.input_file.metadata)
- id: out_intersected
type: File[]
secondaryFiles:
- $(self.basename)
outputBinding:
glob: out
addMetadata:
- input_file
- input_list
requirements:
- class: DockerRequirement
dockerPull: 'debian:stretch-slim'
- class: InlineJavascriptRequirement
stdout: out