Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zymergen-phaverty opened this issue Feb 6, 2020 · 0 comments · Fixed by #2036
Closed

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

Zymergen-phaverty opened this issue Feb 6, 2020 · 0 comments · Fixed by #2036

Comments

@Zymergen-phaverty
Copy link

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
@Zymergen-phaverty Zymergen-phaverty changed the title loadConents does not load contents for an array of files loadContents does not load contents for an array of files Feb 6, 2020
@mr-c mr-c closed this as completed in #2036 Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant