Skip to content

static_checker mistakenly fails with source -> sink #437

@michael-kotliar

Description

@michael-kotliar

Expected Behavior

Workflow inputs

inputs:
    file1:
      - type: array
        items: File
    file2:
      - type: array
        items: File

should be exactly the same as

inputs:
    file1:
      type: File[]
    file2:
      type: File[]

Actual Behavior

static_checker mistakenly fails with source -> sink mismatch

Tool definition failed validation:
count-lines11-wf.cwl:9:5: Source 'file1' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened
count-lines11-wf.cwl:12:5: Source 'file2' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened

Workflow Code

Workflow count-lines11-wf.cwl

#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.0

requirements:
  - class: MultipleInputFeatureRequirement

inputs:
    file1:
      - type: array
        items: File
    file2:
      - type: array
        items: File

outputs:
    count_output:
      type: int
      outputSource: step1/output

steps:
  step1:
    run: wc3-tool.cwl
    in:
      file1:
        source: [file1, file2]
        linkMerge: merge_flattened
    out: [output]

tool wc3-tool.cwl

#!/usr/bin/env cwl-runner
class: CommandLineTool
cwlVersion: v1.0

requirements:
  - class: InlineJavascriptRequirement

inputs:
    file1:
      type: File[]
      inputBinding: {}
outputs:
    output:
      type: int
      outputBinding:
        glob: output.txt
        loadContents: true
        outputEval: |
              ${
                var s = self[0].contents.split(/\r?\n/);
                return parseInt(s[s.length-2]);
              }
stdout: output.txt
baseCommand: wc

job count-lines6-job.json

{
    "file1": [
        {
            "class": "File",
            "location": "whale.txt"
        },
        {
            "class": "File",
            "location": "whale.txt"
        }
    ],
    "file2": [
        {
            "class": "File",
            "location": "hello.txt"
        },
        {
            "class": "File",
            "location": "hello.txt"
        }
    ]
}

Full Traceback

cwltool --debug count-lines11-wf.cwl count-lines6-job.json
/Users/kot4or/venv/cwl_latest/bin/cwltool 1.0.20170622090721
Resolved 'count-lines11-wf.cwl' to 'file:///Users/kot4or/workspaces/python_ws/common-workflow-language/v1.0/v1.0/count-lines11-wf.cwl'
Tool definition failed validation:
count-lines11-wf.cwl:9:5: Source 'file1' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened
count-lines11-wf.cwl:12:5: Source 'file2' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened
Traceback (most recent call last):
  File "/Users/kot4or/venv/cwl_latest/lib/python2.7/site-packages/cwltool/main.py", line 715, in main
    makeTool, vars(args))
  File "/Users/kot4or/venv/cwl_latest/lib/python2.7/site-packages/cwltool/load_tool.py", line 251, in make_tool
    tool = makeTool(processobj, **kwargs)
  File "/Users/kot4or/venv/cwl_latest/lib/python2.7/site-packages/cwltool/workflow.py", line 37, in defaultMakeTool
    return Workflow(toolpath_object, **kwargs)
  File "/Users/kot4or/venv/cwl_latest/lib/python2.7/site-packages/cwltool/workflow.py", line 524, in __init__
    static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs)
  File "/Users/kot4or/venv/cwl_latest/lib/python2.7/site-packages/cwltool/workflow.py", line 612, in static_checker
    raise validate.ValidationException(all_exception_msg)
ValidationException: count-lines11-wf.cwl:9:5: Source 'file1' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened
count-lines11-wf.cwl:12:5: Source 'file2' of type [{"type": "array", "items": "File"}] is incompatible
count-lines11-wf.cwl:25:7:   with sink 'file1' of type {"type": "array", "items": "File"}
count-lines11-wf.cwl:25:7:   sink has linkMerge method merge_flattened

Your Environment

  • cwltool version: 1.0.20170622090721

Link to reproduce test

count-lines11-wf.cwl
count-lines6-job.json
wc3-tool.cwl
whale.txt
hello.txt

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