@@ -365,16 +365,17 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True):
365
365
# type: (Set[Dict[str,Any]], Builder, str) -> Dict[unicode, Union[unicode, List[Any], Dict[unicode, Any]]]
366
366
try :
367
367
ret = {} # type: Dict[unicode, Union[unicode, List[Any], Dict[unicode, Any]]]
368
- custom_output = builder .fs_access .join (outdir , "cwl.output.json" )
369
- if builder .fs_access .exists (custom_output ):
370
- with builder .fs_access .open (custom_output , "r" ) as f :
368
+ fs_access = builder .make_fs_access (outdir )
369
+ custom_output = fs_access .join (outdir , "cwl.output.json" )
370
+ if fs_access .exists (custom_output ):
371
+ with fs_access .open (custom_output , "r" ) as f :
371
372
ret = json .load (f )
372
373
_logger .debug (u"Raw output from %s: %s" , custom_output , json .dumps (ret , indent = 4 ))
373
374
else :
374
375
for port in ports :
375
376
fragment = shortname (port ["id" ])
376
377
try :
377
- ret [fragment ] = self .collect_output (port , builder , outdir , compute_checksum )
378
+ ret [fragment ] = self .collect_output (port , builder , outdir , fs_access , compute_checksum = compute_checksum )
378
379
except Exception as e :
379
380
_logger .debug (u"Error collecting output for parameter '%s'" % shortname (port ["id" ]), exc_info = e )
380
381
raise WorkflowException (u"Error collecting output for parameter '%s': %s" % (shortname (port ["id" ]), e ))
@@ -388,14 +389,14 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True):
388
389
adjustDirObjs (ret , remove_path )
389
390
normalizeFilesDirs (ret )
390
391
if compute_checksum :
391
- adjustFileObjs (ret , partial (compute_checksums , builder . fs_access ))
392
+ adjustFileObjs (ret , partial (compute_checksums , fs_access ))
392
393
393
394
validate .validate_ex (self .names .get_name ("outputs_record_schema" , "" ), ret )
394
395
return ret if ret is not None else {}
395
396
except validate .ValidationException as e :
396
397
raise WorkflowException ("Error validating output record, " + str (e ) + "\n in " + json .dumps (ret , indent = 4 ))
397
398
398
- def collect_output (self , schema , builder , outdir , compute_checksum = True ):
399
+ def collect_output (self , schema , builder , outdir , fs_access , compute_checksum = True ):
399
400
# type: (Dict[str,Any], Builder, str) -> Union[Dict[unicode, Any], List[Union[Dict[unicode, Any], unicode]]]
400
401
r = [] # type: List[Any]
401
402
if "outputBinding" in schema :
@@ -419,16 +420,16 @@ def collect_output(self, schema, builder, outdir, compute_checksum=True):
419
420
raise WorkflowException ("glob patterns must not start with '/'" )
420
421
try :
421
422
r .extend ([{"location" : g ,
422
- "class" : "File" if builder . fs_access .isfile (g ) else "Directory" }
423
- for g in builder . fs_access .glob (builder . fs_access .join (outdir , gb ))])
423
+ "class" : "File" if fs_access .isfile (g ) else "Directory" }
424
+ for g in fs_access .glob (fs_access .join (outdir , gb ))])
424
425
except (OSError , IOError ) as e :
425
426
_logger .warn (str (e ))
426
427
427
428
for files in r :
428
429
if files ["class" ] == "Directory" and "listing" not in files :
429
- getListing (builder . fs_access , files )
430
+ getListing (fs_access , files )
430
431
else :
431
- with builder . fs_access .open (files ["location" ], "rb" ) as f :
432
+ with fs_access .open (files ["location" ], "rb" ) as f :
432
433
contents = ""
433
434
if binding .get ("loadContents" ) or compute_checksum :
434
435
contents = f .read (CONTENT_LIMIT )
@@ -488,7 +489,7 @@ def collect_output(self, schema, builder, outdir, compute_checksum=True):
488
489
sfpath = {"location" : substitute (primary ["location" ], sf ), "class" : "File" }
489
490
490
491
for sfitem in aslist (sfpath ):
491
- if builder . fs_access .exists (sfitem ["location" ]):
492
+ if fs_access .exists (sfitem ["location" ]):
492
493
primary ["secondaryFiles" ].append (sfitem )
493
494
494
495
if not r and optional :
@@ -499,6 +500,6 @@ def collect_output(self, schema, builder, outdir, compute_checksum=True):
499
500
out = {}
500
501
for f in schema ["type" ]["fields" ]:
501
502
out [shortname (f ["name" ])] = self .collect_output ( # type: ignore
502
- f , builder , outdir , compute_checksum )
503
+ f , builder , outdir , fs_access , compute_checksum = compute_checksum )
503
504
return out
504
505
return r
0 commit comments