Changeset 1577:0f4fd4c20cd6

Show
Ignore:
Timestamp:
10/28/08 10:21:02 (2 months ago)
Author:
Greg Von Kuster <greg@bx.psu.edu>
branch:
default
Message:

Improve job error messaging, some fixes for setting job state, job info, dataset state, and dataset info when job ends in error.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/galaxy/jobs/__init__.py

    r1570 r1577  
    177177                        log.debug( "job %d dispatched" % job.job_id) 
    178178                elif job_state == JOB_DELETED: 
    179                     log.debug( "job %d deleted by user while still queued" % job.job_id ) 
     179                    msg = "job %d deleted by user while still queued" % job.job_id 
     180                    job.info = msg 
     181                    log.debug( msg ) 
    180182                else: 
    181                     log.error( "unknown job state '%s' for job %d" % ( job_state, job.job_id )) 
    182             except: 
    183                 log.exception( "failure running job %d" % job.job_id ) 
     183                    msg = "unknown job state '%s' for job %d" % ( job_state, job.job_id ) 
     184                    job.info = msg 
     185                    log.error( msg ) 
     186            except Exception, e: 
     187                msg = "failure running job %d: %s" % ( job.job_id, str( e ) ) 
     188                job.info = msg 
     189                log.exception( msg ) 
    184190        # Update the waiting list 
    185191        self.waiting = new_waiting 
     
    195201                    # squeue is empty, so stop dispatching 
    196202                    break 
    197                 except: # if something else breaks while dispatching 
    198                     job.fail( "failure dispatching job" ) 
    199                     log.exception( "failure running job %d" % sjob.job_id ) 
     203                except Exception, e: # if something else breaks while dispatching 
     204                    msg = "failure running job %d: %s" % ( sjob.job_id, str( e ) ) 
     205                    job.fail( msg ) 
     206                    log.exception( msg ) 
    200207             
    201208    def put( self, job_id, tool ): 
     
    302309        return extra_filenames 
    303310         
    304     def fail( self, message, exception=False ): 
     311    def fail( self, message, state=None, exception=False ): 
    305312        """ 
    306313        Indicate job failure by setting state and message on all output  
     
    310317        job.refresh() 
    311318        # if the job was deleted, don't fail it 
    312         if job.state == job.states.DELETED: 
    313             self.cleanup() 
    314             return 
    315         for dataset_assoc in job.output_datasets: 
    316             dataset = dataset_assoc.dataset 
    317             dataset.refresh() 
    318             dataset.state = dataset.states.ERROR 
    319             dataset.blurb = 'tool error' 
    320             dataset.info = message 
    321             dataset.set_size() 
    322             dataset.flush() 
    323         job.state = model.Job.states.ERROR 
    324         job.command_line = self.command_line 
    325         job.info = message 
    326         # If the failure is due to a Galaxy framework exception, save  
    327         # the traceback 
    328         if exception: 
    329             job.traceback = traceback.format_exc() 
    330         job.flush() 
     319        if not job.state == job.states.DELETED: 
     320            for dataset_assoc in job.output_datasets: 
     321                dataset = dataset_assoc.dataset 
     322                dataset.refresh() 
     323                dataset.state = dataset.states.ERROR 
     324                dataset.blurb = 'tool error' 
     325                dataset.info = message 
     326                dataset.set_size() 
     327                dataset.flush() 
     328            if state is not None: 
     329                job.state = state 
     330            else: 
     331                job.state = model.Job.states.ERROR 
     332            job.command_line = self.command_line 
     333            job.info = message 
     334            # If the failure is due to a Galaxy framework exception, save the traceback 
     335            if exception: 
     336                job.traceback = traceback.format_exc() 
     337            job.flush() 
     338        # If the job was deleted, just clean up 
    331339        self.cleanup() 
    332340         
     
    372380        for dataset_assoc in job.input_datasets: 
    373381            idata = dataset_assoc.dataset 
    374             if not idata: continue 
     382            if not idata: 
     383                continue 
    375384            idata.refresh() 
    376385            idata.dataset.refresh() #we need to refresh the base Dataset, since that is where 'state' is stored 
    377386            # don't run jobs for which the input dataset was deleted 
    378             if idata.deleted == True: 
    379                 self.fail( "input data %d was deleted before this job ran" % idata.hid ) 
     387            if idata.deleted: 
     388                msg = "input data %d was deleted before this job started" % idata.hid 
     389                self.fail( msg, state=JOB_INPUT_DELETED ) 
    380390                return JOB_INPUT_DELETED 
    381391            # an error in the input data causes us to bail immediately 
    382392            elif idata.state == idata.states.ERROR: 
    383                 self.fail( "error in input data %d" % idata.hid ) 
     393                msg = "input data %d is in an error state" % idata.hid 
     394                self.fail( msg, state=JOB_INPUT_ERROR ) 
    384395                return JOB_INPUT_ERROR 
    385396            elif idata.state != idata.states.OK: 
     
    468479            if self.working_directory is not None: 
    469480                os.rmdir( self.working_directory )  
    470         except
    471             log.exception( "Unable to cleanup job %s" % self.job_id
     481        except Exception, e
     482            log.exception( "Unable to cleanup job %s, exception: %s" % ( str( self.job_id ), str( e ) )
    472483         
    473484    def get_command_line( self ): 
     
    618629        job.refresh() 
    619630        job.state = job.states.DELETED 
    620         job.info = "Job deleted by user before it completed." 
     631        job.info = "Job output deleted by user before job completed." 
    621632        job.flush() 
    622633        for dataset_assoc in job.output_datasets: 
     
    631642                dataset.blurb = 'deleted' 
    632643                dataset.peek = 'Job deleted' 
    633                 dataset.info = 'Job deleted by user before it completed' 
     644                dataset.info = 'Job output deleted by user before job completed' 
    634645                dataset.flush() 
    635646 
  • templates/dataset/errors.tmpl

    r847 r1577  
    11<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    22<html> 
     3    <head> 
     4        <title>Dataset generation errors</title> 
     5        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
     6        <link href="/static/style/base.css" rel="stylesheet" type="text/css" /> 
     7        <style> 
     8            pre 
     9            { 
     10                background: white; 
     11                color: black; 
     12                border: dotted black 1px; 
     13                overflow: auto; 
     14                padding: 10px; 
     15            } 
     16        </style> 
     17    </head> 
    318 
    4 <head> 
    5 <title>Dataset generation errors</title> 
    6 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    7 <link href="/static/style/base.css" rel="stylesheet" type="text/css" /> 
    8 <style> 
    9 pre 
    10 
    11     background: white; 
    12     color: black; 
    13     border: dotted black 1px; 
    14     overflow: auto; 
    15     padding: 10px; 
    16 
    17 </style> 
    18 </head> 
     19    <body> 
     20        <h2>Dataset generation errors</h2> 
     21        <p><b>Dataset $dataset.hid: $dataset.display_name</b></p> 
    1922 
    20 <body> 
    21    
    22   <h2>Dataset generation errors</h2> 
    23  
    24   <p><b>Dataset $dataset.hid: $dataset.display_name</b></p> 
    25    
    26   #if $dataset.creating_job_associations 
    27    
    28     #set job = $dataset.creating_job_associations[0].job 
    29    
    30     #if job.traceback 
    31       The Galaxy framework encountered the following error while attempting 
    32       to run the tool: 
     23        #if $dataset.creating_job_associations 
     24            #set job = $dataset.creating_job_associations[0].job 
     25            #if job.traceback 
     26                The Galaxy framework encountered the following error while attempting to run the tool: 
     27                <pre>${job.traceback}</pre> 
     28            #end if 
     29            #if $job.stderr or $job.info 
     30                Tool execution generated the following error message: 
     31                #if $job.stderr 
     32                    <pre>${job.stderr}</pre> 
     33                #elif $job.info 
     34                    <pre>${job.info}</pre> 
     35                #end if 
     36            #else 
     37                Tool execution did not generate any error messages. 
     38            #end if 
     39            #if $job.stdout 
     40                The tool produced the following additional output: 
     41                <pre>${job.stdout}</pre> 
     42            #end if 
     43        #else 
     44            The tool did not create any additional job / error info. 
     45        #end if 
    3346       
    34       <pre>${job.traceback}</pre> 
    35    
    36     #end if 
    37    
    38     #if $job.stderr 
    39       Tool execution generated the following error message: 
    40       <pre>${job.stderr}</pre> 
    41     #else 
    42       Tool execution did not generate any error messages. 
    43     #end if 
    44  
    45     #if $job.stdout 
    46       The tool produced the following additional output: 
    47       <pre>${job.stdout}</pre> 
    48     #end if 
    49  
    50   #else 
    51    
    52     The tool did not create any additional job / error info. 
    53    
    54   #end if 
    55    
    56   <h2>Report this error to the Galaxy Team</h2> 
    57    
    58   <p>The Galaxy team regularly reviews errors that occur in the application.  
    59   However, if you would like to provide additional information (such as  
    60   what you were trying to do when the error occurred) and a contact e-mail 
    61   address, we will be better able to investigate your problem and get back 
    62   to you.</p> 
    63    
    64   <div class="toolForm"> 
    65     <div class="toolFormTitle">Error Report</div> 
    66     <div class="toolFormBody"> 
    67     <form name="report_error" action="${h.url_for( action='report_error')}" method="post" > 
    68       <input type="hidden" name="id" value="$dataset.id" /> 
    69       <table>  
    70         <tr valign="top"><td>Your Email:</td><td><input type="text" name="email" size="40" /></td></tr> 
    71         <tr valign="top"><td>Message:</td><td><textarea name="message", rows="10" cols="40" /></textarea></td></tr> 
    72                         <tr><td></td><td><input type="submit" value="Report"> 
    73       </table> 
    74     </form> 
    75     </div> 
    76   </div> 
    77    
    78 </body> 
     47        <h2>Report this error to the Galaxy Team</h2> 
     48        <p> 
     49            The Galaxy team regularly reviews errors that occur in the application.  
     50            However, if you would like to provide additional information (such as  
     51            what you were trying to do when the error occurred) and a contact e-mail 
     52            address, we will be better able to investigate your problem and get back 
     53            to you. 
     54        </p> 
     55        <div class="toolForm"> 
     56            <div class="toolFormTitle">Error Report</div> 
     57            <div class="toolFormBody"> 
     58                <form name="report_error" action="${h.url_for( action='report_error')}" method="post" > 
     59                    <input type="hidden" name="id" value="$dataset.id" /> 
     60                    <table>  
     61                        <tr valign="top"><td>Your Email:</td><td><input type="text" name="email" size="40" /></td></tr> 
     62                        <tr valign="top"><td>Message:</td><td><textarea name="message", rows="10" cols="40" /></textarea></td></tr> 
     63                        <tr><td></td><td><input type="submit" value="Report"> 
     64                    </table> 
     65                </form> 
     66            </div> 
     67      </div> 
     68    </body> 
    7969</html>