From 9c488fb521699f523cd979252134380e9f286605 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Mon, 17 Feb 2020 05:58:40 -0500 Subject: [PATCH] Partial work cleaning up front & backends --- Client/Client.py | 20 +++ OpenBench/admin.py | 35 +++-- OpenBench/apps.py | 24 +++- OpenBench/config.py | 208 +++++++++++++++--------------- OpenBench/models.py | 20 +++ OpenBench/static/style.css | 123 +++++++----------- OpenBench/tests.py | 3 - OpenBench/urls.py | 86 +++++++----- OpenBench/utils.py | 28 +++- OpenBench/views.py | 127 +++++++++++------- Templates/OpenBench/base.html | 4 +- Templates/OpenBench/eventLog.html | 12 +- Templates/OpenBench/index.html | 26 ++-- Templates/OpenBench/machines.html | 14 +- Templates/OpenBench/newTest.html | 4 +- Templates/OpenBench/users.html | 36 +++--- Templates/OpenBench/viewTest.html | 62 ++++----- 17 files changed, 483 insertions(+), 349 deletions(-) delete mode 100644 OpenBench/tests.py diff --git a/Client/Client.py b/Client/Client.py index 402659b..616196d 100644 --- a/Client/Client.py +++ b/Client/Client.py @@ -1,3 +1,23 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + from __future__ import print_function import argparse, ast, hashlib, json, math, multiprocessing, os diff --git a/OpenBench/admin.py b/OpenBench/admin.py index 006b5f7..9b1333e 100644 --- a/OpenBench/admin.py +++ b/OpenBench/admin.py @@ -1,9 +1,28 @@ -from django.contrib import admin -from OpenBench.models import LogEvent, Engine, Profile, Machine, Result, Test +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -admin.site.register(LogEvent) -admin.site.register(Engine) -admin.site.register(Profile) -admin.site.register(Machine) -admin.site.register(Result) -admin.site.register(Test) +import django.contrib, OpenBench.models + +django.contrib.admin.site.register(OpenBench.models.Engine) +django.contrib.admin.site.register(OpenBench.models.Profile) +django.contrib.admin.site.register(OpenBench.models.Machine) +django.contrib.admin.site.register(OpenBench.models.Result) +django.contrib.admin.site.register(OpenBench.models.Test) +django.contrib.admin.site.register(OpenBench.models.LogEvent) diff --git a/OpenBench/apps.py b/OpenBench/apps.py index 9d792a8..c9b5743 100644 --- a/OpenBench/apps.py +++ b/OpenBench/apps.py @@ -1,4 +1,24 @@ -from django.apps import AppConfig +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -class OpenbenchConfig(AppConfig): +import django.apps + +class OpenbenchConfig(django.apps.AppConfig): name = 'OpenBench' diff --git a/OpenBench/config.py b/OpenBench/config.py index 5e3484b..d2c5656 100644 --- a/OpenBench/config.py +++ b/OpenBench/config.py @@ -1,122 +1,124 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# Workers will use FRAMEWORK_REPO_URL to determine the location -# for the Cutechess binary and DLLs, as well as any of the books -# which are being used in the testing framework. The main OpenBench -# repo should suffice, but new books require this to be redirected. -FRAMEWORK_REPO_URL = 'http://github.com/AndyGrant/OpenBench/' +OPENBENCH_CONFIG = { -FRAMEWORK_DEFAULTS = { + # Sidebar link, location of resources, and contact information + 'framework' : 'http://github.com/AndyGrant/OpenBench/', + 'corefiles' : 'http://github.com/AndyGrant/OpenBench/raw/master/CoreFiles/', + 'serveradmin' : 'andrew@grantnet.us', - 'config' : { + # SPRT Elo bounds and type I/II errors + 'sprt' : { 'elolower' : 0.00, 'eloupper' : 5.00, 'alpha' : 0.05, 'beta' : 0.05 }, - # Controls the Link on the sidebar - 'framework' : FRAMEWORK_REPO_URL, - # Email of OpenBench instance owner - 'serveradmin' : 'andrew@grantnet.us', + # Book confgiruation. When addding a book, follow the provided template. + # The SHA is defined by hashlib.sha256(book).hexdigest(). OpenBench.py + # (Client File) has an example to show you how to find a hash digest - # SPRT Elo bounds and type I/II errors - 'sprt' : { - 'elolower' : 0.00, 'eloupper' : 5.00, - 'alpha' : 0.05, 'beta' : 0.05, + 'books' : { + + '2moves_v1.pgn' : { + 'sha' : '46aed7f2696618b2b914942032957b7a97a8f343bf54ba83e20a47818f0d42e0', + 'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/2moves_v1.pgn', + 'default' : True, }, - # Engine Configuration. All engines must have a name, a source repo, - # a set of paramaters for each standard test type, as well as a scaled - # NPS value, which is used to normalize speed across all workers. + '8moves_v3.pgn' : { + 'sha' : '04fcce1488a94f3b7795cef6f74d89016eb278328897c1018e6162c5967273f5', + 'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/8moves_v3.pgn', + 'default' : False, + }, - 'engines' : { - 'Ethereal' : { - 'proto' : 'uci', - 'nps' : 1275000, - 'name' : 'Ethereal', - 'source' : 'https://github.com/AndyGrant/Ethereal', - 'testmodes' : { - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, - }, - }, + '3moves_FRC.pgn' : { + 'sha' : '4c801140e3a52d3a306cb226ccd6225c47789409c5f2d0e1d7cf86152ea1f973', + 'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/3moves_FRC.pgn', + 'default' : False, + }, + }, - 'Laser' : { - 'proto' : 'uci', - 'nps' : 710000, - 'name' : 'Laser', - 'source' : 'https://github.com/jeffreyan11/uci-chess-engine', - 'testmodes' : { - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, - }, - }, - 'Weiss' : { - 'proto' : 'uci', - 'nps' : 2675000, - 'name' : 'Weiss', - 'source' : 'https://github.com/TerjeKir/weiss', - 'testmodes' : { - 'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' }, - }, - }, + # Engine Configuration. All engines must have a name, a source repo, + # a set of paramaters for each standard test type, as well as a scaled + # NPS value, which is used to normalize speed across all workers. - 'Demolito' : { - 'proto' : 'uci', - 'nps' : 1250000, - 'name' : 'Demolito', - 'source' : 'https://github.com/lucasart/Demolito', - 'testmodes' : { - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '8.0+0.08' }, - 'ltc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '32.0+0.32'}, - 'smpstc' : { 'threads' : 8, 'hash' : 32, 'timecontrol' : '4.0+0.04' }, - 'smpltc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '16.0+0.16'}, - }, - }, + 'engines' : { - 'RubiChess' : { - 'proto' : 'uci', - 'nps' : 1000000, - 'name' : 'RubiChess', - 'source' : 'https://github.com/Matthies/RubiChess', - 'testmodes' : { - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, - }, + 'Ethereal' : { + 'proto' : 'uci', + 'nps' : 1275000, + 'source' : 'https://github.com/AndyGrant/Ethereal', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '12.0+0.12' }, + 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, + }, + }, + + 'Laser' : { + 'proto' : 'uci', + 'nps' : 710000, + 'source' : 'https://github.com/jeffreyan11/uci-chess-engine', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, + }, + }, + + 'Weiss' : { + 'proto' : 'uci', + 'nps' : 2675000, + 'source' : 'https://github.com/TerjeKir/weiss', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' }, }, }, - # Book confgiruation. When addding a book, follow the provided template. - # The SHA is defined by hashlib.sha256(book).hexdigest(). OpenBench.py - # (Client File) has an example to show you how to find a hash digest - - 'books' : { - '2moves_v1.pgn' : { - 'name' : '2moves_v1.pgn', - 'sha' : '46aed7f2696618b2b914942032957b7a97a8f343bf54ba83e20a47818f0d42e0', - 'source' : FRAMEWORK_REPO_URL + 'raw/master/Books/2moves_v1.pgn', - 'default' : True, - }, - - '8moves_v3.pgn' : { - 'name' : '8moves_v3.pgn', - 'sha' : '04fcce1488a94f3b7795cef6f74d89016eb278328897c1018e6162c5967273f5', - 'source' : FRAMEWORK_REPO_URL + 'raw/master/Books/8moves_v3.pgn', - 'default' : False, - }, - - '3moves_FRC.pgn' : { - 'name' : '3moves_FRC.pgn', - 'sha' : '4c801140e3a52d3a306cb226ccd6225c47789409c5f2d0e1d7cf86152ea1f973', - 'source' : FRAMEWORK_REPO_URL + 'raw/master/Books/3moves_FRC.pgn', - 'default' : False, + 'Demolito' : { + 'proto' : 'uci', + 'nps' : 1250000, + 'source' : 'https://github.com/lucasart/Demolito', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '8.0+0.08' }, + 'ltc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '32.0+0.32'}, + 'smpstc' : { 'threads' : 8, 'hash' : 32, 'timecontrol' : '4.0+0.04' }, + 'smpltc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '16.0+0.16'}, }, }, - } + + 'RubiChess' : { + 'proto' : 'uci', + 'nps' : 1000000, + 'source' : 'https://github.com/Matthies/RubiChess', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, + }, + }, + }, } diff --git a/OpenBench/models.py b/OpenBench/models.py index 521ec90..2920a6e 100644 --- a/OpenBench/models.py +++ b/OpenBench/models.py @@ -1,3 +1,23 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + from django.db.models import CharField, IntegerField, BooleanField, FloatField from django.db.models import ForeignKey, DateTimeField, OneToOneField from django.db.models import CASCADE, PROTECT, Model diff --git a/OpenBench/static/style.css b/OpenBench/static/style.css index 2fde157..c9b416c 100644 --- a/OpenBench/static/style.css +++ b/OpenBench/static/style.css @@ -1,7 +1,7 @@ body { font-family: "Courier New"; - font-size: 16px; - background: #2A2A2A; + font-size: 18px; + background: #303030; } a:link, a:visited, a:hover, a:active { @@ -11,36 +11,36 @@ a:link, a:visited, a:hover, a:active { #sidebar { float: left; - margin: 20px; + margin: 16px; } #sidebar ul { list-style-type: none; - padding: 0px; + padding: 0px 16px; } #sidebar li a { - font-size: 18px; color: #A2A2A2; } #sidebar .header { - font-weight: bold; - color: #00CCFF; + font-size: 16px; + color: #00AF00; } #content { float: left; - padding: 20px 0px; + margin-top: 32px; color: #EAEAEA; } #content label { - width: 120px; + width: 128px; padding-right: 10px; - font-weight:bold; text-align: right; display: inline-block; + color: #A2A2A2; + font-size: 16px; } #content input, #content select { @@ -62,32 +62,28 @@ a:link, a:visited, a:hover, a:active { display: inline-block; vertical-align: middle; width: 290px; - background-color: #00CCFF; + background-color: #777777; color: black; border: none; - border-radius: 8px; + border-radius: 16px; cursor: pointer; font-weight: bold; } #content button:hover { - background-color: #FFFFFF; + background-color: #00AF00; } #content input[type=submit] { - background-color: #00CCFF; + background-color: #00AF00; color: #000000; border: none; - border-radius: 8px; + border-radius: 16px; cursor: pointer; width: 100%; font-weight: bold; } -#content input[type=submit]:hover { - background-color: #FFFFFF; -} - #content input:read-only { font-weight: bold; } @@ -101,28 +97,8 @@ a:link, a:visited, a:hover, a:active { margin-top: 20px; } -#content .summarytable th { - padding-top: 20px; - padding-right: 10px; - padding-bottom: 20px; - font-size: 16px; - color: #00CCFF; -} - -#content .rawtable td { - padding-right: 20px; -} - -#content .rawtable th { - padding-right: 20px; - text-align: left; -} - -#content .rawtable .numeric { - text-align: right; -} - #content #actions { + margin-left: 32px; float: right; } @@ -130,7 +106,7 @@ a:link, a:visited, a:hover, a:active { color: #000000; padding: 8px 8px; margin: 0px 8px; - border-radius: 8px; + border-radius: 16px; font-weight: bold; text-align: center; display: inline-block; @@ -138,7 +114,7 @@ a:link, a:visited, a:hover, a:active { } #content #actions .anchorbutton a:hover { - background-color: #FFFFFF; + background-color: #00AF00; } #content #actions #approvebutton { @@ -170,59 +146,59 @@ a:link, a:visited, a:hover, a:active { width: 100%; } -#content .datatable th { - color: #FFFFFF; - font-size: 20px; - padding: 6px 12px; - background-color: #2A2A2A; +#content .left-align { + text-align: left; } -#content .datatable td { +#content tr:hover { + background-color: #00AF00; +} + +#content th { + color: #00AF00; + font-size: 16px; + padding: 6px 12px; + background-color: #000000; +} + +#content td { padding: 6px 12px; } -#content .datatable .numeric { +#content .numeric { text-align: right; } -#content .datatable tr { - background-color: #212121; +#content tr { + background-color: #1A1A1A; } -#content .datatable .embedded { - border: none; - text-align: left; - padding-left: 0px; - background: #2A2A2A; +#content .table-spacer th { + background: #303030; + height: 16px; } -#content .datatable .embedded h2 { - margin: 16px 0px 0px 0px; - color: #00CCFF; -} - -#content .datatable .statblock { +#content .statblock { line-height: 70%; color: black; - background-color: #AAAAAA; + background-color: #CCCCCC; border-radius: 4px; } -#content .datatable .green { +#content .green { background-color: #9DF779 } -#content .datatable .yellow { +#content .yellow { background-color: #EEF788 } -#content .datatable .red { +#content .red { background-color: #FA8E8E } #content #results { display: inline-block; - margin-top: 50px; width: inherit; } @@ -244,7 +220,7 @@ a:link, a:visited, a:hover, a:active { #content #pagebrowse { text-align: center; - margin-top: 16px; + margin: 16px 0px 16px 0px; } #content .page { @@ -252,12 +228,12 @@ a:link, a:visited, a:hover, a:active { display: inline-block; padding: 8px 0px; width: 5%; - background-color: #212121; + background-color: #1A1A1A; border-radius: 8px; } #content .page:hover { - background-color: #AAAAAA; + background-color: #00AF00; } #error { @@ -269,14 +245,15 @@ a:link, a:visited, a:hover, a:active { } #content form h3 { - margin-left: 130px; + margin-left: 140px; margin-bottom: 0px; - color: #00CCFF; + font-size: 16px; + color: #00AF00; } #content form .settings-column { float: left; - padding-bottom: 4px; + padding-bottom: 16px; } #content #test-mode-buttons button { diff --git a/OpenBench/tests.py b/OpenBench/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/OpenBench/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/OpenBench/urls.py b/OpenBench/urls.py index 54e61b4..4642b73 100644 --- a/OpenBench/urls.py +++ b/OpenBench/urls.py @@ -1,41 +1,65 @@ -from django.urls import path +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -import OpenBench.views +import django.urls, OpenBench.views urlpatterns = [ - path(r'register/', OpenBench.views.register), - path(r'login/', OpenBench.views.login), - path(r'logout/', OpenBench.views.logout), - path(r'viewProfile/', OpenBench.views.viewProfile), - path(r'editProfile/', OpenBench.views.editProfile), + # Links for account managment + django.urls.path(r'register/', OpenBench.views.register), + django.urls.path(r'login/', OpenBench.views.login), + django.urls.path(r'logout/', OpenBench.views.logout), + django.urls.path(r'viewProfile/', OpenBench.views.viewProfile), + django.urls.path(r'editProfile/', OpenBench.views.editProfile), - path(r'index/', OpenBench.views.index), - path(r'index//', OpenBench.views.index), - path(r'greens/', OpenBench.views.greens), - path(r'greens//', OpenBench.views.greens), - path(r'search/', OpenBench.views.search), - path(r'viewUser//', OpenBench.views.viewUser), - path(r'viewUser///', OpenBench.views.viewUser), + # Links for viewing test tables + django.urls.path(r'index/', OpenBench.views.index), + django.urls.path(r'index//', OpenBench.views.index), + django.urls.path(r'greens/', OpenBench.views.greens), + django.urls.path(r'greens//', OpenBench.views.greens), + django.urls.path(r'search/', OpenBench.views.search), + django.urls.path(r'viewUser//', OpenBench.views.viewUser), + django.urls.path(r'viewUser///', OpenBench.views.viewUser), - path(r'users/', OpenBench.views.users), - path(r'machines/', OpenBench.views.machines), - path(r'eventLog/', OpenBench.views.eventLog), - path(r'eventLog//', OpenBench.views.eventLog), + # Links for viewing general information tables + django.urls.path(r'users/', OpenBench.views.users), + django.urls.path(r'machines/', OpenBench.views.machines), + django.urls.path(r'eventLog/', OpenBench.views.eventLog), + django.urls.path(r'eventLog//', OpenBench.views.eventLog), - path(r'newTest/', OpenBench.views.newTest), - path(r'viewTest//', OpenBench.views.viewTest), - path(r'editTest//', OpenBench.views.editTest), - path(r'approveTest//', OpenBench.views.approveTest), - path(r'restartTest//', OpenBench.views.restartTest), - path(r'stopTest//', OpenBench.views.stopTest), - path(r'deleteTest//', OpenBench.views.deleteTest), + # Links for viewing and managing tests + django.urls.path(r'newTest/', OpenBench.views.newTest), + django.urls.path(r'viewTest//', OpenBench.views.viewTest), + django.urls.path(r'editTest//', OpenBench.views.editTest), + django.urls.path(r'approveTest//', OpenBench.views.approveTest), + django.urls.path(r'restartTest//', OpenBench.views.restartTest), + django.urls.path(r'stopTest//', OpenBench.views.stopTest), + django.urls.path(r'deleteTest//', OpenBench.views.deleteTest), - path(r'getFiles/', OpenBench.views.getFiles), - path(r'getWorkload/', OpenBench.views.getWorkload), - path(r'wrongBench/', OpenBench.views.wrongBench), - path(r'submitNPS/', OpenBench.views.submitNPS), - path(r'submitResults/', OpenBench.views.submitResults), + # Links for the Client to update the Server + django.urls.path(r'getFiles/', OpenBench.views.getFiles), + django.urls.path(r'getWorkload/', OpenBench.views.getWorkload), + django.urls.path(r'wrongBench/', OpenBench.views.wrongBench), + django.urls.path(r'submitNPS/', OpenBench.views.submitNPS), + django.urls.path(r'submitResults/', OpenBench.views.submitResults), - path(r'', OpenBench.views.index), + # Redirect anything else to the Index + django.urls.path(r'', OpenBench.views.index), ] diff --git a/OpenBench/utils.py b/OpenBench/utils.py index 3868642..4049940 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -1,3 +1,23 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + import math, requests, random from django.utils import timezone @@ -61,12 +81,12 @@ def newTest(request): # Extract Development Fields devname = request.POST['devbranch'] devbench = int(request.POST['devbench']) - devprotocol = FRAMEWORK_DEFAULTS['config']['engines'][test.engine]['proto'] + devprotocol = OPENBENCH_CONFIG['engines'][test.engine]['proto'] # Extract Base Fields basename = request.POST['basebranch'] basebench = int(request.POST['basebench']) - baseprotocol = FRAMEWORK_DEFAULTS['config']['engines'][test.engine]['proto'] + baseprotocol = OPENBENCH_CONFIG['engines'][test.engine]['proto'] # Extract test configuration test.source = request.POST['source'] @@ -206,8 +226,8 @@ def workloadDictionary(machine, result, test): 'result' : { 'id' : result.id, }, 'test' : { 'id' : test.id, - 'nps' : FRAMEWORK_DEFAULTS['config']['engines'][test.engine]['nps'], - 'book' : FRAMEWORK_DEFAULTS['config']['books'][test.bookname], + 'nps' : OPENBENCH_CONFIG['engines'][test.engine]['nps'], + 'book' : OPENBENCH_CONFIG['books'][test.bookname], 'timecontrol' : test.timecontrol, 'engine' : test.engine, 'dev' : { diff --git a/OpenBench/views.py b/OpenBench/views.py index 8d962e7..d932b49 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -1,12 +1,32 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +#from django.shortcuts import render as djangoRender + +import django.shortcuts +import django.contrib.auth + from django.db.models import F -from django.shortcuts import render as djangoRender from django.http import HttpResponse, HttpResponseRedirect -from django.contrib.auth import authenticate -from django.contrib.auth import login as loginUser -from django.contrib.auth import logout as logoutUser from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required -from django.contrib.admin.views.decorators import staff_member_required from django.views.decorators.csrf import csrf_exempt from django.utils.timezone import utc from htmlmin.decorators import not_minified_response @@ -18,71 +38,83 @@ from OpenBench.utils import pagingContext import OpenBench.utils, datetime -def render(request, template, data): +def render(request, template, data={}): - # Always provde the Configuration - data.update(FRAMEWORK_DEFAULTS) - - # Send User data when logged in + # Provide Configuration & User information + data.update({'config' : OPENBENCH_CONFIG}) if request.user.is_authenticated: data.update({'profile' : Profile.objects.get(user=request.user)}) - # Final wrap of Django's rendering funtion - return djangoRender(request, 'OpenBench/{0}'.format(template), data) + # Wrapper to simplify django's rendering function + return django.shortcuts.render(request, 'OpenBench/{0}'.format(template), data) + + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Administrative Views # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # # + # GET : # + # # + # POST : # + # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # def register(request): - # User trying to view the registration page + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + # # + # GET : Return the HTML template used for registering a new User # + # # + # POST : Enforce matching alpha-numeric passwords, and then attempt to # + # generate a new User and Profile. Return to the homepage after # + # after logging the User in. Share any errors with the viewer # + # # + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + if request.method == 'GET': - return render(request, 'register.html', {}) + return render(request, 'register.html') - try: - # Verify that the passwords are matching - if request.POST['password1'] != request.POST['password2']: - raise Exception('Passwords Do Not Match') + if request.POST['password1'] != request.POST['password2']: + return index(request, error='Passwords Do Not Match') - # Force alpha numeric usernames - if not request.POST['username'].isalnum(): - raise Exception('Alpha Numeric Usernames Only') + if not request.POST['username'].isalnum(): + return index(request, error='Alpha Numeric Usernames Only') - # Create new User and Profile - Profile.objects.create( - user=User.objects.create_user( - request.POST['username'], - request.POST['email'], - request.POST['password1'])) + if User.objects.filter(username=request.POST['username']): + return index(request, error='That Username is taken') - # Log the User in now - loginUser(request, User.objects.get(username=request.POST['username'])) - # Kick back to index - return HttpResponseRedirect('/index/') + email = request.POST['email'] + username = request.POST['username'] + password = request.POST['password1'] - # Bad data, kick back to index with error - except Exception as error: - return index(request, error=str(error)) + user = User.objects.create_user(username, email, password) + Profile.objects.create(user=user) + django.contrib.auth.login(request, user) + + + return HttpResponseRedirect('/index/') def login(request): - # User trying to view the login page if request.method == 'GET': - return render(request, 'login.html', {}) + return render(request, 'login.html') try: - # Attempt to login the user, and return to index - loginUser(request, authenticate( - username=request.POST['username'], - password=request.POST['password'])) + django.contrib.auth.login(request, + django.contrib.auth.authenticate( + username=request.POST['username'], + password=request.POST['password'])) return HttpResponseRedirect('/index/') - # Bad data, kick back to index with error except Exception as error: - return index(request, error='Invalid Login Credentials') + return index(request, error='Unable to Authenticate User') def logout(request): - # Logout the user and return to index - logoutUser(request) + django.contrib.auth.logout(request) return HttpResponseRedirect('/index/') @login_required(login_url='/login/') @@ -115,6 +147,8 @@ def editProfile(request): # Send back to see the homepage return HttpResponseRedirect('/index/') + + def index(request, page=1, pageLength=24, greens=False, username=None, error=''): # Get tests pending approval @@ -259,7 +293,7 @@ def machines(request): data = {'machines' : Machine.objects.filter(updated__gte=target)} return render(request, 'machines.html', data) -def eventLog(request, page=1, pageLength=50): +def eventLog(request, page=1, pageLength=24): # Choose events within the given page, if any events = LogEvent.objects.all().order_by('-id') @@ -477,8 +511,7 @@ def deleteTest(request, id): def getFiles(request): # Core Files should be sitting in framework's repo - source = FRAMEWORK_REPO_URL + 'raw/master/CoreFiles/' - return HttpResponse(source) + return HttpResponse(OPENBENCH_CONFIG['corefiles']) @csrf_exempt @not_minified_response diff --git a/Templates/OpenBench/base.html b/Templates/OpenBench/base.html index 59a18a7..af6b49c 100644 --- a/Templates/OpenBench/base.html +++ b/Templates/OpenBench/base.html @@ -54,15 +54,15 @@
  • ENGINES
  • {% for engine, data in config.engines.items|dictsort:"0.lower" %} -
  • {{data.name}}
  • +
  • {{engine}}
  • {% endfor %}
diff --git a/Templates/OpenBench/eventLog.html b/Templates/OpenBench/eventLog.html index 6ea79fc..bbc891f 100644 --- a/Templates/OpenBench/eventLog.html +++ b/Templates/OpenBench/eventLog.html @@ -2,13 +2,14 @@ {% block content %} - +
- - - - + + + + + {% for event in events %} @@ -16,6 +17,7 @@ + {% endfor %} diff --git a/Templates/OpenBench/index.html b/Templates/OpenBench/index.html index e7349b0..1adb2a4 100644 --- a/Templates/OpenBench/index.html +++ b/Templates/OpenBench/index.html @@ -8,25 +8,27 @@ {% if paging.page == 1 and greens == False %} - - {% for test in pending %} - {% include "OpenBench/Blocks/testsummary.html" %} - {% endfor %} - - - {% if active %} - + {% if pending %} + + {% for test in pending %} + {% include "OpenBench/Blocks/testsummary.html" %} + {% endfor %} + {% endif %} - {% for test in active %} - {% include "OpenBench/Blocks/testsummary.html" %} - {% endfor %} + {% if active %} + + {% for test in active %} + {% include "OpenBench/Blocks/testsummary.html" %} + {% endfor %} + + {% endif %} {% endif %} - + {% for test in completed %} {% include "OpenBench/Blocks/testsummary.html" %} {% endfor %} diff --git a/Templates/OpenBench/machines.html b/Templates/OpenBench/machines.html index 45ecf3a..1fd2f53 100644 --- a/Templates/OpenBench/machines.html +++ b/Templates/OpenBench/machines.html @@ -1,18 +1,18 @@ {% extends "OpenBench/base.html" %} -{% load mytags %} +{% load mytags %} {% block content %} -
DateUserTestActionDATEUSERTESTTIMEACTION
{{event.creation|date:'Y-m-d H:i:s'}} {{event.author}} {{event.test.dev.name}}{{event.test.timecontrol}} {{event.data}}

Pending

Active {{status}}

Pending
Active {{status}}

Finished

Finished
+
- - - - - + + + + + diff --git a/Templates/OpenBench/newTest.html b/Templates/OpenBench/newTest.html index c584412..b522f1c 100644 --- a/Templates/OpenBench/newTest.html +++ b/Templates/OpenBench/newTest.html @@ -75,9 +75,9 @@
diff --git a/Templates/OpenBench/users.html b/Templates/OpenBench/users.html index 71d637d..af79dae 100644 --- a/Templates/OpenBench/users.html +++ b/Templates/OpenBench/users.html @@ -1,42 +1,38 @@ {% extends "OpenBench/base.html" %} -{% load mytags %} +{% load mytags %} {% block content %} -
IDUserSystemUpdatedWorkloadThreadsUSERSYSTEMUPDATEDWORKLOADTHREADS MNPS
- - - - - - -
OVERALL | USERS {{ profiles|length }} | TESTS {{ profiles|sumAttributes:"tests"|insertCommas }}| GAMES {{ profiles|sumAttributes:"games"|insertCommas }}
- - +
- - - - - - + + + + + {% for profile in profiles %} {% if profile.enabled %} - - - + + {% endif %} {% endfor %} + + + + + + +
UsernameLast SeenGamesTestsEngineSource RepositoryUSERNAMEGAMESTESTSENGINESOURCE REPOSITORY
{{profile.user.username}}{{profile.updated|date:'Y-m-d'}}{{profile.games}}{{profile.tests}}{{profile.games|insertCommas}}{{profile.tests|insertCommas}} {{profile.engine}} {{profile.repo}}
OVERALL{{profiles|sumAttributes:"games"|insertCommas}}{{profiles|sumAttributes:"tests"|insertCommas}}
{% endblock %} diff --git a/Templates/OpenBench/viewTest.html b/Templates/OpenBench/viewTest.html index 85d0f05..e167871 100644 --- a/Templates/OpenBench/viewTest.html +++ b/Templates/OpenBench/viewTest.html @@ -9,25 +9,23 @@ {% block content %}
- - - - - - - - - - - - - - - - - - - +
Engine{{test.engine}}
Dev Branch{{test.dev.name}}
Dev Bench{{test.dev.bench}}
Dev Options{{test.devoptions}}
Dev Protocol{{test.dev.protocol}}
Dev Sha{{test.dev.sha}}
Base Branch{{test.base.name}}
Base Bench{{test.base.bench}}
Base Options{{test.baseoptions}}
Base Protocol{{test.base.protocol}}
Base Sha{{test.base.sha}}
Source Repo{{test.source}}
Opening Book{{test.bookname}}
Time Control{{test.timecontrol}}s
Elo Bounds[{{test.elolower}}, {{test.eloupper}}]
SPRT Bounds({{test.lowerllr|twoDigitPrecision}}, {{test.upperllr|twoDigitPrecision}})
Creation{{test.creation|date:'Y-m-d H:i:s'}}
Author{{test.author}}
+ + + + + + + + + + + + + + + +
Engine{{test.engine}}
Dev Branch{{test.dev.name}}
Dev Bench{{test.dev.bench}}
Dev Options{{test.devoptions}}
Dev Sha{{test.dev.sha}}
Base Branch{{test.base.name}}
Base Bench{{test.base.bench}}
Base Options{{test.baseoptions}}
Base Sha{{test.base.sha}}
Source Repo{{test.source}}
Opening Book{{test.bookname}}
Time Control{{test.timecontrol}}s
Elo Bounds[{{test.elolower}}, {{test.eloupper}}]
SPRT Bounds({{test.lowerllr|twoDigitPrecision}}, {{test.upperllr|twoDigitPrecision}})
Creation{{test.creation|date:'Y-m-d H:i:s'}}
Author{{test.author}}
@@ -77,16 +75,20 @@
{{test|longStatBlock|linebreaksbr}}
+ +
+ {% csrf_token %}

+ {% if profile.approver or profile.user.username == test.author %} - + {% else %} - + {% endif %}
@@ -101,21 +103,21 @@ ID - Owner - System + USER + OS Last Updated - Games - Won - Lost - Drawn - Time - Crash + GAMES + WON + LOST + DRAWN + TIME + CRASH {% for result in results %} {{result.machine.id}} - {{result.machine.owner}} + {{result.machine.owner|slice:"6"}} {{result.machine.osname|truncatewords:1|slice:":-4"}} {{result.updated|date:'Y-m-d H:i'}} {{result.games}}