common-workflow-language / common-workflow-language/cwltool

SchemaDefRequirement producing ordereddict in output

Open
#1,684 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
376
Forks
255
Avg merge
2d 7h
Merged PRs (30d)
12

Description

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`

```yaml
- 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`

```yaml
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
```pytb
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.

```bash
(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``

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.