Skip to content

Commit 3c950c9

Browse files
authored
Merge pull request #123 from common-workflow-language/fix-writable-files
Fix implementation of writable flag
2 parents 318030e + ce1c0e6 commit 3c950c9

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
@@ -294,6 +294,7 @@ def rm_pending_output_callback(output_callback, jobcachepending,
294294
et["entryname"] = builder.do_eval(t["entryname"])
295295
else:
296296
et["entryname"] = None
297+
et["writable"] = t.get("writable", False)
297298
ls.append(et)
298299
else:
299300
ls.append(builder.do_eval(t))
@@ -303,12 +304,14 @@ def rm_pending_output_callback(output_callback, jobcachepending,
303304
ls[i] = {
304305
"class": "File",
305306
"basename": t["entryname"],
306-
"contents": t["entry"]
307+
"contents": t["entry"],
308+
"writable": t.get("writable")
307309
}
308310
else:
309311
if t["entryname"]:
310312
t = copy.deepcopy(t)
311313
t["entry"]["basename"] = t["entryname"]
314+
t["entry"]["writable"] = t.get("writable")
312315
ls[i] = t["entry"]
313316
j.generatefiles[u"listing"] = ls
314317

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)