Add format to report_best

This commit is contained in:
2023-06-01 01:11:06 +02:00
parent a51fed6281
commit f7ed11562b
5 changed files with 77 additions and 27 deletions

View File

@@ -183,4 +183,9 @@ def best_results(file, compare):
data = json.load(f) data = json.load(f)
except Exception as e: except Exception as e:
return render_template("error.html", message=str(e), compare=compare) return render_template("error.html", message=str(e), compare=compare)
return render_template("report_best.html", data=data, compare=compare) return render_template(
"report_best.html",
data=data,
compare=compare,
framework=current_app.config[FRAMEWORK],
)

View File

@@ -1,5 +1,8 @@
{%- macro header(title) -%} {%- macro header(title, close=False, url="") -%}
<div class="p-4 bg-primary text-white"> <div class="p-4 bg-primary text-white">
{%- if close -%}
<button type="button" class="btn-close" aria-label="Close" onclick="location.href = '{{url}}'"></button>
{%- endif -%}
<h1 class="alternate-font">{{ title }}</h1> <h1 class="alternate-font">{{ title }}</h1>
</div> </div>
{%- endmacro -%} {%- endmacro -%}
@@ -44,4 +47,10 @@ float-left
{%- endmacro -%} {%- endmacro -%}
{%- macro get_right_position() -%} {%- macro get_right_position() -%}
float-right float-right
{%- endmacro -%}
{%- macro get_row_head_class() -%}
bg-primary text-white
{%- endmacro -%}
{%- macro get_align_center() -%}
text-center
{%- endmacro -%} {%- endmacro -%}

View File

@@ -1,6 +1,9 @@
{%- macro header(title) -%} {%- macro header(title, close=False, url="") -%}
<div class="hero is-info is-bold"> <div class="hero is-info is-bold">
<div class="hero-body"> <div class="hero-body">
{%- if close -%}
<button class="delete is-large" onclick="location.href = '{{ url }}'"></button>
{%- endif -%}
<h1 class="is-size-3 alternate-font">{{ title }}</h1> <h1 class="is-size-3 alternate-font">{{ title }}</h1>
</div> </div>
</div> </div>
@@ -38,9 +41,18 @@ level
{%- macro get_align_right() -%} {%- macro get_align_right() -%}
has-text-right has-text-right
{%- endmacro -%} {%- endmacro -%}
{%- macro get_align_center() -%}
has-text-center
{%- endmacro -%}
{%- macro get_left_position() -%} {%- macro get_left_position() -%}
float-left float-left
{%- endmacro -%} {%- endmacro -%}
{%- macro get_right_position() -%} {%- macro get_right_position() -%}
float-right float-right
{%- endmacro -%}
{%- macro get_row_head_class() -%}
is-selected
{%- endmacro -%}
{%- macro get_align_center() -%}
has-text-center
{%- endmacro -%} {%- endmacro -%}

View File

@@ -26,7 +26,7 @@
<td>{{ "%s" % data["title"] }}</td> <td>{{ "%s" % data["title"] }}</td>
<td class="{{ select.get_align_right() }}">{{ "%.6f" % data["score"] }}</td> <td class="{{ select.get_align_right() }}">{{ "%.6f" % data["score"] }}</td>
<td> <td>
{{ select.get_button_tag("eye", "showFile('" ~ file ~ "')") | safe }} {{ select.get_button_tag("table-eye", "showFile('" ~ file ~ "')") | safe }}
{% set file_best = "best_results_" ~ parts[1] ~ "_" ~ parts[2] ~ ".json" %} {% set file_best = "best_results_" ~ parts[1] ~ "_" ~ parts[2] ~ ".json" %}
{{ select.get_button_tag("star-circle-outline", "redirectDouble('best_results', '" ~ file_best ~ "')", visible=False, name="best_buttons") | safe }} {{ select.get_button_tag("star-circle-outline", "redirectDouble('best_results', '" ~ file_best ~ "')", visible=False, name="best_buttons") | safe }}
<input <input

View File

@@ -1,23 +1,47 @@
<table class="table"> {% set title = "Best Results" %}
<thead> {% extends "base_" ~ framework ~ ".html" %}
<tr> {% import "partials/cfg_select_" ~ framework ~ ".jinja" as select %}
<th>Dataset</th> {% block content %}
<th>Score</th> {{ select.header(title, True, url_for("main.index", compare=compare)) }}
<th>Hyperparameters</th> <container class="{{select.get_container_class() }}">
<th>File</th> <table id="file-table" class="{{ select.get_table_class() }}">
</tr> <thead>
</thead> <tr class="{{ select.get_row_head_class() }}">
<tbody> <th class="{{ select.get_align_center() }}">Dataset</th>
{% for dataset, info in data.items() %} <th class="{{ select.get_align_center() }}">Score</th>
<tr> <th class="{{ select.get_align_center() }}">Hyperparameters</th>
<td>{{ dataset }}</td> <th class="{{ select.get_align_center() }}">File</th>
<td>{{ '%9.7f' % info[0] }}</td> </tr>
<td>{{ info[1] }}</td> </thead>
<td> <tbody>
{% set url = url_for(request.endpoint, **request.view_args)|urlencode %} {% for dataset, info in data.items() %}
<a href="{{ url_for('main.showfile', file_name = info[2], compare = compare) }}?url={{ url }}">{{ info[2] }}</a> <tr>
</td> <td>{{ dataset }}</td>
</tr> <td class="{{ select.get_align_right() }}">{{ '%9.7f' % info[0] }}</td>
{% endfor %} <td class="{{ select.get_align_center() }}">{{ info[1] }}</td>
</tbody> <td>
</table> {% set url = url_for(request.endpoint, **request.view_args)|urlencode %}
<a href="{{ url_for('main.showfile', file_name = info[2], compare = compare) }}?url={{ url }}">{{ info[2] }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</container>
{% endblock %}
{% block jscript %}
<script>
$(document).ready(function () {
// Check if row is selected
$('#file-table tbody').on('click', 'tr', function () {
if ($(this).hasClass('{{ select.selected() }}')) {
$(this).removeClass('{{ select.selected() }}');
} else {
$('#file-table tbody tr.{{ select.selected() }}').removeClass("{{ select.selected() }}")
$(this).addClass('{{ select.selected() }}');
}
});
});
</script>
{% endblock %}