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

--tmpdir-prefix is ignored

Open
#1,084 1 comment 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
`--tmpdir-prefix` should create all temporary files in the provided location. `--leave-tmpdir` should not remove the tmpdir or any of it's contents.

## Actual Behavior
`--tmpdir-prefix` is ignored when running a CWL tool that doesn't require a docker image and instead uses the prefix `/tmp/tmp`. It works as intended for tools with a DockerRequirement. Only data written to `$TMPDIR` seems to be kept using `--leave-tmpdir`, no job metadata (docker cid files, input symlinks etc) that might be useful for troubleshooting. If this is intentional, it should be clarified in the command line help.

## Workflow Code
The following bash script is run on host (`cp.cwl`) and from a container based on `alpine:latest` (`cp-alpine.cwl`). It create a temporary intermediate file in `$TMPDIR`.
```
#!/bin/sh
F=$TMPDIR/tmp.file
cp $1 $F
cp $F $2
```
CWLs are providing input `--source` and output `--dest`.

## Full Traceback

#### Without docker:
```
$ cwltool --tmpdir-prefix /tmp/tmpdir/test_ --leave-tmpdir cp.cwl --source input.file --dest copy.file
/home/forsmark/venv/bin/cwltool 1.0.20190228155703
Resolved 'cp.cwl' to 'file:///home/forsmark/cp.cwl'
[job cp.cwl] /tmp/j1ozvvns$ /home/forsmark/cp.sh \
/tmp/tmpr9t1n47r/stg95880438-cade-4b8a-8ce5-b35be57391fc/input.file \
copy.file
[job cp.cwl] Max memory used: 3MiB
[job cp.cwl] completed success
[...]
Final process status is success
```
The value for `--tmpdir-prefix` is not used and the input symlink is not kept.
```
$ find /tmp -name "*.file"
/tmp/tmp7gqjfd_v/tmp.file
$ ls -l /tmp/tmpdir/
total 0
```

#### With container:
```
$ cwltool --tmpdir-prefix /tmp/tmpdir/test_ --leave-tmpdir cp-alpine.cwl --source input.file --dest copy.file &
/home/forsmark/venv/bin/cwltool 1.0.20190228155703
Resolved 'cp-alpine.cwl' to 'file:///home/forsmark/cp-alpine.cwl'
[job cp-alpine.cwl] /tmp/mq1m_mdo$ docker \
run \
-i \
--volume=/tmp/mq1m_mdo:/Bvqdrc:rw \
--volume=/tmp/tmpdir/test_g49gg6z3:/tmp:rw \
--volume=/data/large.file:/var/lib/cwl/stgbbe0bf5c-09fb-4a77-bea8-a5e431bfe3db/input.file:ro \
--workdir=/Bvqdrc \
--read-only=true \
--user=1116:1116 \
--rm \
--env=TMPDIR=/tmp \
--env=HOME=/Bvqdrc \
--cidfile=/tmp/tmpdir/test_i5o3uchd/20190318230508-333021.cid \
cp:latest \
cp.sh \
/var/lib/cwl/stgbbe0bf5c-09fb-4a77-bea8-a5e431bfe3db/input.file \
copy.file
[job cp-alpine.cwl] Max memory used: 0MiB
[job cp-alpine.cwl] completed success
[...]
Final process status is success
```
The value of `--tmpdir-prefix` is used but many of the temporary files are removed despite `--leave-tmpdir`.

```
$ ls -R /tmp/tmpdir/
/tmp/tmpdir/:
test_4v93ebd3 test_a13q0ip_ test_g49gg6z3 test_i5o3uchd

/tmp/tmpdir/test_a13q0ip_:

/tmp/tmpdir/test_g49gg6z3:
tmp.file

/tmp/tmpdir/test_i5o3uchd:
20190318230508-333021.cid
$ wait
$ ls -R /tmp/tmpdir/
/tmp/tmpdir/:
test_g49gg6z3 test_i5o3uchd

/tmp/tmpdir/test_g49gg6z3:
tmp.file

/tmp/tmpdir/test_i5o3uchd:
```

## Your Environment
```
$ pip freeze | grep cwltool
cwltool==1.0.20190228155703
$ python --version
Python 3.6.7
```

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.