Skip to content

Commit 78f6271

Browse files
authored
Merge pull request #741 from wtsi-hgi/cache_fix
Fix #740 (cachedir not working in certain situations)
2 parents 9e3e720 + 20edfbb commit 78f6271

File tree

6 files changed

+67
-3
lines changed

6 files changed

+67
-3
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
sudo: false
1+
sudo: true
2+
services:
3+
- docker
24
language: python
35
cache: pip
46
python:

cwltool/command_line_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def job(self,
296296
"EnvVarRequirement",
297297
"CreateFileRequirement",
298298
"ShellCommandRequirement"}
299-
for rh in (self.requirements, self.hints):
299+
for rh in (self.original_requirements, self.original_hints):
300300
for r in reversed(rh):
301301
if r["class"] in interesting and r["class"] not in keydict:
302302
keydict[r["class"]] = r

cwltool/process.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from functools import cmp_to_key
1818
from typing import (Any, Callable, Dict, Generator, List, Set, Text,
1919
Tuple, Union, cast, Optional)
20+
import copy
2021

2122
import schema_salad.schema as schema
2223
import schema_salad.validate as validate
@@ -453,6 +454,9 @@ def __init__(self, toolpath_object, **kwargs):
453454
self.tool.get("requirements", []) +
454455
get_overrides(kwargs.get("overrides", []), self.tool["id"]).get("requirements", []))
455456
self.hints = kwargs.get("hints", []) + self.tool.get("hints", [])
457+
# Versions of requirements and hints which aren't mutated.
458+
self.original_requirements = copy.deepcopy(self.requirements)
459+
self.original_hints = copy.deepcopy(self.hints)
456460
self.formatgraph = None # type: Graph
457461
if "loader" in kwargs:
458462
self.formatgraph = kwargs["loader"].graph

tests/test_examples.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import sys
77
import json
88
import logging
9+
import tempfile
10+
import shutil
911

1012
from io import StringIO, BytesIO
1113

@@ -651,13 +653,30 @@ def test_no_js_console(self):
651653

652654
@needs_docker
653655
class TestCache(TestCmdLine):
656+
def setUp(self):
657+
self.cache_dir = tempfile.mkdtemp("cwltool_cache")
658+
659+
def tearDown(self):
660+
shutil.rmtree(self.cache_dir)
661+
654662
def test_wf_without_container(self):
655663
test_file = "hello-workflow.cwl"
656-
error_code, stdout, stderr = self.get_main_output(["--cachedir", "cache",
664+
error_code, stdout, stderr = self.get_main_output(["--cachedir", self.cache_dir,
657665
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
658666
self.assertIn("completed success", stderr)
659667
self.assertEquals(error_code, 0)
660668

669+
def test_issue_740_fixed(self):
670+
test_file = "cache_test_workflow.cwl"
671+
error_code, stdout, stderr = self.get_main_output(["--cachedir", self.cache_dir, get_data("tests/wf/" + test_file)])
672+
self.assertIn("completed success", stderr)
673+
self.assertEquals(error_code, 0)
674+
675+
error_code, stdout, stderr = self.get_main_output(["--cachedir", self.cache_dir, get_data("tests/wf/" + test_file)])
676+
self.assertNotIn("Output of job will be cached in", stderr)
677+
self.assertEquals(error_code, 0)
678+
679+
661680
@needs_docker
662681
class TestChecksum(TestCmdLine):
663682

tests/wf/cache_test_workflow.cwl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.0
4+
class: Workflow
5+
6+
inputs: []
7+
outputs: []
8+
9+
steps:
10+
task1:
11+
run: touch_tool.cwl
12+
in:
13+
message:
14+
default: one
15+
out: []
16+
task2:
17+
run: touch_tool.cwl
18+
in:
19+
message:
20+
default: two
21+
out: []

tests/wf/touch_tool.cwl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.0
4+
class: CommandLineTool
5+
baseCommand: touch
6+
requirements:
7+
DockerRequirement:
8+
dockerPull: alpine
9+
inputs:
10+
message:
11+
type: string
12+
inputBinding:
13+
position: 1
14+
outputs:
15+
- id: out
16+
type: File
17+
outputBinding:
18+
glob: "*"

0 commit comments

Comments
 (0)