mirror of
https://github.com/Doctorado-ML/beflask.git
synced 2025-08-19 00:55:52 +00:00
Begin adding sockets
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SubmitField, SelectField
|
||||
from benchmark.Arguments import ALL_METRICS
|
||||
|
||||
|
||||
class RankingForm(FlaskForm):
|
||||
score = SelectField("Score", choices=ALL_METRICS)
|
||||
submit = SubmitField("Generate Ranking")
|
@@ -1,18 +1,16 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import xlsxwriter
|
||||
from benchmark.Datasets import Datasets
|
||||
from benchmark.ResultsBase import StubReport
|
||||
from benchmark.ResultsFiles import Benchmark, Excel, ReportDatasets
|
||||
from benchmark.ResultsFiles import Excel, ReportDatasets
|
||||
from benchmark.Utils import Files, Folders
|
||||
from dotenv import dotenv_values
|
||||
from flask import (
|
||||
Blueprint,
|
||||
current_app,
|
||||
redirect,
|
||||
render_template,
|
||||
request,
|
||||
send_file,
|
||||
@@ -20,8 +18,6 @@ from flask import (
|
||||
)
|
||||
from flask_login import current_user, login_required
|
||||
|
||||
from .forms import RankingForm
|
||||
|
||||
results = Blueprint("results", __name__, template_folder="templates")
|
||||
|
||||
|
||||
@@ -235,32 +231,3 @@ def dataset_report(dataset):
|
||||
results=results,
|
||||
app_config=app_config,
|
||||
)
|
||||
|
||||
|
||||
@results.route("/ranking", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def ranking():
|
||||
os.chdir(current_user.benchmark.folder)
|
||||
form = RankingForm()
|
||||
if form.validate_on_submit():
|
||||
benchmark = Benchmark(score=form.score.data, visualize=False)
|
||||
try:
|
||||
benchmark.compile_results()
|
||||
benchmark.save_results()
|
||||
benchmark.report(tex_output=False)
|
||||
benchmark.exreport()
|
||||
benchmark.excel()
|
||||
except ValueError as e:
|
||||
return render_template(
|
||||
"error.html", message="Couldn't generate ranking", error=str(e)
|
||||
)
|
||||
except KeyError as e:
|
||||
return render_template(
|
||||
"error.html",
|
||||
message="Couldn't generate ranking. It seems that there are "
|
||||
"partial results for some classifiers",
|
||||
error=f"Key not found {str(e)}",
|
||||
)
|
||||
file_name = Path(benchmark.get_excel_file_name()).name
|
||||
return redirect(url_for("results.download", file_name=file_name))
|
||||
return render_template("ranking.html", form=form)
|
||||
|
@@ -1,13 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% from 'bootstrap5/form.html' import render_form %}
|
||||
{% block content %}
|
||||
<div class="alert alert-{{ alert_type }} col-md-4" role="alert">
|
||||
<h4 class="alert-heading">{{ title }}</h4>
|
||||
<button class="btn btn-primary"
|
||||
onclick="window.location.href='{{ url_for("main.index") }}'">Back</button>
|
||||
<div class="row">
|
||||
<div>{{ render_form(form) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
```
|
Reference in New Issue
Block a user