schema_salad icon indicating copy to clipboard operation
schema_salad copied to clipboard

Python CodeGen: Loading and saving tool leads to validation fail

Open ZimmerA opened this issue 2 years ago • 0 comments

After generating Python utilities for https://github.com/common-workflow-language/cwl-v1.2/tree/1.2.1_proposed I tried loading and subsequently saving one of the test files (/tests/count-lines14-wf.cwl) using the following code:

f = open("/home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl", "r")
doc = load_document_by_string(f.read(), "file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl")

out = doc.save(True, "file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl", True)
with open(f"./count-lines14-wf.cwl", "w") as file:
    yaml = yaml_no_ts()
    yaml.dump(out, file)

The result was the following document:

class: Workflow
id: file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl
inputs:
- id: file1
  type: File
- id: file2
  type: File
outputs:
- id: count_output
  outputSource: step1/count_output
  type:
    name: _:a5070f24-d2c6-46de-90ed-7286845ecf62
    items: int
    type: array
requirements:
- class: MultipleInputFeatureRequirement
- class: ScatterFeatureRequirement
- class: SubworkflowFeatureRequirement
cwlVersion: v1.2
steps:
- id: step1
  in:
  - id: file1
    source:
    - file1
    - file2
  out:
  - count_output
  run:
    class: Workflow
    id: _:8dcc1f57-11bd-4b83-93be-48b3f43fa358
    inputs:
    - id: file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/file1
      type: File
    outputs:
    - id: file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/count_output
      outputSource: step2/output
      type: int
    steps:
    - id: file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1
      in:
      - id: file1
        source: step1/file1
      out:
      - output
      run: wc-tool.cwl
    - id: file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step2
      in:
      - id: file1
        source: step1/step1/output
      out:
      - output
      run: parseInt-tool.cwl
  scatter: file1

Trying to validate this with cwltool version 3.1.20220607081835 leads to the following error:

ERROR Tool definition failed initialization:
Tool definition ordereddict([('class', 'Workflow'), ('id', '_:8dcc1f57-11bd-4b83-93be-48b3f43fa358'), ('inputs', [ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/file1'), ('type', 'File')])]), ('outputs', [ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/count_output'), ('outputSource', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step2/output'), ('type', 'int')])]), ('steps', [ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1'), ('in', [ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1/file1'), ('source', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1/file1')])]), ('out', ['file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1/output']), ('run', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/wc-tool.cwl')]), ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step2'), ('in', [ordereddict([('id', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step2/file1'), ('source', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1/output')])]), ('out', ['file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step2/output']), ('run', 'file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/parseInt-tool.cwl')])])]) failed validation:
../../Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl:42:9:   source not found:
                                                                       file:///home/adrian/Dokumente/Coding/CWL/cwl-v1.2/tests/count-lines14-wf.cwl#step1/step1/file1

ZimmerA avatar Jun 21 '22 15:06 ZimmerA