#NEWLINE# def _expand_add_cleanup_jobs( self ) : #NEWLINE# #INDENT# "For all temp jobs, find a final non-temp target\n        if we have targets, create a cleanup job, add\n        all the temp job's output files and\n        make it dependant on the temp nodes targets\n        " #NEWLINE# log . info ( 'Expand | Checking for temporary jobs' ) #NEWLINE# temp_nodes = set ( [ ] ) #NEWLINE# targets = set ( [ ] ) #NEWLINE# temp_outputs = set ( [ ] ) #NEWLINE# for node in self . nodes ( ) : #NEWLINE# #INDENT# if node . _job . temp : #NEWLINE# #INDENT# temp_nodes . add ( node ) #NEWLINE# #UNINDENT# #UNINDENT# if temp_nodes : #NEWLINE# #INDENT# log . info ( 'Expand | Check temporary outputs for %d job(s)' , len ( temp_nodes ) ) #NEWLINE# for temp_node in temp_nodes : #NEWLINE# #INDENT# for opt in temp_node . _tool . options . get_by_type ( jip . options . TYPE_OUTPUT ) : #NEWLINE# #INDENT# if ( not opt . is_stream ( ) ) : #NEWLINE# #INDENT# temp_outputs . add ( opt ) #NEWLINE# #UNINDENT# #UNINDENT# for child in temp_node . children ( ) : #NEWLINE# #INDENT# if ( not child . _job . temp ) : #NEWLINE# #INDENT# targets . add ( child ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# log . info ( 'Expand | Found %d temporary outputs and %d targets' , len ( temp_outputs ) , len ( targets ) ) #NEWLINE# #UNINDENT# if ( len ( targets ) > 0 ) : #NEWLINE# #INDENT# cleanup_node = self . run ( 'cleanup' , files = list ( temp_outputs ) ) #NEWLINE# cleanup_node . job . threads = 1 #NEWLINE# cleanup_node . job . temp = True #NEWLINE# cleanup_node . job . name = 'cleanup' #NEWLINE# cleanup_node . _name = 'cleanup' #NEWLINE# cleanup_node . files . dependency = True #NEWLINE# for target in list ( targets ) : #NEWLINE# #INDENT# if ( ( not cleanup_node . _pipeline ) and target . _pipeline ) : #NEWLINE# #INDENT# cleanup_node . _pipeline = target . _pipeline #NEWLINE# #UNINDENT# cleanup_node . depends_on ( target ) #NEWLINE# #UNINDENT# self . _cleanup_nodes . append ( cleanup_node )