From f1626daad91e5f5ee9a860a51cf4042b35414dbb Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 10 Jan 2024 20:13:44 -0500 Subject: [PATCH] Merge tune.html and test.html into workload.html Always show a network, even if it is blank due to a non NNUE engine Redirect test/tune searches where the names are swapped --- OpenBench/templatetags/mytags.py | 4 + OpenBench/views.py | 17 +-- OpenBench/workloads/view_workload.py | 50 +++++++ Templates/OpenBench/test.html | 177 ---------------------- Templates/OpenBench/tune.html | 198 ------------------------ Templates/OpenBench/workload.html | 216 +++++++++++++++++++++++++++ 6 files changed, 277 insertions(+), 385 deletions(-) create mode 100644 OpenBench/workloads/view_workload.py delete mode 100644 Templates/OpenBench/test.html delete mode 100644 Templates/OpenBench/tune.html create mode 100644 Templates/OpenBench/workload.html diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py index f2ac16f..5c04f97 100644 --- a/OpenBench/templatetags/mytags.py +++ b/OpenBench/templatetags/mytags.py @@ -260,6 +260,9 @@ def spsa_param_digest(workload): return digest +def spsa_param_digest_headers(workload): + return ['Name', 'Curr', 'Start', 'Min', 'Max', 'C', 'C_end', 'R', 'R_end'] + def spsa_original_input(workload): # Maintain the original order, if there was one @@ -366,6 +369,7 @@ def test_is_fischer(test): register.filter('spsa_param_digest', spsa_param_digest) +register.filter('spsa_param_digest_headers', spsa_param_digest_headers) register.filter('spsa_original_input', spsa_original_input) register.filter('spsa_optimal_values', spsa_optimal_values) diff --git a/OpenBench/views.py b/OpenBench/views.py index fa2c94e..d506b46 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -27,10 +27,11 @@ import django.contrib.auth import OpenBench.config import OpenBench.utils -from OpenBench.workloads.get_workload import get_workload from OpenBench.workloads.create_workload import create_workload -from OpenBench.workloads.verify_workload import verify_workload +from OpenBench.workloads.get_workload import get_workload from OpenBench.workloads.modify_workload import modify_workload +from OpenBench.workloads.verify_workload import verify_workload +from OpenBench.workloads.view_workload import view_workload from OpenBench.config import OPENBENCH_CONFIG from OpenSite.settings import PROJECT_PATH @@ -464,11 +465,9 @@ def test(request, id, action=None): # Verify that it is indeed a Test and not a Tune if test.test_mode != 'SPRT' and test.test_mode != 'GAMES': - return redirect(request, '/index/', error='You are trying to view a Tune not Test') + return redirect(request, '/tune/%d' % (id)) - # Package everything up and display the test - data = { 'test' : test, 'results': Result.objects.filter(test=test) } - return render(request, 'test.html', data) + return view_workload(request, test, 'TEST') def tune(request, id, action=None): @@ -482,11 +481,9 @@ def tune(request, id, action=None): # Verify that it is indeed a Tune and not a Test if tune.test_mode == 'SPRT' or tune.test_mode == 'GAMES': - return redirect(request, '/index/', error='You are trying to view a Test not Tune') + return redirect(request, '/test/%d' % (id)) - # Package everything up and display the Tune - data = { 'test' : tune, 'results': Result.objects.filter(test=tune) } - return render(request, 'tune.html', data) + return view_workload(request, tune, 'TUNE') def create_test(request): return create_workload(request, 'TEST') diff --git a/OpenBench/workloads/view_workload.py b/OpenBench/workloads/view_workload.py new file mode 100644 index 0000000..f17ce32 --- /dev/null +++ b/OpenBench/workloads/view_workload.py @@ -0,0 +1,50 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# OpenBench is a chess engine testing framework authored by Andrew Grant. # +# # +# # +# OpenBench is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# OpenBench is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +# Module serves a singular purpose, to invoke: +# >>> view_workload(request, workload, type) +# +# A Workload can be a "TEST", which is an SPRT, or FIXED type. +# A Workload can be a "TUNE", which is an SPSA tuning session + +import OpenBench.views + +from OpenBench.models import * + +def view_workload(request, workload, workload_type): + + assert workload_type in [ 'TEST', 'TUNE' ] + + data = { + 'workload' : workload, + 'results' : Result.objects.filter(test=workload) + } + + if workload_type == 'TEST': + data['type'] = workload_type + data['dev_text'] = 'Dev' + data['submit_endpoint'] = '/newTest/' + + if workload_type == 'TUNE': + data['type'] = workload_type + data['dev_text'] = '' + data['submit_endpoint'] = '/newTune/' + + return OpenBench.views.render(request, 'workload.html', data) diff --git a/Templates/OpenBench/test.html b/Templates/OpenBench/test.html deleted file mode 100644 index d33506d..0000000 --- a/Templates/OpenBench/test.html +++ /dev/null @@ -1,177 +0,0 @@ -{% extends "OpenBench/base.html" %} - -{% load mytags %} -{% load static %} - -{% block style %} -{% endblock %} - -{% block scripts %} - -{% endblock %} - -{% block content %} - -
- - - - - - - - - {% if test.dev_network %} - - - - {% endif %} - - - - - - - - {% if test.base_network %} - - - - {% endif %} - - - - - - - - -
Author{{test.author|capfirst}}
Creation{{test.creation|date:'U'}}
Dev Engine{{test.dev_engine}}
Dev Source{{test.dev_repo}}
Dev Sha{{test.dev.sha}}
Dev Branch{{test.dev.name|prettyName}}
Dev Bench{{test.dev.bench}}
Dev Network{{test.dev_netname}}
Dev Options{{test.dev_options}}
Dev Time{{test.dev_time_control}}
Base Engine{{test.base_engine}}
Base Source{{test.base_repo}}
Base Sha{{test.base.sha}}
Base Branch{{test.base.name|prettyName}}
Base Bench{{test.base.bench}}
Base Network{{test.base_netname}}
Base Options{{test.base_options}}
Base Time{{test.base_time_control}}
Opening Book{{test.book_name}}
Upload PGNs{{test.upload_pgns}}
Syzygy WDL{{test.syzygy_wdl}}
Syzygy ADJ.{{test.syzygy_adj}}
Win ADJ.{{test.win_adj}}
Draw ADJ.{{test.draw_adj}}
-
- -
- - -

{{test|git_diff_text}}

- -
- - {% if not test.approved and profile.approver and profile.user.username != test.author %} - Approve - {% elif not test.approved and request.user.is_superuser %} - Approve - {% else %} - Approve - {% endif %} - - - {% if test.finished and profile.approver %} - Restart - {% elif test.finished and profile.user.username == test.author %} - Restart - {% elif test.finished %} - Restart - {% endif %} - - - {% if not test.finished and profile.approver %} - Stop - {% elif not test.finished and profile.user.username == test.author %} - Stop - {% elif not test.finished %} - Stop - {% endif %} - - - {% if profile.approver or profile.user.username == test.author %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% else %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% endif %} -
- - - - {% if test.upload_pgns != 'FALSE' %} - - {% endif %} - - -
{{test|longStatBlock|linebreaksbr}}
- - -
- {% csrf_token %} -
-
-
- -
-
- -
-
- -
- - {% if profile.approver or profile.user.username == test.author %} - - {% else %} - - {% endif %} -
-
-
-
- -
- - - - - - - - - - - - - - {% for result in results %} - - - - - - - - - - - - {% endfor %} - -
#UserUpdatedGamesWonLostDrawnTimeCrash
{{result.machine.id}}{{result.machine.user.username|capfirst}}{{result.updated|date:'U'}}{{result.games}}{{result.wins}}{{result.losses}}{{result.draws}}{{result.timeloss}}{{result.crashes}}
- -
- -{% endblock %} diff --git a/Templates/OpenBench/tune.html b/Templates/OpenBench/tune.html deleted file mode 100644 index a47655e..0000000 --- a/Templates/OpenBench/tune.html +++ /dev/null @@ -1,198 +0,0 @@ -{% extends "OpenBench/base.html" %} - -{% load mytags %} -{% load static %} - -{% block style %} -{% endblock %} - -{% block scripts %} - -{% endblock %} - -{% block content %} - -
- - - - - - - - - {% if test.dev_network %} - - - - - {% endif %} - - - - - - - - - - - - - -
Author{{test.author|capfirst}}
Creation{{test.creation|date:'U'}}
Engine{{test.dev_engine}}
Source{{test.dev_repo}}
Sha{{test.dev.sha}}
Branch{{test.dev.name|prettyName}}
Bench{{test.dev.bench}}
Network{{test.dev_netname}}
Options{{test.dev_options}}
Time{{test.dev_time_control}}
Opening Book{{test.book_name}}
Syzygy WDL{{test.syzygy_wdl}}
Syzygy ADJ.{{test.syzygy_adj}}
Win ADJ.{{test.win_adj}}
Draw ADJ.{{test.draw_adj}}
Alpha{{test.spsa.Alpha}}
Gamma{{test.spsa.Gamma}}
A-Ratio{{test.spsa.A_ratio}}
Reporting{{test.spsa.reporting_type}}
Distribution{{test.spsa.distribution_type}}
Pairs Per Point{{test.workload_size}}
-
- -
- - -

{{test|workload_pretty_name}}

- -
- - {% if not test.approved and profile.approver and profile.user.username != test.author %} - Approve - {% elif not test.approved and request.user.is_superuser %} - Approve - {% else %} - Approve - {% endif %} - - - {% if test.finished and profile.approver %} - Restart - {% elif test.finished and profile.user.username == test.author %} - Restart - {% elif test.finished %} - Restart - {% endif %} - - - {% if not test.finished and profile.approver %} - Stop - {% elif not test.finished and profile.user.username == test.author %} - Stop - {% elif not test.finished %} - Stop - {% endif %} - - - {% if profile.approver or profile.user.username == test.author %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% else %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% endif %} -
- -
- - - - Copy SPSA Inputs - -
- -
- - - - Copy SPSA Outputs - -
- - - -
{{test|shortStatBlock|linebreaksbr}}
- - -
- {% csrf_token %} -
-
-
- - -
-
- - -
- - - {% if profile.approver or profile.user.username == test.author %} - - {% else %} - - {% endif %} -
-
-
-
- -
- - - - - - - - - - - - - - {% for row in test|spsa_param_digest %} - - {% for element in row %} - {% if not forloop.first %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} -
Name Curr Start Min Max C C_end R R_end
{{ element }} {{ element }}
-
- -
- - - - - - - - - - - - - - {% for result in results %} - - - - - - - - - - - - {% endfor %} -
#UserUpdatedGamesWonLostDrawnTimeCrash
{{result.machine.id}}{{result.machine.user.username|capfirst}}{{result.updated|date:'U'}}{{result.games}}{{result.wins}}{{result.losses}}{{result.draws}}{{result.timeloss}}{{result.crashes}}
-
- -{% endblock %} diff --git a/Templates/OpenBench/workload.html b/Templates/OpenBench/workload.html new file mode 100644 index 0000000..392f674 --- /dev/null +++ b/Templates/OpenBench/workload.html @@ -0,0 +1,216 @@ +{% extends "OpenBench/base.html" %} + +{% load mytags %} +{% load static %} + +{% block scripts %} + +{% endblock %} + +{% block content %} + +
+ + + + + + + + + + + + + + + + + {% if type == "TEST" %} + + + + + + + + + {% endif %} + + + + + + + +
Author{{workload.author|capfirst}}
Creation{{workload.creation|date:'U'}}
{{dev_text}} Engine{{workload.dev_engine}}
{{dev_text}} Source{{workload.dev_repo}}
{{dev_text}} Sha{{workload.dev.sha}}
{{dev_text}} Branch{{workload.dev.name|prettyName}}
{{dev_text}} Bench{{workload.dev.bench}}
{{dev_text}} Network{{workload.dev_netname}}
{{dev_text}} Options{{workload.dev_options}}
{{dev_text}} Time{{workload.dev_time_control}}
Base Engine{{workload.base_engine}}
Base Source{{workload.base_repo}}
Base Sha{{workload.base.sha}}
Base Branch{{workload.base.name|prettyName}}
Base Bench{{workload.base.bench}}
Base Network{{workload.base_netname}}
Base Options{{workload.base_options}}
Base Time{{workload.base_time_control}}
Opening Book{{workload.book_name}}
Upload PGNs{{workload.upload_pgns}}
Syzygy WDL{{workload.syzygy_wdl}}
Syzygy ADJ.{{workload.syzygy_adj}}
Win ADJ.{{workload.win_adj}}
Draw ADJ.{{workload.draw_adj}}
+
+ +
+ + +

{{workload|git_diff_text}}

+ +
+ + + {% if not workload.approved and profile.approver and profile.user.username != workload.author %} + Approve + {% elif not workload.approved and request.user.is_superuser %} + Approve + {% else %} + Approve + {% endif %} + + + {% if workload.finished and profile.approver %} + Restart + {% elif workload.finished and profile.user.username == workload.author %} + Restart + {% elif workload.finished %} + Restart + {% endif %} + + + {% if not workload.finished and profile.approver %} + Stop + {% elif not workload.finished and profile.user.username == workload.author %} + Stop + {% elif not workload.finished %} + Stop + {% endif %} + + + {% if profile.approver or profile.user.username == workload.author %} + {% if workload.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% else %} + {% if workload.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% endif %} +
+ + + {% if type == "TEST" %} + + {% endif %} + + + {% if workload.upload_pgns != "FALSE" %} + + {% endif %} + + + {% if type == "TUNE" %} +
+ + Copy SPSA Inputs +
+ {% endif %} + + + {% if type == "TUNE" %} +
+ + Copy SPSA Outputs +
+ {% endif %} + + + {% if type == "TEST" %} +
{{workload|longStatBlock|linebreaksbr}}
+ {% elif type == "TUNE" %} +
{{workload|shortStatBlock|linebreaksbr}}
+ {% endif %} + + +
+ {% csrf_token %} +
+
+ +
+
+ + {% if type == "TEST" %} +
+ {% endif %} + + + {% if profile.approver or profile.user.username == workload.author %} + + {% else %} + + {% endif %} +
+
+
+
+ + + {% if type == "TUNE" %} +
+ + + + {% for header in workload|spsa_param_digest_headers %} + + {% endfor %} + + + {% for row in workload|spsa_param_digest %} + + {% for element in row %} + {% if not forloop.first %} + + {% else %} + + {% endif %} + {% endfor %} + + {% endfor %} +
{{ header }}
{{ element }} {{ element }}
+
+ {% endif %} + +
+ + + + + + + + + + + + + + {% for result in results %} + + + + + + + + + + + + {% endfor %} +
#UserUpdatedGamesWonLostDrawnTimeCrash
{{result.machine.id}}{{result.machine.user.username|capfirst}}{{result.updated|date:'U'}}{{result.games}}{{result.wins}}{{result.losses}}{{result.draws}}{{result.timeloss}}{{result.crashes}}
+
+ +{% endblock %}