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

resolver.py failing to resolve a relative path

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

Description

## Expected Behavior
cwtool should be able to resolve the location of my relative path to a cwl_document when placed under an expected document search directory, i.e.:

https://www.commonwl.org/v1.0/Workflow.html#Discovering_CWL_documents_on_a_local_filesystem

## Actual Behavior
I get the following exception trace when running with --debug:

```
Search path is ['/susom/commonwl/pipeline/demo/demo.cwl', '/usr/local/share/commonwl/pipeline/demo/demo.cwl', '/usr/share/commonwl/pipeline/demo/demo.cwl']
Traceback (most recent call last):
File "/usr/local/bin/cwltool", line 11, in
sys.exit(run())
File "/usr/local/lib/python3.6/site-packages/cwltool/main.py", line 906, in run
sys.exit(main(*args, **kwargs))
File "/usr/local/lib/python3.6/site-packages/cwltool/main.py", line 632, in main
fetcher_constructor=loadingContext.fetcher_constructor)
File "/usr/local/lib/python3.6/site-packages/cwltool/load_tool.py", line 86, in resolve_tool_uri
uri = resolver(document_loader, argsworkflow)
File "/usr/local/lib/python3.6/site-packages/cwltool/resolver.py", line 44, in tool_resolver
ret = r(document_loader, uri)
File "/usr/local/lib/python3.6/site-packages/cwltool/resolver.py", line 36, in resolve_local
return Path(uri).as_uri()
File "/usr/local/lib/python3.6/pathlib.py", line 721, in as_uri
raise ValueError("relative path can't be expressed as a file URI")
ValueError: relative path can't be expressed as a file URI
```

## Your Environment
* using the published docker container: commonworkflowlanguage/cwltool:1.0.20181129095638
* docker run is:
```
exec docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-e XDG_DATA_HOME="/susom" \
-v "$PWD":"/susom/commonwl" \
-v "$TARGET_WORKDIR":"$TARGET_WORKDIR" \
-w="$TARGET_WORKDIR" \
commonworkflowlanguage/cwltool:1.0.20181129095638 \
pipeline/demo/demo.cwl demo_test_input.yml
```

If I connect to the container interactively using /bin/sh, I can see that XDG_DATA_HOME is setup correctly and the fie can be found at: `/susom/commonwl/pipeline/demo/demo.cwl`

## Suggested Fix
I looked at the code around line 36 of resolver.py and it is currently structured as followed:

```
for path in shares:
if os.path.exists(path):
return Path(uri).as_uri()
```

I think to work correctly the last line should be:
```
return Path(path).as_uri()
```
i.e. use `path` instead of `uri`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.