diff --git a/benchmark/Utils.py b/benchmark/Utils.py index 229b187..33941de 100644 --- a/benchmark/Utils.py +++ b/benchmark/Utils.py @@ -1,5 +1,6 @@ import os import sys +import json import subprocess PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor) diff --git a/benchmark/scripts/be_flask.py b/benchmark/scripts/be_flask.py index 56ba6c9..95774f8 100755 --- a/benchmark/scripts/be_flask.py +++ b/benchmark/scripts/be_flask.py @@ -2,7 +2,7 @@ import os import json import webbrowser -from benchmark.Utils import Files, Folders, Symbols +from benchmark.Utils import Files, Folders from benchmark.Arguments import Arguments, EnvData from benchmark.ResultsBase import StubReport from flask import Flask @@ -13,7 +13,6 @@ from flask import render_template, request, redirect, url_for app = Flask(__name__) FRAMEWORK = "framework" FRAMEWORKS = "frameworks" -HIDDEN = "hidden" def process_data(file_name, data): @@ -35,14 +34,23 @@ def process_data(file_name, data): @app.route("/") def index(): # Get a list of files in a directory - files = Files.get_all_results(hidden=app.config[HIDDEN]) + files = {} + names = Files.get_all_results(hidden=False) + for name in names: + report = StubReport(os.path.join(Folders.results, name)) + report.report() + files[name] = { + "duration": report.duration, + "score": report.score, + "title": report.title, + } candidate = app.config[FRAMEWORKS].copy() candidate.remove(app.config[FRAMEWORK]) return render_template( - f"select.html", + "select.html", files=files, - framework=candidate[0], - used_framework=app.config[FRAMEWORK], + candidate=candidate[0], + framework=app.config[FRAMEWORK], ) @@ -53,10 +61,10 @@ def show(): data = json.load(f) summary = process_data(selected_file, data) return render_template( - f"report.html", + "report.html", data=data, summary=summary, - used_framework=app.config[FRAMEWORK], + framework=app.config[FRAMEWORK], ) @@ -74,13 +82,13 @@ 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").xset("hidden") - arguments.xset("nan") - args = arguments.parse(args_test) - app.config[FRAMEWORK] = EnvData().load()[FRAMEWORK] - app.config[HIDDEN] = args.hidden + # arguments = Arguments(prog="be_flask") + # arguments.xset("model", required=False) + # arguments.xset("score", required=False).xset("compare") + # arguments.xset("nan") + # args = arguments.parse(args_test) + config = EnvData().load() + app.config[FRAMEWORK] = config[FRAMEWORK] app.config[FRAMEWORKS] = ["bootstrap", "bulma"] webbrowser.open_new("http://127.0.0.1:1234/") app.run(port=1234) diff --git a/benchmark/scripts/templates/base.html b/benchmark/scripts/templates/base.html new file mode 100644 index 0000000..44c7aca --- /dev/null +++ b/benchmark/scripts/templates/base.html @@ -0,0 +1,40 @@ + + + + {{ title }} + {% if framework == "bootstrap" %} + + + + {% else %} + + + + {% endif %} + + + {% block content %} + {% endblock %} + + {% if framework == "bootstrap" %} + + {% endif %} + \ No newline at end of file diff --git a/benchmark/scripts/templates/base_bootstrap.html b/benchmark/scripts/templates/base_bootstrap.html deleted file mode 100644 index cd6a841..0000000 --- a/benchmark/scripts/templates/base_bootstrap.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - {{ title }} - - - - - - - {% block content %} - {% endblock %} - - - diff --git a/benchmark/scripts/templates/base_bulma.html b/benchmark/scripts/templates/base_bulma.html deleted file mode 100644 index 927ea63..0000000 --- a/benchmark/scripts/templates/base_bulma.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - {{ title }} - - - - - - {% block content %} - {% endblock %} - - diff --git a/benchmark/scripts/templates/partials/js_select.html b/benchmark/scripts/templates/partials/js_select.html index 4a76c38..96bb38a 100644 --- a/benchmark/scripts/templates/partials/js_select.html +++ b/benchmark/scripts/templates/partials/js_select.html @@ -6,8 +6,9 @@ "ordering": true, "info": true, "select.items": "row", + "pageLength": 25, "columnDefs": [{ - "targets": 6, + "targets": 8, "orderable": false }] }); diff --git a/benchmark/scripts/templates/partials/table_report.html b/benchmark/scripts/templates/partials/table_report.html index fa03681..47855d9 100644 --- a/benchmark/scripts/templates/partials/table_report.html +++ b/benchmark/scripts/templates/partials/table_report.html @@ -1,28 +1,28 @@ {% for item in data.results %} - - - {{item.dataset}} - - - {{'{:,}'.format(item.samples)}} - - - {{"%d" % item.features}} - - - {{"%d" % item.classes}} - - - {{'{:,.2f}'.format(item.nodes)}} - - - {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} - - - {{"%.6f±%.4f" % (item.time, item.time_std)}} - - - {{item.hyperparameters}} - - + + + {{item.dataset}} + + + {{'{:,}'.format(item.samples)}} + + + {{"%d" % item.features}} + + + {{"%d" % item.classes}} + + + {{'{:,.2f}'.format(item.nodes)}} + + + {{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }} + + + {{"%.6f±%.4f" % (item.time, item.time_std)}} + + + {{item.hyperparameters}} + + {% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bootstrap.html b/benchmark/scripts/templates/partials/table_report_bootstrap.html index 20f56da..b3672b8 100644 --- a/benchmark/scripts/templates/partials/table_report_bootstrap.html +++ b/benchmark/scripts/templates/partials/table_report_bootstrap.html @@ -78,6 +78,7 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} + Number of files: {{ data.results | length }} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_report_bulma.html b/benchmark/scripts/templates/partials/table_report_bulma.html index ea5d400..371fa65 100644 --- a/benchmark/scripts/templates/partials/table_report_bulma.html +++ b/benchmark/scripts/templates/partials/table_report_bulma.html @@ -84,6 +84,7 @@ Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }} +

Number of files: {{ data.results | length }}

\ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select.html b/benchmark/scripts/templates/partials/table_select.html index d217c0f..a313e49 100644 --- a/benchmark/scripts/templates/partials/table_select.html +++ b/benchmark/scripts/templates/partials/table_select.html @@ -7,24 +7,28 @@ Date Time Stratified + Title + Score - {% for file in files %} - {% set parts = file.split('_') %} - {% set stratified = parts[6].split('.')[0] %} - - {{ parts[2] }} - {{ parts[1] }} - {{ parts[3] }} - {{ parts[4] }} - {{ parts[5] }} - {{ 'True' if stratified =='1' else 'False' }} - - {{ button_pre | safe }}{{ file }}{{ button_post | safe }} - - + {% for file, data in files.items() %} + {% set parts = file.split('_') %} + {% set stratified = parts[6].split('.')[0] %} + + {{ parts[2] }} + {{ parts[1] }} + {{ parts[3] }} + {{ parts[4] }} + {{ parts[5] }} + {{ 'True' if stratified =='1' else 'False' }} + {{ "%s" % data["title"] }} + {{ "%.6f" % data["score"] }} + + {{ button_pre | safe }}{{ file }}{{ button_post | safe }} + + {% endfor %} \ No newline at end of file diff --git a/benchmark/scripts/templates/partials/table_select_design.html b/benchmark/scripts/templates/partials/table_select_design.html index 5c1589a..7c88002 100644 --- a/benchmark/scripts/templates/partials/table_select_design.html +++ b/benchmark/scripts/templates/partials/table_select_design.html @@ -1,8 +1,7 @@

Benchmark Results

- - {% include "partials/table_select.html" %}
diff --git a/benchmark/scripts/templates/report.html b/benchmark/scripts/templates/report.html index ce91983..23f47e8 100644 --- a/benchmark/scripts/templates/report.html +++ b/benchmark/scripts/templates/report.html @@ -1,11 +1,7 @@ {% set title = "Report Viewer" %} -{% if used_framework == "bootstrap" %} - {% extends "base_bootstrap.html" %} -{% else %} - {% extends "base_bulma.html" %} -{% endif%} +{% extends "base.html" %} {% block content%} - {% if used_framework == "bootstrap" %} + {% if framework == "bootstrap" %} {% set center = "text-center" %} {% set right = "text-end" %} {% include "partials/table_report_bootstrap.html" %} diff --git a/benchmark/scripts/templates/select.html b/benchmark/scripts/templates/select.html index 7ab074c..74cfdb5 100644 --- a/benchmark/scripts/templates/select.html +++ b/benchmark/scripts/templates/select.html @@ -1,6 +1,6 @@ {% set title = "Benchmark Results" %} -{% if used_framework == "bootstrap" %} - {% extends "base_bootstrap.html" %} +{% extends "base.html" %} +{% if framework == "bootstrap" %} {% set button_class = "btn btn-primary bt-sm" %} {% set h1_class = "text-center" %} {% set table_class = "table table-striped table-hover" %} @@ -9,7 +9,6 @@ onclick="showFile(\''%} {% set button_post = '\')">View' %} {% else %} - {% extends "base_bulma.html" %} {% 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" %}