Skip to content

Commit

Permalink
Handle empty history response (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Aug 13, 2021
1 parent ce0e559 commit 6e296c5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions conbench/app/_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@


class TimeSeriesPlotMixin:
def _get_history_plot(self, benchmark):
def get_history_plot(self, benchmark):
history = self._get_history(benchmark)
return json.dumps(
bokeh.embed.json_item(
time_series_plot(history, benchmark["id"]),
"plot-history",
if history:
return json.dumps(
bokeh.embed.json_item(
time_series_plot(history, benchmark["id"]),
"plot-history",
)
)
)
return None

def _get_history(self, benchmark):
response = self.api_get("api.history", benchmark_id=benchmark["id"])
Expand Down
2 changes: 1 addition & 1 deletion conbench/app/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def page(self, benchmark, run, form):
run=run,
form=form,
resources=bokeh.resources.CDN.render(),
plot_history=self._get_history_plot(benchmark),
plot_history=self.get_history_plot(benchmark),
)

def get(self, benchmark_id):
Expand Down
2 changes: 1 addition & 1 deletion conbench/app/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def page(self, comparisons, regressions, improvements, baseline_id, contender_id
baseline = self.get_display_benchmark(baseline_id)
contender = self.get_display_benchmark(contender_id)
plot = self._get_plot(baseline, contender)
plot_history = self._get_history_plot(contender)
plot_history = self.get_history_plot(contender)
baseline_run_id = baseline["run_id"]
contender_run_id = baseline["run_id"]
compare = f"{baseline_run_id}...{contender_run_id}"
Expand Down
2 changes: 2 additions & 0 deletions conbench/templates/benchmark-entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@
$("#benchmark-form").find("#delete").attr("data-message", "<ul><li>Delete benchmark: <strong>{{ benchmark.id }}</strong></li></ul>");
});

{% if plot_history %}
$(document).ready(function() {
Bokeh.embed.embed_item({{ plot_history | safe }});
});
{% endif %}

</script>
{% endblock %}
2 changes: 2 additions & 0 deletions conbench/templates/compare-entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,11 @@
Bokeh.embed.embed_item({{ plot | safe }});
});

{% if plot_history %}
$(document).ready(function() {
Bokeh.embed.embed_item({{ plot_history | safe }});
});
{% endif %}

$(document).ready(function() {
$('#unit-tooltip').tooltip()
Expand Down

0 comments on commit 6e296c5

Please sign in to comment.