From d44814cd66834f353d6b15770283a5dda7f24c85 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Sun, 5 Nov 2023 09:37:18 +1300 Subject: [PATCH] Fix some issues with drawing notes on the graph. (#39) * Copy the notes list before plotting. (Otherwise when popping a note from the list, it will disappear for plots that are generated later). * May combine multiple notes and plot them on the same date. --- scripts/history_report.py | 2 +- scripts/plot.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/history_report.py b/scripts/history_report.py index 7cd2e80..fadb1f7 100644 --- a/scripts/history_report.py +++ b/scripts/history_report.py @@ -85,6 +85,6 @@ pp.pprint(baseline) # plot - fig = plot.plot_history(runs, plan, benchmarks, from_date, to_date, "execution_times", baseline, config['notes']) + fig = plot.plot_history(runs, plan, benchmarks, from_date, to_date, "execution_times", baseline, config['notes'].copy()) path = os.path.join(output_dir, "%s_%s_history.html" % (prefix, plan)) fig.write_html(path) diff --git a/scripts/plot.py b/scripts/plot.py index 7c03e05..389a0d7 100644 --- a/scripts/plot.py +++ b/scripts/plot.py @@ -81,9 +81,17 @@ def peek_next_note_date(): for idx, run_id in enumerate(x_labels): log_date = parse.parse_run_date(run_id) if log_date >= next_note_date: - note = notes.pop(0) - aligned_notes.append({ 'run_id': run_id, 'x': x[idx], 'note': f"{note['date']}: {note['note']}" }) - next_note_date = peek_next_note_date() + # We may have multiple notes on this date. We have to combine them. + combined_note = None + + while log_date >= next_note_date: + note = notes.pop(0) + if combined_note is None: + combined_note = { 'run_id': run_id, 'x': x[idx], 'note': f"{note['date']}: {note['note']}" } + else: + combined_note['note'] += f",{note['date']}: {note['note']}" + next_note_date = peek_next_note_date() + aligned_notes.append(combined_note) y_cur_aboslute = y[-1]