Skip to content

loadContents does not load contents for an array of files #1246

Closed
@Zymergen-phaverty

Description

@Zymergen-phaverty

Expected Behavior

loadContents for type: File[] should load the contents into the file object.

Actual Behavior

Loading only happens for type: File. For File[] the contents field is empty

Workflow Code

Broken case, input yaml:
my_json:

  • {class: File, location: /Users/phaverty/my_json.json}
    Broken case, cwl:
    #!/usr/bin/env cwl-runner
    cwlVersion: v1.0
    class: ExpressionTool
    expression: |-
    ${
    return JSON.parse(inputs.my_json.contents);
    }
    inputs:
    • id: my_json
      type: File[]
      inputBinding:
      loadContents: true
      outputs:
    • id: out
      type: string
      outputBinding:
      glob: out.txt
      requirements:
    • class: InlineJavascriptRequirement

Working case, input yaml:
my_json: {class: File, location: /Users/phaverty/my_json.json}

Working case, input cwl:
#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: ExpressionTool
expression: |-
${
return JSON.parse(inputs.my_json.contents);
}
inputs:

  • id: my_json
    type: File
    inputBinding:
    loadContents: true
    outputs:
  • id: out
    type: string
    outputBinding:
    glob: out.txt
    requirements:
  • class: InlineJavascriptRequirement

Full Traceback

INFO /Users/phaverty/miniconda3/bin/cwltool 2.0.20200122124526
INFO Resolved '/Users/phaverty/echo.cwl' to 'file:///Users/phaverty/echo.cwl'
WARNING Failed to evaluate expression:
Expression evaluation error:
Expecting value: line 1 column 1 (char 0)
script was:
01 "use strict";
02 var inputs = {
03     "my_json": [
04         {
05             "class": "File",
06             "location": "file:///Users/phaverty/my_json.json",
07             "size": 777,
08             "basename": "my_json.json",
09             "nameroot": "my_json",
10             "nameext": ".json"
11         }
12     ]
13 };
14 var self = null;
15 var runtime = {
16     "cores": 1,
17     "ram": 1024,
18     "tmpdirSize": 1024,
19     "outdirSize": 1024,
20     "tmpdir": "/private/var/folders/9y/tk505d9x5g39g72jjxts0d4c0000gn/T/tmpgwy4d1zt",
21     "outdir": "/private/tmp/docker_tmpyk5cb1yn"
22 };
23 (function(){
24   return JSON.parse(inputs.my_json.contents);
25  })()
stdout was: ''
stderr was: 'undefined:1
undefined
^

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at evalmachine.<anonymous>:24:15
    at evalmachine.<anonymous>:25:4
    at Script.runInContext (vm.js:107:20)
    at Script.runInNewContext (vm.js:113:17)
    at Object.runInNewContext (vm.js:296:38)
    at Socket.<anonymous> ([eval]:11:57)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:260:13)'

{}
WARNING Final process status is permanentFail

Note how the my_json object does not have a contents field. Using the single file case and using a javascript syntax error to generate error output, one can see that the contents field contains the JSON from the JSON file.

Your Environment

  • cwltool version:
    Check using cwltool --version
    2.0.20200122124526

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions