#NEWLINE# @ gen . engine #NEWLINE# def FindLastSuccess( self , callback , start_timestamp = None , with_payload_key = None , with_payload_value = None ) : #NEWLINE# #INDENT# 'Find and return the latest successful run. Search back to start_timestamp (a week ago if None).\n    If with_payload_key is not None, the key must be found in the payload (DotDict format).\n    If with_payload_value is not None, the value at that key must match.\n    Callback is run with the matching metric payload if found, else with None.\n    ' #NEWLINE# payloads = ( yield gen . Task ( payloads . FindPreviousRuns , start_timestamp = start_timestamp , status = Job . STATUS_SUCCESS ) ) #NEWLINE# for p in reversed ( payloads ) : #NEWLINE# #INDENT# assert ( p [ 'status' ] == Job . STATUS_SUCCESS ) #NEWLINE# if ( ( with_payload_key is not None ) and ( with_payload_key not in p ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( with_payload_value is not None ) : #NEWLINE# #INDENT# assert ( with_payload_key is not None ) , 'with_payload_value specified, but with_payload_key is None' #NEWLINE# if ( p [ with_payload_key ] != with_payload_value ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# callback ( p ) #NEWLINE# return #NEWLINE# #UNINDENT# callback ( None )