Skip to content

Commit 3102a10

Browse files
author
Anton Khodak
committed
Fix staging writable files for Singularity
1 parent cd61ee6 commit 3102a10

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cwltool/job.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ def add_volumes_singularity(self, pathmapper, runtime, stage_output):
375375
containertgt = container_outdir + vol.target[len(host_outdir):]
376376
else:
377377
containertgt = vol.target
378+
if vol.target.startswith(container_outdir+"/"):
379+
host_outdir_tgt = os.path.join(
380+
host_outdir, vol.target[len(container_outdir)+1:])
381+
else:
382+
host_outdir_tgt = None
378383
if vol.type in ("File", "Directory"):
379384
if not vol.resolved.startswith("_:"):
380385
runtime.append(u"--bind")
@@ -384,7 +389,8 @@ def add_volumes_singularity(self, pathmapper, runtime, stage_output):
384389
runtime.append(u"--bind")
385390
runtime.append("%s:%s:rw" % (docker_windows_path_adjust(vol.resolved), docker_windows_path_adjust(containertgt)))
386391
else:
387-
shutil.copy(vol.resolved, vol.target)
392+
shutil.copy(vol.resolved, host_outdir_tgt)
393+
ensure_writable(host_outdir_tgt)
388394
elif vol.type == "WritableDirectory":
389395
if vol.resolved.startswith("_:"):
390396
os.makedirs(vol.target, 0o0755)
@@ -465,9 +471,9 @@ def run(self, pull_image=True, rm_container=True,
465471
runtime.append(u"--bind")
466472
runtime.append(u"%s:%s:rw" % (docker_windows_path_adjust(os.path.realpath(self.tmpdir)), "/tmp"))
467473

468-
self.add_volumes_singularity(self.pathmapper, runtime, False)
474+
self.add_volumes_singularity(self.pathmapper, runtime, stage_output=False)
469475
if self.generatemapper:
470-
self.add_volumes_singularity(self.generatemapper, runtime, True)
476+
self.add_volumes_singularity(self.generatemapper, runtime, stage_output=True)
471477

472478
runtime.append(u"--pwd")
473479
runtime.append("%s" % (docker_windows_path_adjust(self.builder.outdir)))

0 commit comments

Comments
 (0)