cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

SchemaDefRequirement producing ordereddict in output

Open kinow opened this issue 3 years ago • 0 comments

Ref: https://github.com/common-workflow-language/cwl-v1.2/pull/171#discussion_r902512355

Expected Behavior

The serialization of data/types from SchemaDefRequirement should be a pure JSON object, but they appear to be producing the output of the __repr__ of the object instead.

Actual Behavior

A JSON serialized output.

Workflow Code

Started with four files, as in the referenced pull request. The simplest I could come up with is these two files.

File: schemadef-ordereddict-serialization-bug-schema.yml

- name: a_record
  type: record
  fields:
    - name: a_string
      type: string
    - name: another_string
      type: string

- name: input_record
  type: record
  fields:
    - name: an_array_of_record_with_strings
      type:
        type: array
        items: a_record

File: schemadef-ordereddict-serialization-bug-tool.cwl

cwlVersion: v1.2
class: CommandLineTool

requirements:
  - class: SchemaDefRequirement
    types:
      - $import: schemadef-ordereddict-serialization-bug-schema.yml

inputs:
  - id: message
    type: "schemadef-ordereddict-serialization-bug-schema.yml#input_record"
    inputBinding:
      valueFrom: $(self.an_array_of_record_with_strings)
    default: {
      "an_array_of_record_with_strings": [
        {
          "a_string": "john",
          "another_string": "doe"
        },
        {
          "a_string": "jane",
          "another_string": "doe"
        }
      ]
    }

outputs:
  - id: out
    type: string
    outputBinding:
      glob: output.txt
      loadContents: true
      outputEval: $(self[0].contents)

stdout: output.txt
baseCommand: echo

Full Traceback

Paste the full traceback in case there is an exception
Run the workflow with ``--debug`` flag for more verbose logging 

No traceback really, but the output is incorrect, I believe. Here's the command used with the two files above, and its output.

(venv) kinow@ranma:~/Development/python/workspace/cwltool/tests$ cwltool schemadef-ordereddict-serialization-bug-tool.cwl 
INFO /home/kinow/Development/python/workspace/cwltool/venv/bin/cwltool 3.1.20220622084204
INFO Resolved 'schemadef-ordereddict-serialization-bug-tool.cwl' to 'file:///home/kinow/Development/python/workspace/cwltool/tests/schemadef-ordereddict-serialization-bug-tool.cwl'
INFO [job schemadef-ordereddict-serialization-bug-tool.cwl] /tmp/tooo_0ud$ echo \
    'ordereddict([('"'"'a_string'"'"', '"'"'john'"'"'), ('"'"'another_string'"'"', '"'"'doe'"'"')])' \
    'ordereddict([('"'"'a_string'"'"', '"'"'jane'"'"'), ('"'"'another_string'"'"', '"'"'doe'"'"')])' > /tmp/tooo_0ud/output.txt
INFO [job schemadef-ordereddict-serialization-bug-tool.cwl] completed success
{
    "out": "ordereddict([('a_string', 'john'), ('another_string', 'doe')]) ordereddict([('a_string', 'jane'), ('another_string', 'doe')])\n"
}
INFO Final process status is success

Your Environment

  • cwltool version: Check using cwltool --version
(venv) kinow@ranma:~/Development/python/workspace/cwltool/tests$ cwltool --version
/home/kinow/Development/python/workspace/cwltool/venv/bin/cwltool 3.1.20220622084204

kinow avatar Jun 23 '22 08:06 kinow