diff --git a/CommandLineTool.yml b/CommandLineTool.yml index 7e267dd..6ec6554 100644 --- a/CommandLineTool.yml +++ b/CommandLineTool.yml @@ -223,6 +223,7 @@ $graph: - loadContents - outputEval - secondaryFiles + - addMetadata fields: - name: glob type: @@ -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 diff --git a/Process.yml b/Process.yml index 4d2aafb..a8db0e4 100644 --- a/Process.yml +++ b/Process.yml @@ -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 diff --git a/conformance_tests.yaml b/conformance_tests.yaml index a5d3e65..4ada7c4 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -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 ] + diff --git a/tests/inherit-metadata-job.yml b/tests/inherit-metadata-job.yml new file mode 100644 index 0000000..df7a300 --- /dev/null +++ b/tests/inherit-metadata-job.yml @@ -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 \ No newline at end of file diff --git a/tests/inherit-metadata.cwl b/tests/inherit-metadata.cwl new file mode 100644 index 0000000..212dd78 --- /dev/null +++ b/tests/inherit-metadata.cwl @@ -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 \ No newline at end of file