Add title and score to select page

This commit is contained in:
2023-05-28 11:56:14 +02:00
parent 83cfc3e5f5
commit be62e38e77
13 changed files with 117 additions and 113 deletions

View File

@@ -1,5 +1,6 @@
import os
import sys
import json
import subprocess
PYTHON_VERSION = "{}.{}".format(sys.version_info.major, sys.version_info.minor)

View File

@@ -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)

View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
{% if framework == "bootstrap" %}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<style>
body {
font-family: Courier;
}
#file-table tbody tr.selected td{
background-color: #0dcaf0;
color:white;
}
</style>
{% else %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<style>
body {
font-family: Courier;
}
.tag {
cursor: pointer;
}
</style>
{% endif %}
</head>
<body>
{% block content %}
{% endblock %}
</body>
{% if framework == "bootstrap" %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
crossorigin="anonymous"></script>
{% endif %}
</html>

View File

@@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<style>
body {
font-family: Courier;
}
#file-table tbody tr.selected td{
background-color: #0dcaf0;
color:white;
}
</style>
</head>
<body>
{% block content %}
{% endblock %}
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js" integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
crossorigin="anonymous"></script>
</html>

View File

@@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<style>
body {
font-family: Courier;
}
.tag {
cursor: pointer;
}
</style>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>

View File

@@ -6,8 +6,9 @@
"ordering": true,
"info": true,
"select.items": "row",
"pageLength": 25,
"columnDefs": [{
"targets": 6,
"targets": 8,
"orderable": false
}]
});

View File

@@ -1,28 +1,28 @@
{% for item in data.results %}
<tr>
<td>
{{item.dataset}}
</td>
<td class="{{ right }}">
{{'{:,}'.format(item.samples)}}
</td>
<td class="{{ right }}">
{{"%d" % item.features}}
</td>
<td class="{{ right }}">
{{"%d" % item.classes}}
</td>
<td class="{{ right }}">
{{'{:,.2f}'.format(item.nodes)}}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.time, item.time_std)}}
</td>
<td class="{{ center }}">
{{item.hyperparameters}}
</td>
</tr>
<tr>
<td>
{{item.dataset}}
</td>
<td class="{{ right }}">
{{'{:,}'.format(item.samples)}}
</td>
<td class="{{ right }}">
{{"%d" % item.features}}
</td>
<td class="{{ right }}">
{{"%d" % item.classes}}
</td>
<td class="{{ right }}">
{{'{:,.2f}'.format(item.nodes)}}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.score, item.score_std)}} {{ item.symbol|safe }}
</td>
<td class="{{ right }}">
{{"%.6f±%.4f" % (item.time, item.time_std)}}
</td>
<td class="{{ center }}">
{{item.hyperparameters}}
</td>
</tr>
{% endfor %}

View File

@@ -78,6 +78,7 @@
<h7><b>
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
</b></h7>
<h7>Number of files: {{ data.results | length }}</h7>
</div>
</section>
</div>

View File

@@ -84,6 +84,7 @@
<button class="delete" onclick="location.href='/index';"></button>
Total score: {{ "%.6f" % (data.results | sum(attribute="score")) }}
</b></h2>
<h2>Number of files: {{ data.results | length }}</h2>
</div>
</section>
</div>

View File

@@ -7,24 +7,28 @@
<th>Date</th>
<th>Time</th>
<th>Stratified</th>
<th>Title</th>
<th>Score</th>
<th></th>
</tr>
</thead>
<tbody>
{% for file in files %}
{% set parts = file.split('_') %}
{% set stratified = parts[6].split('.')[0] %}
<tr>
<td>{{ parts[2] }}</td>
<td>{{ parts[1] }}</td>
<td>{{ parts[3] }}</td>
<td>{{ parts[4] }}</td>
<td>{{ parts[5] }}</td>
<td>{{ 'True' if stratified =='1' else 'False' }}</td>
<td>
{{ button_pre | safe }}{{ file }}{{ button_post | safe }}
</td>
</tr>
{% for file, data in files.items() %}
{% set parts = file.split('_') %}
{% set stratified = parts[6].split('.')[0] %}
<tr>
<td>{{ parts[2] }}</td>
<td>{{ parts[1] }}</td>
<td>{{ parts[3] }}</td>
<td>{{ parts[4] }}</td>
<td>{{ parts[5] }}</td>
<td>{{ 'True' if stratified =='1' else 'False' }}</td>
<td>{{ "%s" % data["title"] }}</td>
<td>{{ "%.6f" % data["score"] }}</td>
<td>
{{ button_pre | safe }}{{ file }}{{ button_post | safe }}
</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -1,8 +1,7 @@
<div class="container">
<h1 class="{{ h1_class }}"><b>Benchmark Results</b></h1>
<button class="{{ button_class }}" onclick="location.href='/config/{{ framework }}';">Use {{ framework
<button class="{{ button_class }}" onclick="location.href='/config/{{ candidate }}';">Use {{ candidate
}}</button>
{% include "partials/table_select.html" %}
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

View File

@@ -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" %}

View File

@@ -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</button>' %}
{% 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" %}