Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add colors to the spreadsheet for better readability #13

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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