Skip to content

Commit e9c8373

Browse files
authored
Merge pull request #1282 from common-workflow-language/iwdr_dir_literal_real_inputs
cope with unmovable files left over from Docker+IWDR
2 parents d7cd45f + 08aa4b3 commit e9c8373

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include README.rst
12
include MANIFEST.in
23
include LICENSE.txt
34
include *requirements.txt

cwltool/job.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ def relink_initialworkdir(
163163
host_outdir, vol.target[len(container_outdir) + 1 :]
164164
)
165165
if os.path.islink(host_outdir_tgt) or os.path.isfile(host_outdir_tgt):
166-
os.remove(host_outdir_tgt)
166+
try:
167+
os.remove(host_outdir_tgt)
168+
except PermissionError:
169+
pass
167170
elif os.path.isdir(host_outdir_tgt) and not vol.resolved.startswith("_:"):
168171
shutil.rmtree(host_outdir_tgt)
169172
if onWindows():
@@ -175,7 +178,10 @@ def relink_initialworkdir(
175178
elif vol.type in ("Directory", "WritableDirectory"):
176179
copytree_with_merge(vol.resolved, host_outdir_tgt)
177180
elif not vol.resolved.startswith("_:"):
178-
os.symlink(vol.resolved, host_outdir_tgt)
181+
try:
182+
os.symlink(vol.resolved, host_outdir_tgt)
183+
except FileExistsError:
184+
pass
179185

180186

181187
class JobBase(HasReqsHints, metaclass=ABCMeta):

cwltool/update.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def v1_2_0dev1todev2(doc, loader, baseuri): # pylint: disable=unused-argument
149149
return (doc, "v1.2.0-dev2")
150150

151151

152-
def v1_2_0dev2todev3(doc: Any, loader: Loader, baseuri: str) -> Tuple[Any, str]: # pylint: disable=unused-argument
152+
def v1_2_0dev2todev3(
153+
doc: Any, loader: Loader, baseuri: str
154+
) -> Tuple[Any, str]: # pylint: disable=unused-argument
153155
"""Public updater for v1.2.0-dev2 to v1.2.0-dev3"""
154156
doc = copy.deepcopy(doc)
155157

tests/iwdr_dir_literal_real_file.cwl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.0
3+
4+
requirements:
5+
DockerRequirement:
6+
dockerPull: debian:stable-slim
7+
InlineJavascriptRequirement: {}
8+
InitialWorkDirRequirement:
9+
listing: |
10+
${
11+
return [{"class": "Directory",
12+
"basename": "subdir",
13+
"listing": [ inputs.example ]
14+
}]}
15+
16+
inputs:
17+
example: File
18+
19+
outputs:
20+
same:
21+
type: File
22+
outputBinding:
23+
glob: subdir/$(inputs.example.basename)

tests/test_iwdr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ def test_empty_file_creation():
3030
assert err_code == 0
3131

3232

33+
@needs_docker
34+
def test_directory_literal_with_real_inputs_inside():
35+
"""Cope with unmoveable files in the output directory created by Docker+IWDR."""
36+
err_code, _, _ = get_main_output(
37+
[
38+
get_data("tests/iwdr_dir_literal_real_file.cwl"),
39+
"--example={}".format(get_data("tests/__init__.py")),
40+
]
41+
)
42+
assert err_code == 0
43+
44+
3345
@needs_docker
3446
def test_iwdr_permutations():
3547
saved_tempdir = tempfile.tempdir

0 commit comments

Comments
 (0)