@@ -120,8 +120,9 @@ def revmap_file(builder, outdir, f):
120
120
if f ["location" ].startswith ("file://" ):
121
121
path = convert_pathsep_to_unix (uri_file_path (f ["location" ]))
122
122
revmap_f = builder .pathmapper .reversemap (path )
123
- if revmap_f :
124
- f ["location" ] = revmap_f [1 ]
123
+ if revmap_f and not builder .pathmapper .mapper (revmap_f [0 ]).type .startswith ("Writable" ):
124
+ f ["basename" ] = os .path .basename (path )
125
+ f ["location" ] = revmap_f [0 ]
125
126
elif path == builder .outdir :
126
127
f ["location" ] = outdir
127
128
elif path .startswith (builder .outdir ):
@@ -202,7 +203,7 @@ def makeJobRunner(self, use_container=True): # type: (Optional[bool]) -> JobBas
202
203
dockerReq = self .requirements [0 ]
203
204
if default_container == windows_default_container_id and use_container and onWindows ():
204
205
_logger .warning (DEFAULT_CONTAINER_MSG % (windows_default_container_id , windows_default_container_id ))
205
-
206
+
206
207
if dockerReq and use_container :
207
208
return DockerCommandLineJob ()
208
209
else :
@@ -217,6 +218,17 @@ def makePathMapper(self, reffiles, stagedir, **kwargs):
217
218
# type: (List[Any], Text, **Any) -> PathMapper
218
219
return PathMapper (reffiles , kwargs ["basedir" ], stagedir )
219
220
221
+ def updatePathmap (self , outdir , pathmap , fn ):
222
+ # type: (Text, PathMapper, Dict) -> None
223
+ if "location" in fn :
224
+ pathmap .update (fn ["location" ], pathmap .mapper (fn ["location" ]).resolved ,
225
+ os .path .join (outdir , fn ["basename" ]),
226
+ ("Writable" if fn .get ("writable" ) else "" ) + fn ["class" ], False )
227
+ for sf in fn .get ("secondaryFiles" , []):
228
+ self .updatePathmap (outdir , pathmap , sf )
229
+ for ls in fn .get ("listing" , []):
230
+ self .updatePathmap (os .path .join (outdir , fn ["basename" ]), pathmap , ls )
231
+
220
232
def job (self ,
221
233
job_order , # type: Dict[Text, Text]
222
234
output_callbacks , # type: Callable[[Any, Any], Any]
@@ -341,46 +353,10 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
341
353
builder .pathmapper = self .makePathMapper (reffiles , builder .stagedir , ** make_path_mapper_kwargs )
342
354
builder .requirements = j .requirements
343
355
344
- if _logger .isEnabledFor (logging .DEBUG ):
345
- _logger .debug (u"[job %s] path mappings is %s" , j .name ,
346
- json .dumps ({p : builder .pathmapper .mapper (p ) for p in builder .pathmapper .files ()}, indent = 4 ))
347
-
348
356
_check_adjust = partial (check_adjust , builder )
349
357
350
358
visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
351
359
352
- if self .tool .get ("stdin" ):
353
- with SourceLine (self .tool , "stdin" , validate .ValidationException ):
354
- j .stdin = builder .do_eval (self .tool ["stdin" ])
355
- reffiles .append ({"class" : "File" , "path" : j .stdin })
356
-
357
- if self .tool .get ("stderr" ):
358
- with SourceLine (self .tool , "stderr" , validate .ValidationException ):
359
- j .stderr = builder .do_eval (self .tool ["stderr" ])
360
- if os .path .isabs (j .stderr ) or ".." in j .stderr :
361
- raise validate .ValidationException ("stderr must be a relative path, got '%s'" % j .stderr )
362
-
363
- if self .tool .get ("stdout" ):
364
- with SourceLine (self .tool , "stdout" , validate .ValidationException ):
365
- j .stdout = builder .do_eval (self .tool ["stdout" ])
366
- if os .path .isabs (j .stdout ) or ".." in j .stdout or not j .stdout :
367
- raise validate .ValidationException ("stdout must be a relative path, got '%s'" % j .stdout )
368
-
369
- if _logger .isEnabledFor (logging .DEBUG ):
370
- _logger .debug (u"[job %s] command line bindings is %s" , j .name , json .dumps (builder .bindings , indent = 4 ))
371
-
372
- dockerReq = self .get_requirement ("DockerRequirement" )[0 ]
373
- if dockerReq and kwargs .get ("use_container" ):
374
- out_prefix = kwargs .get ("tmp_outdir_prefix" )
375
- j .outdir = kwargs .get ("outdir" ) or tempfile .mkdtemp (prefix = out_prefix )
376
- tmpdir_prefix = kwargs .get ('tmpdir_prefix' )
377
- j .tmpdir = kwargs .get ("tmpdir" ) or tempfile .mkdtemp (prefix = tmpdir_prefix )
378
- j .stagedir = tempfile .mkdtemp (prefix = tmpdir_prefix )
379
- else :
380
- j .outdir = builder .outdir
381
- j .tmpdir = builder .tmpdir
382
- j .stagedir = builder .stagedir
383
-
384
360
initialWorkdir = self .get_requirement ("InitialWorkDirRequirement" )[0 ]
385
361
j .generatefiles = {"class" : "Directory" , "listing" : [], "basename" : "" }
386
362
if initialWorkdir :
@@ -416,6 +392,45 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
416
392
t ["entry" ]["writable" ] = t .get ("writable" )
417
393
ls [i ] = t ["entry" ]
418
394
j .generatefiles [u"listing" ] = ls
395
+ for l in ls :
396
+ self .updatePathmap (builder .outdir , builder .pathmapper , l )
397
+ visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
398
+
399
+ if _logger .isEnabledFor (logging .DEBUG ):
400
+ _logger .debug (u"[job %s] path mappings is %s" , j .name ,
401
+ json .dumps ({p : builder .pathmapper .mapper (p ) for p in builder .pathmapper .files ()}, indent = 4 ))
402
+
403
+ if self .tool .get ("stdin" ):
404
+ with SourceLine (self .tool , "stdin" , validate .ValidationException ):
405
+ j .stdin = builder .do_eval (self .tool ["stdin" ])
406
+ reffiles .append ({"class" : "File" , "path" : j .stdin })
407
+
408
+ if self .tool .get ("stderr" ):
409
+ with SourceLine (self .tool , "stderr" , validate .ValidationException ):
410
+ j .stderr = builder .do_eval (self .tool ["stderr" ])
411
+ if os .path .isabs (j .stderr ) or ".." in j .stderr :
412
+ raise validate .ValidationException ("stderr must be a relative path, got '%s'" % j .stderr )
413
+
414
+ if self .tool .get ("stdout" ):
415
+ with SourceLine (self .tool , "stdout" , validate .ValidationException ):
416
+ j .stdout = builder .do_eval (self .tool ["stdout" ])
417
+ if os .path .isabs (j .stdout ) or ".." in j .stdout or not j .stdout :
418
+ raise validate .ValidationException ("stdout must be a relative path, got '%s'" % j .stdout )
419
+
420
+ if _logger .isEnabledFor (logging .DEBUG ):
421
+ _logger .debug (u"[job %s] command line bindings is %s" , j .name , json .dumps (builder .bindings , indent = 4 ))
422
+
423
+ dockerReq = self .get_requirement ("DockerRequirement" )[0 ]
424
+ if dockerReq and kwargs .get ("use_container" ):
425
+ out_prefix = kwargs .get ("tmp_outdir_prefix" )
426
+ j .outdir = kwargs .get ("outdir" ) or tempfile .mkdtemp (prefix = out_prefix )
427
+ tmpdir_prefix = kwargs .get ('tmpdir_prefix' )
428
+ j .tmpdir = kwargs .get ("tmpdir" ) or tempfile .mkdtemp (prefix = tmpdir_prefix )
429
+ j .stagedir = tempfile .mkdtemp (prefix = tmpdir_prefix )
430
+ else :
431
+ j .outdir = builder .outdir
432
+ j .tmpdir = builder .tmpdir
433
+ j .stagedir = builder .stagedir
419
434
420
435
inplaceUpdateReq = self .get_requirement ("http://commonwl.org/cwltool#InplaceUpdateRequirement" )[0 ]
421
436
0 commit comments