cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

itemSeparator with an array prints arguments twice

Open ThomasHickman opened this issue 6 years ago • 2 comments

Inputs

test.cwl:

cwlVersion: v1.0
class: CommandLineTool
baseCommand: ['true']
inputs:
  - id: param
    type:
      type: array
      items: string
      inputBinding:
        prefix: --arr_prefix
    inputBinding:
      prefix: --before_prefix
      itemSeparator: " "

outputs: []

Output

$ python -m cwltool test.cwl --param one --param two
/Users/th10/checkouts/cwltool/cwltool/__main__.py 1.0.20180509130025
Resolved 'test.cwl' to 'file:///Users/th10/checkouts/cwltool/test.cwl'
[job test.cwl] /private/tmp/docker_tmpq_xbceae$ true \
    --before_prefix \
    'one two' \
    --arr_prefix \
    one \
    --arr_prefix \
    two
[job test.cwl] completed success
{}
Final process status is success

It looks like https://github.com/common-workflow-language/cwltool/blob/78f62710b7add5148b89db7c104d8f8ce46413f5/cwltool/builder.py#L292 is generating values as well as bind_input splitting up the list and feeding each part into bind_input, hence the generation of the interpolated value of one two twice.

Your Environment

  • cwltool version: 1.0.20170816094652

ThomasHickman avatar May 11 '18 10:05 ThomasHickman

Same output with the latest version of cwltool and using v1.0 or v1.2.

I think the type element is a CommandInputRecordSchema, and its inputBinding is telling cwltool to add the values of that parameter to the command line.

If the idea was to add one two to both --arr_prefix and to --before_prefix (i.e. re-use the same values), I think it would be simpler to create two inputs like this.

cwlVersion: v1.2
class: CommandLineTool
baseCommand: ['true']
requirements:
  InlineJavascriptRequirement: {}
inputs:
  - id: param
    type:
      type: array
      items: string
    inputBinding:
      prefix: --before_prefix
      itemSeparator: " "
  - id: param2
    default: []
    type:
      type: array
      items: string
    inputBinding:
      prefix: --after_prefix
      valueFrom: ${ return inputs.param.join(' ') }

outputs: []
(venv) kinow@ranma:~/Development/python/workspace/cwltool$ cwltool /tmp/test.cwl --param a --param b
INFO /home/kinow/Development/python/workspace/cwltool/venv/bin/cwltool 3.1.20220502060230
INFO Resolved '/tmp/test.cwl' to 'file:///tmp/test.cwl'
INFO [job test.cwl] /tmp/mr6wviq1$ true \
    --before_prefix \
    'a b' \
    --after_prefix \
    'a b'
INFO [job test.cwl] completed success
{}
INFO Final process status is success

But I am not sure what's the expected behavior.

kinow avatar May 19 '22 12:05 kinow

It is a matter of the specification as well as the implementation. Related: https://github.com/common-workflow-language/cwl-v1.2/issues/177

tom-tan avatar May 19 '22 13:05 tom-tan