@@ -346,7 +346,9 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
346346 j .hints = self .hints
347347 j .name = jobname
348348
349- if _logger .isEnabledFor (logging .DEBUG ):
349+ debug = _logger .isEnabledFor (logging .DEBUG )
350+
351+ if debug :
350352 _logger .debug (u"[job %s] initializing from %s%s" ,
351353 j .name ,
352354 self .tool .get ("id" , "" ),
@@ -405,28 +407,28 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
405407 self .updatePathmap (builder .outdir , builder .pathmapper , l )
406408 visit_class ([builder .files , builder .bindings ], ("File" , "Directory" ), _check_adjust )
407409
408- if _logger . isEnabledFor ( logging . DEBUG ) :
410+ if debug :
409411 _logger .debug (u"[job %s] path mappings is %s" , j .name ,
410412 json .dumps ({p : builder .pathmapper .mapper (p ) for p in builder .pathmapper .files ()}, indent = 4 ))
411413
412414 if self .tool .get ("stdin" ):
413- with SourceLine (self .tool , "stdin" , validate .ValidationException ):
415+ with SourceLine (self .tool , "stdin" , validate .ValidationException , debug ):
414416 j .stdin = builder .do_eval (self .tool ["stdin" ])
415417 reffiles .append ({"class" : "File" , "path" : j .stdin })
416418
417419 if self .tool .get ("stderr" ):
418- with SourceLine (self .tool , "stderr" , validate .ValidationException ):
420+ with SourceLine (self .tool , "stderr" , validate .ValidationException , debug ):
419421 j .stderr = builder .do_eval (self .tool ["stderr" ])
420422 if os .path .isabs (j .stderr ) or ".." in j .stderr :
421423 raise validate .ValidationException ("stderr must be a relative path, got '%s'" % j .stderr )
422424
423425 if self .tool .get ("stdout" ):
424- with SourceLine (self .tool , "stdout" , validate .ValidationException ):
426+ with SourceLine (self .tool , "stdout" , validate .ValidationException , debug ):
425427 j .stdout = builder .do_eval (self .tool ["stdout" ])
426428 if os .path .isabs (j .stdout ) or ".." in j .stdout or not j .stdout :
427429 raise validate .ValidationException ("stdout must be a relative path, got '%s'" % j .stdout )
428430
429- if _logger . isEnabledFor ( logging . DEBUG ) :
431+ if debug :
430432 _logger .debug (u"[job %s] command line bindings is %s" , j .name , json .dumps (builder .bindings , indent = 4 ))
431433
432434 dockerReq = self .get_requirement ("DockerRequirement" )[0 ]
@@ -505,17 +507,18 @@ def register_reader(f):
505507 def collect_output_ports (self , ports , builder , outdir , compute_checksum = True , jobname = "" , readers = None ):
506508 # type: (Set[Dict[Text, Any]], Builder, Text, bool, Text, Dict[Text, Any]) -> Dict[Text, Union[Text, List[Any], Dict[Text, Any]]]
507509 ret = {} # type: Dict[Text, Union[Text, List[Any], Dict[Text, Any]]]
510+ debug = _logger .isEnabledFor (logging .DEBUG )
508511 try :
509512 fs_access = builder .make_fs_access (outdir )
510513 custom_output = fs_access .join (outdir , "cwl.output.json" )
511514 if fs_access .exists (custom_output ):
512515 with fs_access .open (custom_output , "r" ) as f :
513516 ret = json .load (f )
514- if _logger . isEnabledFor ( logging . DEBUG ) :
517+ if debug :
515518 _logger .debug (u"Raw output from %s: %s" , custom_output , json .dumps (ret , indent = 4 ))
516519 else :
517520 for i , port in enumerate (ports ):
518- with SourceLine (ports , i , WorkflowException ):
521+ with SourceLine (ports , i , WorkflowException , debug ):
519522 fragment = shortname (port ["id" ])
520523 try :
521524 ret [fragment ] = self .collect_output (port , builder , outdir , fs_access ,
@@ -554,14 +557,15 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
554557 def collect_output (self , schema , builder , outdir , fs_access , compute_checksum = True ):
555558 # type: (Dict[Text, Any], Builder, Text, StdFsAccess, bool) -> Union[Dict[Text, Any], List[Union[Dict[Text, Any], Text]]]
556559 r = [] # type: List[Any]
560+ debug = _logger .isEnabledFor (logging .DEBUG )
557561 if "outputBinding" in schema :
558562 binding = schema ["outputBinding" ]
559563 globpatterns = [] # type: List[Text]
560564
561565 revmap = partial (revmap_file , builder , outdir )
562566
563567 if "glob" in binding :
564- with SourceLine (binding , "glob" , WorkflowException ):
568+ with SourceLine (binding , "glob" , WorkflowException , debug ):
565569 for gb in aslist (binding ["glob" ]):
566570 gb = builder .do_eval (gb )
567571 if gb :
@@ -626,12 +630,12 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
626630 single = True
627631
628632 if "outputEval" in binding :
629- with SourceLine (binding , "outputEval" , WorkflowException ):
633+ with SourceLine (binding , "outputEval" , WorkflowException , debug ):
630634 r = builder .do_eval (binding ["outputEval" ], context = r )
631635
632636 if single :
633637 if not r and not optional :
634- with SourceLine (binding , "glob" , WorkflowException ):
638+ with SourceLine (binding , "glob" , WorkflowException , debug ):
635639 raise WorkflowException ("Did not find output file with glob pattern: '{}'" .format (globpatterns ))
636640 elif not r and optional :
637641 pass
@@ -642,7 +646,7 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr
642646 r = r [0 ]
643647
644648 if "secondaryFiles" in schema :
645- with SourceLine (schema , "secondaryFiles" , WorkflowException ):
649+ with SourceLine (schema , "secondaryFiles" , WorkflowException , debug ):
646650 for primary in aslist (r ):
647651 if isinstance (primary , dict ):
648652 primary .setdefault ("secondaryFiles" , [])
0 commit comments