#NEWLINE# def PublishSamples( self , samples ) : #NEWLINE# #INDENT# if ( not samples ) : #NEWLINE# #INDENT# logging . warn ( 'No samples: not publishing to BigQuery' ) #NEWLINE# return #NEWLINE# #UNINDENT# with vm_util . NamedTemporaryFile ( prefix = 'perfkit-bq-pub' , dir = vm_util . GetTempDir ( ) , suffix = '.json' ) as tf : #NEWLINE# #INDENT# json_publisher = NewlineDelimitedJSONPublisher ( tf . name , collapse_labels = True ) #NEWLINE# json_publisher . PublishSamples ( samples ) #NEWLINE# tf . close ( ) #NEWLINE# logging . info ( 'Publishing %d samples to %s' , len ( load_cmd ) , self . bigquery_table ) #NEWLINE# load_cmd = [ self . bq_path ] #NEWLINE# if self . project_id : #NEWLINE# #INDENT# load_cmd . append ( ( '--project_id=' + self . project_id ) ) #NEWLINE# #UNINDENT# if self . service_account : #NEWLINE# #INDENT# assert ( self . service_account_private_key_file is not None ) #NEWLINE# load_cmd . extend ( [ ( '--service_account=' + self . service_account ) , ( '--service_account_credential_file=' + self . _credentials_file ) , ( '--service_account_private_key_file=' + self . service_account_private_key_file ) ] ) #NEWLINE# #UNINDENT# load_cmd . extend ( [ 'load' , '--source_format=NEWLINE_DELIMITED_JSON' , self . bigquery_table , tf . name ] ) #NEWLINE# vm_util . IssueRetryableCommand ( load_cmd )