From be9b55fe7cc8d5fa4e66ebf59d188195cc79643b Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Thu, 29 Aug 2024 13:51:05 +0900 Subject: [PATCH 1/4] Add Defaultable --- Process.yml | 34 ++++++++++++++++++++-------------- Workflow.yml | 12 +----------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Process.yml b/Process.yml index 3a1f3a2..d88002d 100644 --- a/Process.yml +++ b/Process.yml @@ -116,6 +116,24 @@ $graph: 2. Inherited from `LoadListingRequirement` 3. By default: `no_listing` +- name: Defaultable + type: record + abstract: true + fields: + - name: default + type: CWLObjectType? + jsonldPredicate: + _id: "sld:default" + _container: "@list" + noLinkCheck: true + doc: | + The default value for this parameter. When it occurs in a CommandLineTool, + it is used if the parameter is missing from the input object, or if the value + of the parameter in the input object is `null`. When it occurs in a Workflow, + it is used if there is no `source` field, or the value produced by the `source` + is `null`. Default values are applied before scattering or evaluating expressions + (e.g. dependent `valueFrom` fields). + - name: FieldBase type: record extends: Labeled @@ -286,7 +304,7 @@ $graph: - name: InputRecordField type: record - extends: [CWLRecordField, FieldBase, InputFormat, LoadContents] + extends: [CWLRecordField, FieldBase, InputFormat, LoadContents, Defaultable] specialize: - specializeFrom: CWLRecordSchema specializeTo: InputRecordSchema @@ -372,19 +390,7 @@ $graph: - name: InputParameter type: record abstract: true - extends: [Parameter, InputFormat, LoadContents] - fields: - - name: default - type: CWLObjectType? - jsonldPredicate: - _id: "sld:default" - _container: "@list" - noLinkCheck: true - doc: | - The default value to use for this parameter if the parameter is missing - from the input object, or if the value of the parameter in the input - object is `null`. Default values are applied before evaluating expressions - (e.g. dependent `valueFrom` fields). + extends: [Parameter, InputFormat, LoadContents, Defaultable] - name: OutputParameter diff --git a/Workflow.yml b/Workflow.yml index 176de9a..859c8b7 100644 --- a/Workflow.yml +++ b/Workflow.yml @@ -274,7 +274,7 @@ $graph: - type: record name: WorkflowStepInput - extends: [Identified, InputSink, LoadContents, Labeled] + extends: [Identified, InputSink, LoadContents, Labeled, Defaultable] docParent: "#WorkflowStep" doc: | The input of a workflow step connects an upstream parameter (from the @@ -387,16 +387,6 @@ $graph: should be filtered out. fields: - - name: default - type: CWLObjectType? - doc: | - The default value for this parameter to use if either there is no - `source` field, or the value produced by the `source` is `null`. The - default must be applied prior to scattering or evaluating `valueFrom`. - jsonldPredicate: - _id: "sld:default" - _container: "@list" - noLinkCheck: true - name: valueFrom type: - "null" From 3fc37ee482e9f8663e4f1f294cd533f989efecc2 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Thu, 29 Aug 2024 13:57:28 +0900 Subject: [PATCH 2/4] Tweak --- Process.yml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Process.yml b/Process.yml index d88002d..d4ef907 100644 --- a/Process.yml +++ b/Process.yml @@ -61,6 +61,23 @@ $graph: jsonldPredicate: "rdfs:label" doc: "A short, human-readable label of this object." +- name: Defaultable + type: record + abstract: true + fields: + - name: default + type: CWLObjectType? + jsonldPredicate: + _id: "sld:default" + _container: "@list" + noLinkCheck: true + doc: | + The default value for this parameter. When it occurs in a CommandLineTool, + it is used if the parameter is missing from the input object, or if the value + of the parameter in the input object is `null`. When it occurs in a Workflow, + it is used if there is no `source` field, or the value produced by the `source` + is `null`. Default values are applied before scattering or evaluating expressions + (e.g. dependent `valueFrom` fields). - name: Identified type: record @@ -116,24 +133,6 @@ $graph: 2. Inherited from `LoadListingRequirement` 3. By default: `no_listing` -- name: Defaultable - type: record - abstract: true - fields: - - name: default - type: CWLObjectType? - jsonldPredicate: - _id: "sld:default" - _container: "@list" - noLinkCheck: true - doc: | - The default value for this parameter. When it occurs in a CommandLineTool, - it is used if the parameter is missing from the input object, or if the value - of the parameter in the input object is `null`. When it occurs in a Workflow, - it is used if there is no `source` field, or the value produced by the `source` - is `null`. Default values are applied before scattering or evaluating expressions - (e.g. dependent `valueFrom` fields). - - name: FieldBase type: record extends: Labeled From c6cfc98e5960b304ba42fb718f6345190ae716b6 Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Thu, 29 Aug 2024 14:09:25 +0900 Subject: [PATCH 3/4] Add a conformance test --- conformance_tests.yaml | 9 +++++++++ tests/record-default-field.cwl | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/record-default-field.cwl diff --git a/conformance_tests.yaml b/conformance_tests.yaml index 8d397d7..2326e28 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3525,3 +3525,12 @@ an_array_of_mixed_booleans: [ false, true, false ] an_array_of_trues: [ true, true, true ] an_int: 42 + +- id: record_default_field + job: tests/empty:json + tool: tests/record-default-field.cwl + doc: handling default value in fields of a record object + tags: [ required, command_line_tool ] + output: + v1: f1 + v2: f2 diff --git a/tests/record-default-field.cwl b/tests/record-default-field.cwl new file mode 100644 index 0000000..10e050c --- /dev/null +++ b/tests/record-default-field.cwl @@ -0,0 +1,23 @@ +cwlVersion: v1.3.0-dev1 +class: CommandLineTool +inputs: + record_input: + type: + type: record + fields: + f1: + type: string + default: "f1" + f2: + type: string + default: "f2" +arguments: ['true'] +outputs: + v1: + type: string + outputBinding: + outputEval: $(inputs.record_input.f1) + v2: + type: string + outputBinding: + outputEval: $(inputs.record_input.f2) From 3b942fb6f8db4f8207fdd6b4afecebb0c5cc6e0c Mon Sep 17 00:00:00 2001 From: Tomoya Tanjo Date: Thu, 29 Aug 2024 14:25:22 +0900 Subject: [PATCH 4/4] Fix typo --- conformance_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance_tests.yaml b/conformance_tests.yaml index 2326e28..5ac8391 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3527,7 +3527,7 @@ an_int: 42 - id: record_default_field - job: tests/empty:json + job: tests/empty.json tool: tests/record-default-field.cwl doc: handling default value in fields of a record object tags: [ required, command_line_tool ]