cwltool icon indicating copy to clipboard operation
cwltool copied to clipboard

cwltool throws an error when `secondaryFile`s are specified as a list in a workflow and as a single element in a tool

Open ThomasHickman opened this issue 9 months ago • 0 comments

Expected Behavior

No error should be thrown

Actual Behavior

An error is thrown

Workflow Code

workflow.cwl

cwlVersion: v1.2
class: Workflow

inputs:
  file: 
    type: File
    secondaryFiles:
      - .csi

steps:
  - id: run tool
    run: tool.cwl
    in:
      file: file
    out: []

outputs: []

tool.cwl

cwlVersion: v1.2
class: CommandLineTool

inputs:
  file: 
    type: File
    secondaryFiles: .csi

outputs: []

Full Traceback

$ cwltool --debug --validate ./workflow.cwl
INFO /home/user/Documents/checkouts/cwltool/venv/bin/cwltool 3.1.20230630061538
INFO Resolved './workflow.cwl' to 'file:///home/user/test-folder/workflow.cwl'
ERROR I'm sorry, I couldn't load this CWL file.
The error was: 
Traceback (most recent call last):
  File "/home/user/Documents/checkouts/cwltool/cwltool/main.py", line 1119, in main
    tool = make_tool(uri, loadingContext)
  File "/home/user/Documents/checkouts/cwltool/cwltool/load_tool.py", line 588, in make_tool
    tool = loadingContext.construct_tool_object(processobj, loadingContext)
  File "/home/user/Documents/checkouts/cwltool/cwltool/workflow.py", line 55, in default_make_tool
    return Workflow(toolpath_object, loadingContext)
  File "/home/user/Documents/checkouts/cwltool/cwltool/workflow.py", line 137, in __init__
    static_checker(
  File "/home/user/Documents/checkouts/cwltool/cwltool/checker.py", line 211, in static_checker
    sinksf = sorted(
  File "/home/user/Documents/checkouts/cwltool/cwltool/checker.py", line 212, in <genexpr>
    p["pattern"] for p in sink.get("secondaryFiles", []) if p.get("required", True)
AttributeError: 'str' object has no attribute 'get'

Your Environment

  • cwltool version: Check using cwltool --version
$ cwltool --version
/home/user/Documents/checkouts/cwltool/venv/bin/cwltool 3.1.20230630061538

(this is using the latest commit in main)

I think the cause of this is two-fold:

  • The code that checks whether secondaryFiles are compatible warns even if the src and sink are the same, but one represented as an array, and one as a single value in secondaryFiles
  • The code that reports this doesn't account for the fact that secondaryFiles properties may be an array or a single element

ThomasHickman avatar Sep 22 '23 10:09 ThomasHickman