From c55a0b29ab709baa100774236d5cb26a11ebcd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Mon, 29 May 2023 11:50:49 +0200 Subject: [PATCH] Add compare with best results in reports --- benchmark/ResultsBase.py | 6 ++++-- benchmark/scripts/be_flask.py | 7 ++++--- .../templates/partials/table_select_design.html | 13 +++++++++++-- benchmark/scripts/templates/select.html | 11 ++++++++++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/benchmark/ResultsBase.py b/benchmark/ResultsBase.py index 94add18..708f38a 100644 --- a/benchmark/ResultsBase.py +++ b/benchmark/ResultsBase.py @@ -149,9 +149,11 @@ class BaseReport(abc.ABC): class StubReport(BaseReport): - def __init__(self, file_name): - self.compare = False + def __init__(self, file_name, compare=False): + self.compare = compare super().__init__(file_name=file_name, best_file=False) + if self.compare: + self._load_best_results(self.score_name, self.data["model"]) def print_line(self, line) -> None: pass diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index e42342e..fc639b7 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -20,7 +20,9 @@ TEST = "test" def process_data(file_name, data): - report = StubReport(os.path.join(Folders.results, file_name)) + report = StubReport( + os.path.join(Folders.results, file_name), compare=app.config[COMPARE] + ) new_list = [] for result in data["results"]: symbol = report._compute_status(result["dataset"], result["score"]) @@ -116,8 +118,7 @@ def config(framework): def main(args_test=None): arguments = Arguments(prog="be_flask") - arguments.xset("model", required=False) - arguments.xset("score", required=False).xset("compare") + arguments.xset("compare") args = arguments.parse(args_test) config = EnvData().load() app.config[FRAMEWORK] = config[FRAMEWORK] diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 7d6b5fb..6c01aae 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,7 +1,16 @@

Benchmark Results

- +
+
+ +
+ {% if config.compare %} +
+ Comparing with best results +
+ {% endif %} +
{% include "partials/table_select.html" %}
\ No newline at end of file diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 107eaed..6af6750 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -9,13 +9,22 @@ onclick="showFile(\''%} {% set button_post = '\')">View' %} {% set selected = "selected" %} -{% else %} + {% set tag_class = "badge bg-primary bg-small" %} + {% set frbutton_position = "float-left" %} + {% set frtag_position = "float-right" %} + {% set level = "navbar" %} + "tag is-primary" + {% else %} {% set button_class = "button is-primary is-small" %} {% set h1_class = "title is-1 has-text-centered" %} {% set table_class = "table is-striped is-hoverable cell-border is-bordered" %} {% set button_pre = 'View' %} {% set selected = "is-selected" %} + {% set tag_class = "tag is-primary is-normal" %} + {% set frbutton_position = "level-left" %} + {% set frtag_position = "level-right" %} + {% set level = "level" %} {% endif %} {% block content %} {% include "partials/table_select_design.html" %}