common-workflow-language / common-workflow-language/cwltool

load_tool fails on second call with same url

Open
#960 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
376
Forks
255
Avg merge
2d 7h
Merged PRs (30d)
12

Description

Using the `load_tool` function fails to load a packed workflow if it has been called before with the same url.

## Expected Behavior
`load_tool` should fetch and parse the packed workflow every time it is called.

## Actual Behavior
`load_tool` raises a **schema_salad.validate.ValidationException: No cwlVersion found**

## Workflow Code
```python
from cwltool.context import LoadingContext
from cwltool.workflow import default_make_tool
from cwltool.resolver import tool_resolver
from cwltool.load_tool import load_tool

def parse(url):
context = LoadingContext({"construct_tool_object": default_make_tool,
"resolver": tool_resolver})
parsed = load_tool(url + '#main', context)
return parsed

# a packed workflow
packed_url1 = 'https://github.com/Duke-GCB/bespin-cwl/releases/download/v0.9.4/exomeseq-gatk4-preprocessing.cwl'
packed_url2 = 'https://github.com/Duke-GCB/bespin-cwl/releases/download/v0.9.3/exomeseq.cwl'

parse(packed_url1) # ok
parse(packed_url2) # ok
parse(packed_url2) # fail

```

## Full Traceback
```pytb
Traceback (most recent call last):
File "fail.py", line 18, in
parse(packed_url2) # fail
File "fail.py", line 9, in parse
parsed = load_tool(url + '#main', context)
File "/Users/dcl9/Code/python/test-bespin-api-167/env/lib/python3.6/site-packages/cwltool/load_tool.py", line 372, in load_tool
metadata=loadingContext.metadata)
File "/Users/dcl9/Code/python/test-bespin-api-167/env/lib/python3.6/site-packages/cwltool/load_tool.py", line 241, in validate_document
"No cwlVersion found. "
schema_salad.validate.ValidationException: No cwlVersion found. Use the following syntax in your CWL document to declare the version: cwlVersion: .
Note: if this is a CWL draft-2 (pre v1.0) document then it will need to be upgraded first.
```

## Your Environment
* cwltool version: cwltool 1.0.20181012180214
* schema-salad: 2.7.20181017120439

Contributor guide

Open the contributing guide

Research direction

Start at the load_tool entry point, especially the load_tool.py locations shown in the traceback around lines 372 and 241, and reproduce the issue with the provided parse function and packed workflow URLs. Done means calling parse on the same packed URL twice succeeds and returns the parsed workflow both times.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.