Skip to content

Commit ce1c0e6

Browse files
author
Peter Amstutz
committed
Fix writable flag. Was not correctly propagated from 'entry' to path mapper,
and job.py was overwriting the modified output file by accident.
1 parent d007cf6 commit ce1c0e6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

cwltool/draft2tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
295295
et["entryname"] = builder.do_eval(t["entryname"])
296296
else:
297297
et["entryname"] = None
298+
et["writable"] = t.get("writable", False)
298299
ls.append(et)
299300
else:
300301
ls.append(builder.do_eval(t))
@@ -304,12 +305,14 @@ def rm_pending_output_callback(output_callback, jobcachepending,
304305
ls[i] = {
305306
"class": "File",
306307
"basename": t["entryname"],
307-
"contents": t["entry"]
308+
"contents": t["entry"],
309+
"writable": t.get("writable")
308310
}
309311
else:
310312
if t["entryname"]:
311313
t = copy.deepcopy(t)
312314
t["entry"]["basename"] = t["entryname"]
315+
t["entry"]["writable"] = t.get("writable")
313316
ls[i] = t["entry"]
314317
j.generatefiles[u"listing"] = ls
315318

cwltool/job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self): # type: () -> None
5858
self.outdir = None # type: str
5959
self.tmpdir = None # type: str
6060
self.environment = None # type: Dict[str,str]
61-
self.generatefiles = None # type: Dict[unicode, Union[List[Dict[str, str]], Dict[str,str], str]]
61+
self.generatefiles = None # type: Dict[unicode, Union[List[Dict[str, str]], Dict[str,str], str]]
6262
self.stagedir = None # type: unicode
6363

6464
def run(self, dry_run=False, pull_image=True, rm_container=True,
@@ -251,7 +251,7 @@ def linkoutdir(src, tgt):
251251
if os.path.exists(tgt) and os.path.islink(tgt):
252252
os.remove(tgt)
253253
os.symlink(src, tgt)
254-
stageFiles(generatemapper, linkoutdir)
254+
stageFiles(generatemapper, linkoutdir, ignoreWritable=True)
255255

256256
outputs = self.collect_outputs(self.outdir)
257257

cwltool/process.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ def getListing(fs_access, rec):
169169
listing.append({"class": "File", "location": ld})
170170
rec["listing"] = listing
171171

172-
def stageFiles(pm, stageFunc):
172+
def stageFiles(pm, stageFunc, ignoreWritable=False):
173173
# type: (PathMapper, Callable[..., Any]) -> None
174174
for f, p in pm.items():
175175
if not os.path.exists(os.path.dirname(p.target)):
176176
os.makedirs(os.path.dirname(p.target), 0755)
177177
if p.type == "File":
178178
stageFunc(p.resolved, p.target)
179-
elif p.type == "WritableFile":
179+
elif p.type == "WritableFile" and not ignoreWritable:
180180
shutil.copy(p.resolved, p.target)
181-
elif p.type == "CreateFile":
181+
elif p.type == "CreateFile" and not ignoreWritable:
182182
with open(p.target, "w") as n:
183183
n.write(p.resolved.encode("utf-8"))
184184

0 commit comments

Comments
 (0)