This is a test version of Biostars. For the public version, visit https://www.biostars.org.
InitialWorkDirRequirement error with array of Directories

I believe this should be supported as per the v1.0 spec

cwlVersion: v1.0
class: CommandLineTool
baseCommand: [touch]
arguments:
- ${return './' + inputs.directories[0].basename + '/' + inputs.to_touch}

requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
  listing:
  - entry: $(inputs.files)
  - entry: $(inputs.directories)

inputs:
  to_touch: string
  directories:
    type: Directory[]
  files:
    type: File[]

outputs:
  output:
    type: string
    outputBinding:
      outputEval: 'asdf'

But I am receiving this error from cwltool:

(test13)  johnsoni@lski2427  ~/Desktop/initial_wd_dir_test  cwltool --debug test.cwl inputs.yaml
/Users/johnsoni/Desktop/virtualenvs/test13/bin/cwltool 1.0.20180306140409
Resolved 'test.cwl' to 'file:///Users/johnsoni/Desktop/initial_wd_dir_test/test.cwl'
[job test.cwl] initializing from file:///Users/johnsoni/Desktop/initial_wd_dir_test/test.cwl
[job test.cwl] {
    "to_touch": "a_new_one",
    "directories": [
        {
            "class": "Directory",
            "location": "file:///Users/johnsoni/Desktop/initial_wd_dir_test/test_dir",
            "basename": "test_dir"
        },
        {
            "class": "Directory",
            "location": "file:///Users/johnsoni/Desktop/initial_wd_dir_test/test_dir_2",
            "basename": "test_dir_2"
        }
    ],
    "files": [
        {
            "class": "File",
            "location": "file:///Users/johnsoni/Desktop/initial_wd_dir_test/file1",
            "size": 0,
            "basename": "file1",
            "nameroot": "file1",
            "nameext": ""
        },
        {
            "class": "File",
            "location": "file:///Users/johnsoni/Desktop/initial_wd_dir_test/file2",
            "size": 0,
            "basename": "file2",
            "nameroot": "file2",
            "nameext": ""
        }
    ]
}
Got workflow error
Traceback (most recent call last):
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/executors.py", line 98, in run_jobs
    for r in jobiter:
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/command_line_tool.py", line 417, in job
    self.updatePathmap(builder.outdir, builder.pathmapper, l)
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/command_line_tool.py", line 241, in updatePathmap
    for sf in fn.get("secondaryFiles", []):
AttributeError: 'CommentedSeq' object has no attribute 'get'
Workflow error, try again with --debug for more information:
'CommentedSeq' object has no attribute 'get'
Traceback (most recent call last):
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/main.py", line 588, in main
    **vars(args))
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/executors.py", line 29, in __call__
    return self.execute(*args, **kwargs)
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/executors.py", line 69, in execute
    self.run_jobs(t, job_order_object, logger, **kwargs)
  File "/Users/johnsoni/Desktop/virtualenvs/test13/lib/python2.7/site-packages/cwltool-1.0.20180306140409-py2.7.egg/cwltool/executors.py", line 113, in run_jobs
    raise WorkflowException(Text(e))
WorkflowException: 'CommentedSeq' object has no attribute 'get'
cwl

1 answer

Answered my own question. It is the listing field that must evaluate to a list, so lists are not supported in the entry fields

requirements:
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
  listing: $(inputs.directories)

Log in to answer this question.