Skip to content

Commit a972860

Browse files
authored
Merge pull request #898 from wtsi-hgi/rm-intermediates
Delete intermediate outputs even when they exist
2 parents 83851db + b73b2b5 commit a972860

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cwltool/executors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tempfile
66
import threading
77
from abc import ABCMeta, abstractmethod
8-
from typing import Any, Dict, List, Optional, Set, Tuple
8+
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
99

1010
import psutil
1111
from schema_salad.validate import ValidationException
@@ -97,7 +97,11 @@ def execute(self,
9797
path_mapper=runtime_context.path_mapper)
9898

9999
if runtime_context.rm_tmpdir:
100-
cleanIntermediate(self.output_dirs)
100+
if runtime_context.cachedir is None:
101+
output_dirs = self.output_dirs # type: Iterable[Any]
102+
else:
103+
output_dirs = filter(lambda x: not x.startswith(runtime_context.cachedir), self.output_dirs)
104+
cleanIntermediate(output_dirs)
101105

102106
if self.final_output and self.final_status:
103107

cwltool/process.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ def relink(relinked, # type: Dict[Text, Text]
372372
return outputObj
373373

374374

375-
def cleanIntermediate(output_dirs): # type: (Set[Text]) -> None
375+
def cleanIntermediate(output_dirs): # type: (Iterable[Text]) -> None
376376
for a in output_dirs:
377-
if os.path.exists(a) and empty_subtree(a):
377+
if os.path.exists(a):
378378
_logger.debug(u"Removing intermediate output directory %s", a)
379379
shutil.rmtree(a, True)
380380

0 commit comments

Comments
 (0)