in utils/output_handling.py [0:0]
def export_csv(data_directory, filename, data):
"""Exports the content of data to a csv file in data_directory
Args:
data_directory: the directory to store the csv file.
filename: the name of the .csv file.
data: the collected data to be exported.
Returns:
The path to the newly created csv file.
"""
if not os.path.exists(data_directory):
os.makedirs(data_directory)
csv_file_path = os.path.join(data_directory, filename)
logger.log('Writing raw data into csv file: %s' % str(csv_file_path))
with open(csv_file_path, 'w') as csv_file:
hostname = socket.gethostname()
username = getpass.getuser()
csv_writer = csv.writer(csv_file)
csv_writer.writerow([
'project_source', 'project_commit', 'bazel_commit', 'run', 'cpu',
'wall', 'system', 'memory', 'command', 'expressions', 'hostname',
'username', 'options', 'exit_status', 'started_at', 'platform',
'project_label'
])
for (bazel_commit, project_commit), data_item in data.items():
command, expressions, options = data_item['args']
non_measurables = data_item['non_measurables']
for idx, run in enumerate(data_item['results'], start=1):
csv_writer.writerow([
non_measurables['project_source'], project_commit, bazel_commit,
idx, run['cpu'], run['wall'], run['system'], run['memory'], command,
expressions, hostname, username, options, run['exit_status'],
run['started_at'], non_measurables['platform'],
non_measurables['project_label']
])
return csv_file_path