@@ -109,8 +109,9 @@ def revmap_file(builder, outdir, f):
109
109
if f ["location" ].startswith ("file://" ):
110
110
path = convert_pathsep_to_unix (uri_file_path (f ["location" ]))
111
111
revmap_f = builder .pathmapper .reversemap (path )
112
- if revmap_f :
113
- f ["location" ] = revmap_f [1 ]
112
+ if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
113
+ f ["basename" ] = os .path .basename (path )
114
+ f ["location" ] = revmap_f [0 ]
114
115
elif path == builder .outdir :
115
116
f ["location" ] = outdir
116
117
elif path .startswith (builder .outdir ):
@@ -189,7 +190,7 @@ def makeJobRunner(self, use_container=True): # type: (Optional[bool]) -> JobBas
189
190
"dockerPull" : default_container
190
191
})
191
192
dockerReq = self .requirements [0 ]
192
-
193
+
193
194
if dockerReq and use_container :
194
195
return DockerCommandLineJob ()
195
196
else :
@@ -204,6 +205,17 @@ def makePathMapper(self, reffiles, stagedir, **kwargs):
204
205
# type: (List[Any], Text, **Any) -> PathMapper
205
206
return PathMapper (reffiles , kwargs ["basedir" ], stagedir )
206
207
208
+ def updatePathmap (self , outdir , pathmap , fn ):
209
+ # type: (Text, PathMapper, Dict) -> None
210
+ if "location" in fn :
211
+ pathmap .update (fn ["location" ], pathmap .mapper (fn ["location" ]).resolved ,
212
+ os .path .join (outdir , fn ["basename" ]),
213
+ ("Writable" if fn .get ("writable" ) else "" ) + fn ["class" ], False )
214
+ for sf in fn .get ("secondaryFiles" , []):
215
+ self .updatePathmap (outdir , pathmap , sf )
216
+ for ls in fn .get ("listing" , []):
217
+ self .updatePathmap (os .path .join (outdir , fn ["basename" ]), pathmap , ls )
218
+
207
219
def job (self ,
208
220
job_order , # type: Dict[Text, Text]
209
221
output_callbacks , # type: Callable[[Any, Any], Any]
@@ -328,46 +340,10 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
328
340
builder .pathmapper = self .makePathMapper (reffiles , builder .stagedir , ** make_path_mapper_kwargs )
329
341
builder .requirements = j .requirements
330
342
331
- if _logger .isEnabledFor (logging .DEBUG ):
332
- _logger .debug (u"[job %s] path mappings is %s" , j .name ,
333
- json .dumps ({p : builder .pathmapper .mapper (p ) for p in builder .pathmapper .files ()}, indent = 4 ))
334
-
335
343
_check_adjust = partial (check_adjust , builder )
336
344
337
345
visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
338
346
339
- if self .tool .get ("stdin" ):
340
- with SourceLine (self .tool , "stdin" , validate .ValidationException ):
341
- j .stdin = builder .do_eval (self .tool ["stdin" ])
342
- reffiles .append ({"class" : "File" , "path" : j .stdin })
343
-
344
- if self .tool .get ("stderr" ):
345
- with SourceLine (self .tool , "stderr" , validate .ValidationException ):
346
- j .stderr = builder .do_eval (self .tool ["stderr" ])
347
- if os .path .isabs (j .stderr ) or ".." in j .stderr :
348
- raise validate .ValidationException ("stderr must be a relative path, got '%s'" % j .stderr )
349
-
350
- if self .tool .get ("stdout" ):
351
- with SourceLine (self .tool , "stdout" , validate .ValidationException ):
352
- j .stdout = builder .do_eval (self .tool ["stdout" ])
353
- if os .path .isabs (j .stdout ) or ".." in j .stdout or not j .stdout :
354
- raise validate .ValidationException ("stdout must be a relative path, got '%s'" % j .stdout )
355
-
356
- if _logger .isEnabledFor (logging .DEBUG ):
357
- _logger .debug (u"[job %s] command line bindings is %s" , j .name , json .dumps (builder .bindings , indent = 4 ))
358
-
359
- dockerReq = self .get_requirement ("DockerRequirement" )[0 ]
360
- if dockerReq and kwargs .get ("use_container" ):
361
- out_prefix = kwargs .get ("tmp_outdir_prefix" )
362
- j .outdir = kwargs .get ("outdir" ) or tempfile .mkdtemp (prefix = out_prefix )
363
- tmpdir_prefix = kwargs .get ('tmpdir_prefix' )
364
- j .tmpdir = kwargs .get ("tmpdir" ) or tempfile .mkdtemp (prefix = tmpdir_prefix )
365
- j .stagedir = tempfile .mkdtemp (prefix = tmpdir_prefix )
366
- else :
367
- j .outdir = builder .outdir
368
- j .tmpdir = builder .tmpdir
369
- j .stagedir = builder .stagedir
370
-
371
347
initialWorkdir = self .get_requirement ("InitialWorkDirRequirement" )[0 ]
372
348
j .generatefiles = {"class" : "Directory" , "listing" : [], "basename" : "" }
373
349
if initialWorkdir :
@@ -403,6 +379,45 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
403
379
t ["entry" ]["writable" ] = t .get ("writable" )
404
380
ls [i ] = t ["entry" ]
405
381
j .generatefiles [u"listing" ] = ls
382
+ for l in ls :
383
+ self .updatePathmap (builder .outdir , builder .pathmapper , l )
384
+ visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
385
+
386
+ if _logger .isEnabledFor (logging .DEBUG ):
387
+ _logger .debug (u"[job %s] path mappings is %s" , j .name ,
388
+ json .dumps ({p : builder .pathmapper .mapper (p ) for p in builder .pathmapper .files ()}, indent = 4 ))
389
+
390
+ if self .tool .get ("stdin" ):
391
+ with SourceLine (self .tool , "stdin" , validate .ValidationException ):
392
+ j .stdin = builder .do_eval (self .tool ["stdin" ])
393
+ reffiles .append ({"class" : "File" , "path" : j .stdin })
394
+
395
+ if self .tool .get ("stderr" ):
396
+ with SourceLine (self .tool , "stderr" , validate .ValidationException ):
397
+ j .stderr = builder .do_eval (self .tool ["stderr" ])
398
+ if os .path .isabs (j .stderr ) or ".." in j .stderr :
399
+ raise validate .ValidationException ("stderr must be a relative path, got '%s'" % j .stderr )
400
+
401
+ if self .tool .get ("stdout" ):
402
+ with SourceLine (self .tool , "stdout" , validate .ValidationException ):
403
+ j .stdout = builder .do_eval (self .tool ["stdout" ])
404
+ if os .path .isabs (j .stdout ) or ".." in j .stdout or not j .stdout :
405
+ raise validate .ValidationException ("stdout must be a relative path, got '%s'" % j .stdout )
406
+
407
+ if _logger .isEnabledFor (logging .DEBUG ):
408
+ _logger .debug (u"[job %s] command line bindings is %s" , j .name , json .dumps (builder .bindings , indent = 4 ))
409
+
410
+ dockerReq = self .get_requirement ("DockerRequirement" )[0 ]
411
+ if dockerReq and kwargs .get ("use_container" ):
412
+ out_prefix = kwargs .get ("tmp_outdir_prefix" )
413
+ j .outdir = kwargs .get ("outdir" ) or tempfile .mkdtemp (prefix = out_prefix )
414
+ tmpdir_prefix = kwargs .get ('tmpdir_prefix' )
415
+ j .tmpdir = kwargs .get ("tmpdir" ) or tempfile .mkdtemp (prefix = tmpdir_prefix )
416
+ j .stagedir = tempfile .mkdtemp (prefix = tmpdir_prefix )
417
+ else :
418
+ j .outdir = builder .outdir
419
+ j .tmpdir = builder .tmpdir
420
+ j .stagedir = builder .stagedir
406
421
407
422
inplaceUpdateReq = self .get_requirement ("http://commonwl.org/cwltool#InplaceUpdateRequirement" )[0 ]
408
423
0 commit comments