Skip to content

Commit

Permalink
Add colors to the spreadsheet for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharras committed Oct 16, 2023
1 parent 7ea962f commit 5f0ad34
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions benchmarks/kmeans/consolidate_result_csv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
from io import BytesIO
from itertools import zip_longest
from operator import attrgetter

import numpy as np
Expand Down Expand Up @@ -385,6 +386,8 @@ def _gspread_sync(source, gspread_url, gspread_auth_key):
# freeze filter rows and benchmark-defining cols
worksheet.freeze(rows=1, cols=walltime_worksheet_col)

format_queries = []

# Text is centerd and wrapped in all cells
global_format = dict(
horizontalAlignment="CENTER",
Expand All @@ -395,7 +398,7 @@ def _gspread_sync(source, gspread_url, gspread_auth_key):
f"{gspread.utils.rowcol_to_a1(1, 1)}:"
f"{gspread.utils.rowcol_to_a1(n_rows + 1, n_cols)}"
)
worksheet.format(global_range, global_format)
format_queries.append(dict(range=global_range, format=global_format))

# benchmark_id and walltime columns are bold
bold_format = dict(textFormat=dict(bold=True))
Expand All @@ -407,12 +410,44 @@ def _gspread_sync(source, gspread_url, gspread_auth_key):
f"{gspread.utils.rowcol_to_a1(2, walltime_worksheet_col)}:"
f"{gspread.utils.rowcol_to_a1(n_rows + 1, walltime_worksheet_col)}"
)
worksheet.batch_format(
[
dict(range=benchmark_id_col_range, format=bold_format),
dict(range=walltime_col_range, format=bold_format),
]
format_queries.append(dict(range=benchmark_id_col_range, format=bold_format))
format_queries.append(dict(range=walltime_col_range, format=bold_format))

# Header is light-ish yellow
yellow_lighter_header = dict(
backgroundColorStyle=dict(
rgbColor=dict(red=1, green=1, blue=102 / 255, alpha=1)
)
)
header_row_range = (
f"{gspread.utils.rowcol_to_a1(1, 1)}:"
f"{gspread.utils.rowcol_to_a1(1, n_cols)}"
)
format_queries.append(dict(range=header_row_range, format=yellow_lighter_header))

# Every other benchmark_id has greyed background
bright_gray_background = dict(
backgroundColorStyle=dict(
rgbColor=dict(red=232 / 255, green=233 / 255, blue=235 / 255, alpha=1)
)
)
benchmark_ids = df[BENCHMARK_ID_NAME]
benchmark_ids_ending_idx = (
np.where((benchmark_ids.shift() != benchmark_ids).values[1:])[0] + 2
)
for benchmark_id_range_start, benchmark_id_range_end in zip_longest(
*(iter(benchmark_ids_ending_idx),) * 2
):
benchmark_row_range = (
f"{gspread.utils.rowcol_to_a1(benchmark_id_range_start + 1, 1)}:"
f"{gspread.utils.rowcol_to_a1(benchmark_id_range_end or (n_rows + 1), n_cols)}" # noqa
)
format_queries.append(
dict(range=benchmark_row_range, format=bright_gray_background)
)

# Apply formats
worksheet.batch_format(format_queries)

# auto-resize rows and cols
worksheet.columns_auto_resize(0, n_cols - 1)
Expand Down

0 comments on commit 5f0ad34

Please sign in to comment.