Implement support for cross-engine play

Also support for time odds
This commit is contained in:
andrew committed 2023-06-01 09:40:33 -04:00
1 parent 1bdb332aca
commit 01d99a86df
35 files changed
+681 -564

No files matched your search

+63 -49
View File
@@ -52,7 +52,7 @@ from itertools import combinations_with_replacement
TIMEOUT_HTTP = 30 # Timeout in seconds for HTTP requests TIMEOUT_HTTP = 30 # Timeout in seconds for HTTP requests
TIMEOUT_ERROR = 10 # Timeout in seconds when any errors are thrown TIMEOUT_ERROR = 10 # Timeout in seconds when any errors are thrown
TIMEOUT_WORKLOAD = 30 # Timeout in seconds between workload requests TIMEOUT_WORKLOAD = 30 # Timeout in seconds between workload requests
CLIENT_VERSION = '8' # Client version to send to the Server CLIENT_VERSION = '9' # Client version to send to the Server
SYZYGY_WDL_PATH = None # Pathway to WDL Syzygy Tables SYZYGY_WDL_PATH = None # Pathway to WDL Syzygy Tables
FLEET_MODE = False # Exit when there are no workloads FLEET_MODE = False # Exit when there are no workloads
@@ -191,8 +191,8 @@ def scan_for_cpu_flags(data):
SYSTEM_CPU_FLAGS = [x for x in desired if x in actual] SYSTEM_CPU_FLAGS = [x for x in desired if x in actual]
# Report the results of our search, including any "missing flags # Report the results of our search, including any "missing flags
print ('Found | ', ' '.join(SYSTEM_CPU_FLAGS)) print ('Found |', ' '.join(SYSTEM_CPU_FLAGS))
print ('Missing | ', ' '.join([x for x in desired if x not in actual])) print ('Missing |', ' '.join([x for x in desired if x not in actual]))
def scan_for_machine_id(): def scan_for_machine_id():
@@ -339,21 +339,26 @@ def parse_bench_output(stream):
nps = bench = None # Search through output Stream nps = bench = None # Search through output Stream
for line in stream.decode('ascii').strip().split('\n')[::-1]: for line in stream.decode('ascii').strip().split('\n')[::-1]:
# Try to match a wide array of patterns # Convert non alpha-numerics to spaces
line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line) line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line)
nps_pattern = r'([0-9]+ NPS)|(NPS[ ]+[0-9]+)'
bench_pattern = r'([0-9]+ NODES)|(NODES[ ]+[0-9]+)'
re_nps = re.search(nps_pattern, line.upper())
re_bench = re.search(bench_pattern, line.upper())
# Replace only if not already found earlier # Multiple methods, including Ethereal and Stockfish
if not nps and re_nps: nps = re_nps.group() nps_pattern = r'(\d+\s+nps)|(nps\s+\d+)|(nodes second\s+\d+)'
if not bench and re_bench: bench = re_bench.group() bench_pattern = r'(\d+\s+nodes)|(nodes\s+\d+)|(nodes searched\s+\d+)'
# Search for and set only once the NPS value
if (re_nps := re.search(nps_pattern, line, re.IGNORECASE)):
nps = nps if nps else re_nps.group()
# Search for and set only once the Bench value
if (re_bench := re.search(bench_pattern, line, re.IGNORECASE)):
bench = bench if bench else re_bench.group()
# Parse out the integer portion from our matches # Parse out the integer portion from our matches
nps = int(re.search(r'[0-9]+', nps).group()) if nps else None nps = int(re.search(r'\d+', nps ).group()) if nps else None
bench = int(re.search(r'[0-9]+', bench).group()) if bench else None bench = int(re.search(r'\d+', bench).group()) if bench else None
return (nps, bench)
return (bench, nps)
def run_bench(engine, outqueue, private_net=None): def run_bench(engine, outqueue, private_net=None):
@@ -363,16 +368,19 @@ def run_bench(engine, outqueue, private_net=None):
else: cmd = ['./' + engine, 'setoption name EvalFile value %s' % (private_net), 'bench', 'quit'] else: cmd = ['./' + engine, 'setoption name EvalFile value %s' % (private_net), 'bench', 'quit']
# Launch the engine and parse output for statistics # Launch the engine and parse output for statistics
process = Popen(cmd, stdout=PIPE, stderr=PIPE) stdout, stderr = Popen(cmd, stdout=PIPE, stderr=STDOUT).communicate()
stdout, stderr = process.communicate()
outqueue.put(parse_bench_output(stdout)) outqueue.put(parse_bench_output(stdout))
except Exception: outqueue.put((0, 0)) except Exception: outqueue.put((0, 0))
def scale_time_control(workload, nps): def scale_time_control(workload, nps, branch):
# Extract everything from the workload dictionary
reference_nps = workload['test'][branch]['nps']
time_control = workload['test'][branch]['time_control']
# Searching for Nodes or Depth time controls ("N=", "D=") # Searching for Nodes or Depth time controls ("N=", "D=")
pattern = '(?P<mode>((N))|(D))=(?P<value>(\d+))' pattern = '(?P<mode>((N))|(D))=(?P<value>(\d+))'
results = re.search(pattern, workload['test']['timecontrol'].upper()) results = re.search(pattern, time_control.upper())
# No scaling is needed for fixed nodes or fixed depth games # No scaling is needed for fixed nodes or fixed depth games
if results: if results:
@@ -381,16 +389,16 @@ def scale_time_control(workload, nps):
# Searching for MoveTime or Fixed Time Controls ("MT=") # Searching for MoveTime or Fixed Time Controls ("MT=")
pattern = '(?P<mode>(MT))=(?P<value>(\d+))' pattern = '(?P<mode>(MT))=(?P<value>(\d+))'
results = re.search(pattern, workload['test']['timecontrol'].upper()) results = re.search(pattern, time_control.upper())
# Scale the time based on this machine's NPS. Add a time Margin to avoid time losses. # Scale the time based on this machine's NPS. Add a time Margin to avoid time losses.
if results: if results:
mode, value = results.group('mode', 'value') mode, value = results.group('mode', 'value')
return 'st=%.2f timemargin=100' % (float(value) * int(workload['test']['nps']) / (1000 * nps)) return 'st=%.2f timemargin=100' % ((float(value) * reference_nps) / (1000 * nps))
# Searching for "X/Y+Z" time controls # Searching for "X/Y+Z" time controls
pattern = '(?P<moves>(\d+/)?)(?P<base>\d*(\.\d+)?)(?P<inc>\+(\d+\.)?\d+)?' pattern = '(?P<moves>(\d+/)?)(?P<base>\d*(\.\d+)?)(?P<inc>\+(\d+\.)?\d+)?'
results = re.search(pattern, workload['test']['timecontrol']) results = re.search(pattern, time_control)
moves, base, inc = results.group('moves', 'base', 'inc') moves, base, inc = results.group('moves', 'base', 'inc')
# Strip the trailing and leading symbols # Strip the trailing and leading symbols
@@ -398,8 +406,8 @@ def scale_time_control(workload, nps):
inc = 0.0 if inc is None else inc.lstrip('+') inc = 0.0 if inc is None else inc.lstrip('+')
# Scale the time based on this machine's NPS # Scale the time based on this machine's NPS
base = float(base) * int(workload['test']['nps']) / nps base = float(base) * reference_nps / nps
inc = float(inc ) * int(workload['test']['nps']) / nps inc = float(inc ) * reference_nps / nps
# Format the time control for cutechess # Format the time control for cutechess
if moves is None: return 'tc=%.2f+%.2f' % (base, inc) if moves is None: return 'tc=%.2f+%.2f' % (base, inc)
@@ -563,10 +571,11 @@ def server_request_workload(arguments):
# Log the start of a new Workload # Log the start of a new Workload
if 'workload' in response: if 'workload' in response:
engine = response['workload']['test']['engine'] dev_engine = response['workload']['test']['dev' ]['engine']
dev = response['workload']['test']['dev' ]['name'] dev_name = response['workload']['test']['dev' ]['name' ]
base = response['workload']['test']['base' ]['name'] base_engine = response['workload']['test']['base']['engine']
print('Workload [%s] %s vs %s\n' % (engine, dev, base)) base_name = response['workload']['test']['base']['name' ]
print('Workload [%s] %s vs [%s] %s\n' % (dev_engine, dev_name, base_engine, base_name))
return None if 'workload' not in response else response['workload'] return None if 'workload' not in response else response['workload']
@@ -596,11 +605,15 @@ def server_report_missing_artifact(arguments, workload, branch, artifact_name, a
def server_report_build_fail(arguments, workload, branch, compiler_output): def server_report_build_fail(arguments, workload, branch, compiler_output):
name = workload['test'][branch]['name']
if workload['test']['dev']['engine'] != workload['test']['base']['engine']:
name = '[%s] %s' % (workload['test'][branch]['engine'], name)
payload = { payload = {
'machine_id' : SYSTEM_MACHINE_ID, 'machine_id' : SYSTEM_MACHINE_ID,
'secret' : SYSTEM_SECRET_TOKEN, 'secret' : SYSTEM_SECRET_TOKEN,
'test_id' : workload['test']['id'], 'test_id' : workload['test']['id'],
'error' : '%s build failed' % (workload['test'][branch]['name']), 'error' : '%s build failed' % (name),
'logs' : compiler_output, 'logs' : compiler_output,
} }
@@ -775,12 +788,12 @@ def download_network_weights(arguments, workload, branch):
def download_engine(arguments, workload, branch, network): def download_engine(arguments, workload, branch, network):
engine = workload['test']['engine'] engine = workload['test'][branch]['engine']
branch_name = workload['test'][branch]['name'] branch_name = workload['test'][branch]['name']
commit_sha = workload['test'][branch]['sha'] commit_sha = workload['test'][branch]['sha']
source = workload['test'][branch]['source'] source = workload['test'][branch]['source']
build_path = workload['test']['build']['path'] build_path = workload['test'][branch]['build']['path']
private = 'artifacts' in workload['test']['build'] private = 'artifacts' in workload['test'][branch]['build']
# Naming as Engine-CommitSha[:8]-NetworkSha[:8] # Naming as Engine-CommitSha[:8]-NetworkSha[:8]
final_name = '%s-%s' % (engine, commit_sha.upper()[:8]) final_name = '%s-%s' % (engine, commit_sha.upper()[:8])
@@ -875,7 +888,7 @@ def run_benchmarks(arguments, workload, branch, engine, network):
cores = arguments.threads cores = arguments.threads
queue = multiprocessing.Queue() queue = multiprocessing.Queue()
name = workload['test'][branch]['name'] name = workload['test'][branch]['name']
private = 'artifacts' in workload['test']['build'] private = 'artifacts' in workload['test'][branch]['build']
print('\nRunning %dx Benchmarks for %s' % (cores, name)) print('\nRunning %dx Benchmarks for %s' % (cores, name))
for ii in range(cores): for ii in range(cores):
@@ -903,8 +916,14 @@ def build_cutechess_command(arguments, workload, dev_cmd, base_cmd, nps, cuteche
dev_threads = int(re.search('(?<=Threads=)\d*', dev_options ).group()) dev_threads = int(re.search('(?<=Threads=)\d*', dev_options ).group())
base_threads = int(re.search('(?<=Threads=)\d*', base_options).group()) base_threads = int(re.search('(?<=Threads=)\d*', base_options).group())
dev_name = dev_cmd.rstrip('.exe') # Used to name the PGN file and Headers dev_network = workload['test']['base']['network'] # Could be empty strings
base_name = base_cmd.rstrip('.exe') # Used to name the PGN file and Headers base_network = workload['test']['base']['network'] # Could be empty strings
dev_time = scale_time_control(workload, nps, 'dev')
base_time = scale_time_control(workload, nps, 'base')
dev_name = dev_cmd.rstrip('.exe') # Used to name the PGN file and Headers
base_name = base_cmd.rstrip('.exe') # Used to name the PGN file and Headers
# Possibly add SyzygyPath to dev and base options # Possibly add SyzygyPath to dev and base options
if SYZYGY_WDL_PATH and workload['test']['syzygy_wdl'] != 'DISABLED': if SYZYGY_WDL_PATH and workload['test']['syzygy_wdl'] != 'DISABLED':
@@ -912,18 +931,15 @@ def build_cutechess_command(arguments, workload, dev_cmd, base_cmd, nps, cuteche
dev_options += ' SyzygyPath=%s' % (path) dev_options += ' SyzygyPath=%s' % (path)
base_options += ' SyzygyPath=%s' % (path) base_options += ' SyzygyPath=%s' % (path)
# Add EvalFile to the options for Private engines using Networks # Private engines may need extra options to set their NNUE files
if 'artifacts' in workload['test']['build']: if 'artifacts' in workload['test']['dev']['build'] and dev_network and dev_network != 'None':
dev_options += ' EvalFile=%s' % (os.path.join('../Networks', dev_network))
dev_name += '-%s' % (dev_network)
dev_network = workload['test']['dev' ]['network'] # Private engines may need extra options to set their NNUE files
if dev_network and dev_network != 'None': if 'artifacts' in workload['test']['base']['build'] and base_network and base_network != 'None':
dev_options += ' EvalFile=%s' % (os.path.join('../Networks', dev_network)) base_options += ' EvalFile=%s' % (os.path.join('../Networks', base_network))
dev_name += '-%s' % (dev_network) base_name += '-%s' % (base_network)
base_network = workload['test']['base']['network']
if base_network and base_network != 'None':
base_options += ' EvalFile=%s' % (os.path.join('../Networks', base_network))
base_name += '-%s' % (base_network)
# Join all of the options into a single string # Join all of the options into a single string
dev_options = ' option.'.join([''] + dev_options.split()) dev_options = ' option.'.join([''] + dev_options.split())
@@ -951,13 +967,11 @@ def build_cutechess_command(arguments, workload, dev_cmd, base_cmd, nps, cuteche
games = int(concurrency * workload['test']['workload_size']) games = int(concurrency * workload['test']['workload_size'])
games = max(8, concurrency * 2, games - (games % (2 * concurrency))) games = max(8, concurrency * 2, games - (games % (2 * concurrency)))
time_control = scale_time_control(workload, nps)
args = ( args = (
win_adj, draw_adj, win_adj, draw_adj,
int(time.time() + cutechess_idx), variant, concurrency, games, int(time.time() + cutechess_idx), variant, concurrency, games,
dev_cmd, time_control, dev_options, dev_name, dev_cmd, dev_time, dev_options, dev_name,
base_cmd, time_control, base_options, base_name, base_cmd, base_time, base_options, base_name,
book_name, book_name.split('.')[-1], book_name, book_name.split('.')[-1],
dev_name, base_name, cutechess_idx, dev_name, base_name, cutechess_idx,
) )
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1225000, "nps" : 1254000,
"base" : "master", "base" : "master",
"source" : "https://github.com/kz04px/4ku", "source" : "https://github.com/kz04px/4ku",
+5 -5
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1325000, "nps" : 1145000,
"base" : "main", "base" : "main",
"source" : "https://github.com/jhonnold/berserk", "source" : "https://github.com/jhonnold/berserk",
@@ -19,28 +19,28 @@
"STC" : { "STC" : {
"options" : "Threads=1 Hash=8", "options" : "Threads=1 Hash=8",
"timecontrol" : "10.0+0.1", "timecontrol" : "8.0+0.08",
"report_rate" : 16, "report_rate" : 16,
"workload_size" : 32 "workload_size" : 32
}, },
"LTC" : { "LTC" : {
"options" : "Threads=1 Hash=64", "options" : "Threads=1 Hash=64",
"timecontrol" : "60.0+0.6", "timecontrol" : "40.0+0.4",
"report_rate" : 4, "report_rate" : 4,
"workload_size" : 8 "workload_size" : 8
}, },
"SMP STC" : { "SMP STC" : {
"options" : "Threads=8 Hash=64", "options" : "Threads=8 Hash=64",
"timecontrol" : "5.0+0.05", "timecontrol" : "4.0+0.04",
"report_rate" : 1, "report_rate" : 1,
"workload_size" : 64 "workload_size" : 64
}, },
"SMP LTC" : { "SMP LTC" : {
"options" : "Threads=8 Hash=256", "options" : "Threads=8 Hash=256",
"timecontrol" : "20.0+0.2", "timecontrol" : "16.0+0.16",
"report_rate" : 1, "report_rate" : 1,
"workload_size" : 16 "workload_size" : 16
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1975000, "nps" : 2096000,
"base" : "master", "base" : "master",
"source" : "https://github.com/Aryan1508/Bit-Genie", "source" : "https://github.com/Aryan1508/Bit-Genie",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1075000, "nps" : 1106000,
"base" : "main", "base" : "main",
"source" : "https://github.com/dsekercioglu/blackmarlin", "source" : "https://github.com/dsekercioglu/blackmarlin",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1300000, "nps" : 1395000,
"base" : "master", "base" : "master",
"source" : "https://github.com/lucasart/Demolito", "source" : "https://github.com/lucasart/Demolito",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1250000, "nps" : 1163000,
"base" : "master", "base" : "master",
"source" : "https://github.com/justNo4b/Drofa", "source" : "https://github.com/justNo4b/Drofa",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1050000, "nps" : 1128000,
"base" : "master", "base" : "master",
"source" : "https://github.com/AndyGrant/Ethereal", "source" : "https://github.com/AndyGrant/Ethereal",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1000000, "nps" : 1012000,
"base" : "master", "base" : "master",
"source" : "https://github.com/fabianvdW/FabChess", "source" : "https://github.com/fabianvdW/FabChess",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1800000, "nps" : 1881000,
"base" : "master", "base" : "master",
"source" : "https://github.com/KierenP/Halogen", "source" : "https://github.com/KierenP/Halogen",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 450000, "nps" : 470000,
"base" : "master", "base" : "master",
"source" : "https://github.com/vshcherbyna/igel", "source" : "https://github.com/vshcherbyna/igel",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1200000, "nps" : 1346000,
"base" : "master", "base" : "master",
"source" : "https://github.com/Luecx/Koivisto", "source" : "https://github.com/Luecx/Koivisto",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 935000, "nps" : 941000,
"base" : "master", "base" : "master",
"source" : "https://github.com/jeffreyan11/uci-chess-engine", "source" : "https://github.com/jeffreyan11/uci-chess-engine",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 925000, "nps" : 937000,
"base" : "master", "base" : "master",
"source" : "https://github.com/Matthies/RubiChess", "source" : "https://github.com/Matthies/RubiChess",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 875000, "nps" : 736000,
"base" : "main", "base" : "main",
"source" : "https://github.com/connormcmonigle/seer-nnue", "source" : "https://github.com/connormcmonigle/seer-nnue",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1625000, "nps" : 1689000,
"base" : "master", "base" : "master",
"source" : "https://github.com/mhouppin/stash-bot", "source" : "https://github.com/mhouppin/stash-bot",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 1700000, "nps" : 1758000,
"base" : "master", "base" : "master",
"source" : "https://github.com/TerjeKir/weiss", "source" : "https://github.com/TerjeKir/weiss",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 625000, "nps" : 661000,
"base" : "master", "base" : "master",
"source" : "https://github.com/rosenthj/Winter", "source" : "https://github.com/rosenthj/Winter",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private" : false, "private" : false,
"nps" : 850000, "nps" : 946000,
"base" : "master", "base" : "master",
"source" : "https://github.com/amanjpro/zahak", "source" : "https://github.com/amanjpro/zahak",
+2 -2
View File
@@ -38,7 +38,7 @@ REQUIRE_MANUAL_REGISTRATION = True # Disable the public facing registration pag
OPENBENCH_CONFIG = { OPENBENCH_CONFIG = {
# Server Client version control # Server Client version control
'client_version' : '8', 'client_version' : '9',
# Generic Error Messages useful to those setting up their own instance # Generic Error Messages useful to those setting up their own instance
'error' : { 'error' : {
@@ -54,7 +54,7 @@ OPENBENCH_CONFIG = {
# Test Configuration. For both SPRT and Fixed Games Tests # Test Configuration. For both SPRT and Fixed Games Tests
'tests' : { 'tests' : {
'max_games' : '20000', # Default for Fixed Games 'max_games' : '40000', # Default for Fixed Games
'confidence' : '[0.05, 0.05]', # SPRT Type I/II Confidence 'confidence' : '[0.05, 0.05]', # SPRT Type I/II Confidence
}, },
+41 -38
View File
@@ -54,7 +54,7 @@ class Machine(Model):
updated = DateTimeField(auto_now=True) updated = DateTimeField(auto_now=True)
secret = CharField(max_length=64, default='None') secret = CharField(max_length=64, default='None')
info = JSONField() info = JSONField()
workload = ForeignKey('Test', PROTECT, related_name='workload', default=1) workload = IntegerField(default=0)
def __str__(self): def __str__(self):
return '[%d] %s' % (self.id, self.user.username) return '[%d] %s' % (self.id, self.user.username)
@@ -76,57 +76,59 @@ class Result(Model):
class Test(Model): class Test(Model):
author = CharField(max_length=64) # Misc information
engine = CharField(max_length=64) author = CharField(max_length=64)
test_mode = CharField(max_length=16, default='SPRT') book_name = CharField(max_length=32)
dev = ForeignKey('Engine', PROTECT, related_name='dev') # Dev Engine, and all of its settings
base = ForeignKey('Engine', PROTECT, related_name='base') dev = ForeignKey('Engine', PROTECT, related_name='dev')
source = CharField(max_length=1024) dev_repo = CharField(max_length=1024)
dev_engine = CharField(max_length=64)
dev_options = CharField(max_length=256)
dev_network = CharField(max_length=256)
dev_netname = CharField(max_length=256)
dev_time_control = CharField(max_length=32)
devoptions = CharField(max_length=256) # Base Engine, and all of its settings
baseoptions = CharField(max_length=256) base = ForeignKey('Engine', PROTECT, related_name='base')
base_repo = CharField(max_length=1024)
base_engine = CharField(max_length=64)
base_options = CharField(max_length=256)
base_network = CharField(max_length=256)
base_netname = CharField(max_length=256)
base_time_control = CharField(max_length=32)
devnetwork = CharField(max_length=256) # Changable Test Parameters
basenetwork = CharField(max_length=256) report_rate = IntegerField(default=8)
workload_size = IntegerField(default=32)
priority = IntegerField(default=0)
throughput = IntegerField(default=0)
devnetname = CharField(max_length=256) # Tablebases and Cutechess adjudicatoins
basenetname = CharField(max_length=256)
bookname = CharField(max_length=32)
timecontrol = CharField(max_length=16)
priority = IntegerField(default=0)
throughput = IntegerField(default=0)
syzygy_adj = CharField(max_length=16, default='OPTIONAL')
syzygy_wdl = CharField(max_length=16, default='OPTIONAL') syzygy_wdl = CharField(max_length=16, default='OPTIONAL')
syzygy_adj = CharField(max_length=16, default='OPTIONAL')
win_adj = CharField(max_length=64, default='movecount=3 score=400') win_adj = CharField(max_length=64, default='movecount=3 score=400')
draw_adj = CharField(max_length=64, default='movenumber=40 movecount=8 score=10') draw_adj = CharField(max_length=64, default='movenumber=40 movecount=8 score=10')
# Client configuration # Test Mode specific values, either SPRT or GAMES
report_rate = IntegerField(default=8) test_mode = CharField(max_length=16, default='SPRT')
workload_size = IntegerField(default=32) elolower = FloatField(default=0.0) # SPRT
eloupper = FloatField(default=0.0) # SPRT
# Only for SPRT Tests alpha = FloatField(default=0.0) # SPRT
elolower = FloatField(default=0.0) beta = FloatField(default=0.0) # SPRT
eloupper = FloatField(default=0.0) lowerllr = FloatField(default=0.0) # SPRT
alpha = FloatField(default=0.0) currentllr = FloatField(default=0.0) # SPRT
beta = FloatField(default=0.0) upperllr = FloatField(default=0.0) # SPRT
lowerllr = FloatField(default=0.0) max_games = IntegerField(default=0) # GAMES
currentllr = FloatField(default=0.0)
upperllr = FloatField(default=0.0)
# Only for Fixed-Games Tests
max_games = IntegerField(default=0)
# Summary of all associated result objects
games = IntegerField(default=0) games = IntegerField(default=0)
wins = IntegerField(default=0) wins = IntegerField(default=0)
draws = IntegerField(default=0) draws = IntegerField(default=0)
losses = IntegerField(default=0) losses = IntegerField(default=0)
error = BooleanField(default=False) error = BooleanField(default=False)
# All status flags associated with the test
passed = BooleanField(default=False) passed = BooleanField(default=False)
failed = BooleanField(default=False) failed = BooleanField(default=False)
finished = BooleanField(default=False) finished = BooleanField(default=False)
@@ -134,11 +136,12 @@ class Test(Model):
approved = BooleanField(default=False) approved = BooleanField(default=False)
awaiting = BooleanField(default=False) awaiting = BooleanField(default=False)
# Datetime house keeping for meta data
creation = DateTimeField(auto_now_add=True) creation = DateTimeField(auto_now_add=True)
updated = DateTimeField(auto_now=True) updated = DateTimeField(auto_now=True)
def __str__(self): def __str__(self):
return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.timecontrol) return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.dev_timecontrol)
class LogEvent(Model): class LogEvent(Model):
-12
View File
@@ -6,10 +6,6 @@
width: 21%; width: 21%;
} }
.w-42 {
width: 42%;
}
.w-50 { .w-50 {
width: 50%; width: 50%;
} }
@@ -18,10 +14,6 @@
width: 75%; width: 75%;
} }
.w-84 {
width: 84%;
}
.w-100 { .w-100 {
width: 100%; width: 100%;
} }
@@ -38,10 +30,6 @@
max-width: 75%; max-width: 75%;
} }
.mw-84 {
max-width: 84%;
}
.mw-100 { .mw-100 {
max-width: 100%; max-width: 100%;
} }
+143
View File
@@ -0,0 +1,143 @@
var config = JSON.parse(document.getElementById("json-config" ).textContent);
var networks = JSON.parse(document.getElementById("json-networks").textContent);
function create_network_options(field_id, engine) {
var has_default = false;
var network_options = document.getElementById(field_id);
while (network_options.length)
network_options.remove(0);
for (const network of networks) {
if (network.engine !== engine)
continue;
var opt = document.createElement("option");
opt.text = network.name;
opt.value = network.sha256;
opt.selected = network.default;
network_options.add(opt)
has_default = has_default || network.default;
}
{
var opt = document.createElement("option");
opt.text = "None";
opt.value = "";
opt.selected = !has_default;
network_options.add(opt);
}
}
function create_testmode_buttons(engine) {
// Clear out all of the existing buttons
var button_div = document.getElementById("test-mode-buttons");
while (button_div.hasChildNodes())
button_div.removeChild(button_div.lastChild);
var index = 0;
for (let mode in config.engines[engine].testmodes) {
// Create a new button for the test mode
var btn = document.createElement('button')
btn.innerHTML = mode;
btn.onclick = function() { set_test_mode(mode); };
// Apply all of our CSS bootstrapping
btn.classList.add("anchorbutton");
btn.classList.add("btn-preset");
btn.classList.add("mt-2");
btn.classList.add("w-100");
// Put the button in a div, so we can handle padding
var div = document.createElement('div')
div.appendChild(btn)
div.classList.add("col-half");
// Left pad everything but the first
if ((index % 4) != 0)
div.classList.add("pl-1");
// Right pad everything but the last
if ((index % 4) != 3)
div.classList.add("pr-1");
button_div.append(div);
index++;
}
}
function set_test_type() {
var selectA = document.getElementById("test_mode");
var mode = selectA.options[selectA.selectedIndex].value;
var selectB = document.getElementById("dev_engine");
var engine = selectB.options[selectB.selectedIndex].value;
if (mode == "SPRT") {
document.getElementById("test_bounds" ).value = config.engines[engine].bounds
document.getElementById("test_confidence").value = config.tests.confidence;
document.getElementById("test_max_games" ).value = "N/A";
}
if (mode == "GAMES") {
document.getElementById("test_bounds" ).value = "N/A";
document.getElementById("test_confidence").value = "N/A";
document.getElementById("test_max_games" ).value = config.tests.max_games;
}
}
function set_test_mode(mode_str) {
var selection = document.getElementById("dev_engine");
var engine = selection.options[selection.selectedIndex].value;
var mode = config.engines[engine].testmodes[mode_str];
document.getElementById("report_rate" ).value = mode["report_rate"] || 8;
document.getElementById("workload_size").value = mode["workload_size"] || 32;
document.getElementById("book_name" ).value = mode["book"] || config.engines[engine].book;
document.getElementById("dev_options" ).value = mode["options"] || "Threads=1 Hash=8";
document.getElementById("dev_time_control" ).value = mode["timecontrol"] || "10.0+0.1";
document.getElementById("base_options" ).value = mode["options"] || "Threads=1 Hash=8";
document.getElementById("base_time_control").value = mode["timecontrol"] || "10.0+0.1";
if (mode["bounds"] != null) {
document.getElementById("test_mode").value = "SPRT"; set_test_type();
document.getElementById("test_bounds").value = mode["bounds"];
}
if (mode["games"] != null) {
document.getElementById("test_mode").value = "GAMES"; set_test_type();
document.getElementById("test_max_games").value = mode["games"];
}
if (mode["bounds"] == null && mode["games"] == null) {
document.getElementById("test_mode").value = "SPRT"; set_test_type();
}
}
function set_engine(engine, target) {
document.getElementById(target + "_engine").value = engine;
if (target == 'dev') {
create_testmode_buttons(engine);
set_test_mode('STC');
}
create_network_options(target + "_network", engine);
document.getElementById("base_branch").value = config.engines[engine].base;
document.getElementById("book_name" ).value = config.engines[engine].book;
document.getElementById("win_adj" ).value = config.engines[engine].win_adj;
document.getElementById("draw_adj" ).value = config.engines[engine].draw_adj;
}
+4 -9
View File
@@ -1,6 +1,6 @@
#content .form .col-half { #content .form .col-half {
display: inline-block; display: inline-block;
width: 21%; width: 25%;
white-space: normal; white-space: normal;
box-sizing: border-box; box-sizing: border-box;
vertical-align: top; vertical-align: top;
@@ -8,7 +8,7 @@
#content .form .col { #content .form .col {
display: inline-block; display: inline-block;
width: 42%; width: 50%;
white-space: normal; white-space: normal;
margin-left: 0; margin-left: 0;
box-sizing: border-box; box-sizing: border-box;
@@ -34,14 +34,10 @@
} }
#content .form h3 { #content .form h3 {
font-weight: 500;
font-size: 14px; font-size: 14px;
width: 100%; color: var(--color-font3);
display: inline-block;
box-sizing: border-box;
padding-left: 1rem;
text-align: left; text-align: left;
color: var(--color-font3) padding-left: 1.5rem;
} }
#content .form .row { #content .form .row {
@@ -56,7 +52,6 @@
min-width: 128px; min-width: 128px;
margin-right: 1rem; margin-right: 1rem;
text-align: right; text-align: right;
font-weight: 400;
color: var(--color-font2) color: var(--color-font2)
} }
+1 -2
View File
@@ -29,7 +29,6 @@ body, html, main{
} }
#sidebar { #sidebar {
/*float: left;*/
padding: 60px 16px 16px 16px; padding: 60px 16px 16px 16px;
flex-basis: calc(min(300px, max(200px, 15%))); flex-basis: calc(min(300px, max(200px, 15%)));
} }
@@ -45,7 +44,7 @@ body, html, main{
} }
#content{ #content{
max-width: calc(min(100%,1100px)); max-width: calc(min(100%,1000px));
width: 100%; width: 100%;
white-space: nowrap; white-space: nowrap;
display: inline-block; display: inline-block;
+18 -16
View File
@@ -51,21 +51,21 @@ def gitDiffLink(test):
base = test['base']['source'] base = test['base']['source']
devsha = test['dev']['sha'] devsha = test['dev']['sha']
basesha = test['base']['sha'] basesha = test['base']['sha']
engine = test['engine'] engine = test['dev_engine']
else: else:
dev = test.dev.source dev = test.dev.source
base = test.base.source base = test.base.source
devsha = test.dev.sha devsha = test.dev.sha
basesha = test.base.sha basesha = test.base.sha
engine = test.engine engine = test.dev_engine
if OpenBench.config.OPENBENCH_CONFIG['engines'][engine]['private']: if OpenBench.config.OPENBENCH_CONFIG['engines'][engine]['private']:
repo = OpenBench.config.OPENBENCH_CONFIG['engines'][engine]['source'] repo = OpenBench.config.OPENBENCH_CONFIG['engines'][engine]['source']
else: else:
repo = OpenBench.utils.pathjoin(*dev.split('/')[:-2]) repo = OpenBench.utils.path_join(*dev.split('/')[:-2])
return OpenBench.utils.pathjoin(repo, 'compare', return OpenBench.utils.path_join(repo, 'compare',
'{0}...{1}'.format(basesha[:8], devsha[:8])) '{0}...{1}'.format(basesha[:8], devsha[:8]))
def shortStatBlock(test): def shortStatBlock(test):
@@ -96,9 +96,8 @@ def shortStatBlock(test):
def longStatBlock(test): def longStatBlock(test):
tokens = test.devoptions.split(' ') threads = OpenBench.utils.extract_option(test.dev_options, 'Threads')
threads = tokens[0].split('=')[1] hash = OpenBench.utils.extract_option(test.dev_options, 'Hash')
hash = tokens[1].split('=')[1]
lower, elo, upper = OpenBench.stats.ELO(test.wins, test.losses, test.draws) lower, elo, upper = OpenBench.stats.ELO(test.wins, test.losses, test.draws)
error = max(upper - elo, elo - lower) error = max(upper - elo, elo - lower)
@@ -113,7 +112,7 @@ def longStatBlock(test):
upperllr = twoDigitPrecision(test.upperllr) upperllr = twoDigitPrecision(test.upperllr)
elolower = twoDigitPrecision(test.elolower) elolower = twoDigitPrecision(test.elolower)
eloupper = twoDigitPrecision(test.eloupper) eloupper = twoDigitPrecision(test.eloupper)
timecontrol = test.timecontrol + ['s', '']['=' in test.timecontrol] timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \ return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \
+ 'SPRT | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \ + 'SPRT | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \
@@ -122,7 +121,7 @@ def longStatBlock(test):
if test.test_mode == 'GAMES': if test.test_mode == 'GAMES':
timecontrol = test.timecontrol + ['s', '']['=' in test.timecontrol] timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \ return 'ELO | {0} +- {1} (95%)\n'.format(elo, error) \
+ 'CONF | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \ + 'CONF | {0} Threads={1} Hash={2}MB\n'.format(timecontrol, threads, hash) \
@@ -150,21 +149,25 @@ def prettyName(name):
def prettyDevName(test): def prettyDevName(test):
# If engines are different, use the base name + branch
if test.dev_engine != test.base_engine:
return '[%s] %s' % (test.base_engine, test.base.name)
# If testing different Networks, possibly use the Network name # If testing different Networks, possibly use the Network name
if test.dev.name == test.base.name and test.devnetname != '': if test.dev.name == test.base.name and test.dev_netname != '':
# Nets match as well, so revert back to the branch name # Nets match as well, so revert back to the branch name
if test.devnetwork == test.basenetwork: if test.dev_network == test.base_network:
return prettyName(test.dev.name) return prettyName(test.dev.name)
# Use the network's name, if we still have it saved # Use the network's name, if we still have it saved
try: return OpenBench.models.Network.objects.get(sha256=test.devnetwork).name try: return OpenBench.models.Network.objects.get(sha256=test.dev_network).name
except: return test.devnetname # File has since been deleted ? except: return test.dev_netname # File has since been deleted ?
return prettyName(test.dev.name) return prettyName(test.dev.name)
def testIsFRC(test): def testIsFRC(test):
return "FRC" in test.bookname.upper() or "960" in test.bookname.upper() return "FRC" in test.book_name.upper() or "960" in test.book_name.upper()
def resolveNetworkURL(sha256): def resolveNetworkURL(sha256):
if OpenBench.models.Network.objects.filter(sha256=sha256): if OpenBench.models.Network.objects.filter(sha256=sha256):
@@ -175,11 +178,10 @@ def testIdToPrettyName(test_id):
return prettyName(OpenBench.models.Test.objects.get(id=test_id).dev.name) return prettyName(OpenBench.models.Test.objects.get(id=test_id).dev.name)
def testIdToTimeControl(test_id): def testIdToTimeControl(test_id):
return OpenBench.models.Test.objects.get(id=test_id).timecontrol return OpenBench.models.Test.objects.get(id=test_id).dev_time_control
def cpuflagsBlock(machine, N=8): def cpuflagsBlock(machine, N=8):
reported = [] reported = []
flags = machine.info['cpu_flags'] flags = machine.info['cpu_flags']
+211 -129
View File
@@ -32,10 +32,10 @@ from OpenBench.config import *
from OpenBench.models import Engine, Profile, Machine, Result, Test, Network from OpenBench.models import Engine, Profile, Machine, Result, Test, Network
def pathjoin(*args): def path_join(*args):
return "/".join([f.lstrip("/").rstrip("/") for f in args]) + "/" return "/".join([f.lstrip("/").rstrip("/") for f in args]).rstrip('/')
def extractOption(options, option): def extract_option(options, option):
match = re.search('(?<={0}=")[^"]*'.format(option), options) match = re.search('(?<={0}=")[^"]*'.format(option), options)
if match: return match.group() if match: return match.group()
@@ -46,7 +46,7 @@ def extractOption(options, option):
match = re.search('(?<={0}=)[^ ]*'.format(option), options) match = re.search('(?<={0}=)[^ ]*'.format(option), options)
if match: return match.group() if match: return match.group()
def parseTimeControl(time_control): def parse_time_control(timecontrol):
# Display Nodes as N=, Depth as D=, MoveTime as MT= # Display Nodes as N=, Depth as D=, MoveTime as MT=
conversion = { conversion = {
@@ -57,13 +57,13 @@ def parseTimeControl(time_control):
# Searching for "nodes=", "depth=", and "movetime=" Time Controls # Searching for "nodes=", "depth=", and "movetime=" Time Controls
pattern = '(?P<mode>((N)|(D)|(MT)|(nodes)|(depth)|(movetime)))=(?P<value>(\d+))' pattern = '(?P<mode>((N)|(D)|(MT)|(nodes)|(depth)|(movetime)))=(?P<value>(\d+))'
if results := re.search(pattern, time_control.upper()): if results := re.search(pattern, timecontrol.upper()):
mode, value = results.group('mode', 'value') mode, value = results.group('mode', 'value')
return '%s=%s' % (conversion[mode], value) return '%s=%s' % (conversion[mode], value)
# Searching for "X/Y+Z" time controls # Searching for "X/Y+Z" time controls
pattern = '(?P<moves>(\d+/)?)(?P<base>\d*(\.\d+)?)(?P<inc>\+(\d+\.)?\d+)?' pattern = '(?P<moves>(\d+/)?)(?P<base>\d*(\.\d+)?)(?P<inc>\+(\d+\.)?\d+)?'
if results := re.search(pattern, time_control): if results := re.search(pattern, timecontrol):
moves, base, inc = results.group('moves', 'base', 'inc') moves, base, inc = results.group('moves', 'base', 'inc')
# Strip the trailing and leading symbols # Strip the trailing and leading symbols
@@ -74,7 +74,7 @@ def parseTimeControl(time_control):
if moves is None: return '%.1f+%.2f' % (float(base), float(inc)) if moves is None: return '%.1f+%.2f' % (float(base), float(inc))
return '%d/%.1f+%.2f' % (int(moves), float(base), float(inc)) return '%d/%.1f+%.2f' % (int(moves), float(base), float(inc))
raise Exception('Unable to parse Time Control (%s)' % (time_control)) raise Exception('Unable to parse Time Control (%s)' % (timecontrol))
def get_pending_tests(): def get_pending_tests():
@@ -157,17 +157,17 @@ def getEngine(source, name, sha, bench):
def read_git_credentials(engine): def read_git_credentials(engine):
fname = 'credentials.%s' % (engine.replace(' ', '').lower()) fname = 'credentials.%s' % (engine.replace(' ', '').lower())
if os.path.exists(fname): if os.path.exists(fname):
with open(fname) as fin: with open(fname) as fin:
return { 'Authorization' : 'token %s' % fin.readlines()[0].rstrip() } return { 'Authorization' : 'token %s' % fin.readlines()[0].rstrip() }
def requests_illegal_fork(request): def requests_illegal_fork(request, field):
# Strip trailing '/'s for sanity # Strip trailing '/'s for sanity
engine = OPENBENCH_CONFIG['engines'][request.POST['enginename']] engine = OPENBENCH_CONFIG['engines'][request.POST['%s_engine' % (field)]]
eng_src = engine['source'].rstrip('/') eng_src = engine['source'].rstrip('/')
tar_src = request.POST['source'].rstrip('/') tar_src = request.POST['%s_repo' % (field)].rstrip('/')
# Illegal if sources do not match for Private engines # Illegal if sources do not match for Private engines
return engine['private'] and eng_src != tar_src return engine['private'] and eng_src != tar_src
@@ -175,7 +175,7 @@ def requests_illegal_fork(request):
def determine_bench(request, field, message): def determine_bench(request, field, message):
# Use the provided bench if possible # Use the provided bench if possible
try: return int(request.POST['{0}bench'.format(field)]) try: return int(request.POST['{0}_bench'.format(field)])
except: pass except: pass
# Fallback to try to parse the Bench from the commit # Fallback to try to parse the Bench from the commit
@@ -187,27 +187,28 @@ def determine_bench(request, field, message):
def collect_github_info(request, errors, field): def collect_github_info(request, errors, field):
# Get branch name, whether it is a commit SHA, and the API path for it # Get branch name, whether it is a commit SHA, and the API path for it
branch = request.POST['{0}branch'.format(field)] branch = request.POST['{0}_branch'.format(field)]
bysha = bool(re.search('[0-9a-fA-F]{40}', branch)) bysha = bool(re.search('[0-9a-fA-F]{40}', branch))
url = 'commits' if bysha else 'branches' url = 'commits' if bysha else 'branches'
# All API requests will share this common path. Some engines are private. # All API requests will share this common path. Some engines are private.
base = request.POST['source'].replace('github.com', 'api.github.com/repos') base = request.POST['%s_repo' % (field)].replace('github.com', 'api.github.com/repos')
private = OPENBENCH_CONFIG['engines'][request.POST['enginename']]['private'] engine = request.POST['%s_engine' % (field)]
private = OPENBENCH_CONFIG['engines'][engine]['private']
headers = {} headers = {}
## Step 1: Verify the target of the API requests ## Step 1: Verify the target of the API requests
## [A] We will not attempt to reach any sit other than api.github.com ## [A] We will not attempt to reach any site other than api.github.com
## [B] Private engines may only use their main repo for sources of tests ## [B] Private engines may only use their main repo for sources of tests
## [C] Determine which, if any, credentials we want to pass along ## [C] Determine which, if any, credentials we want to pass along
# Private engines must have a token stored in credentials.enginename # Private engines must have a token stored in credentials.enginename
if private and not (headers := read_git_credentials(request.POST['enginename'])): if private and not (headers := read_git_credentials(engine)):
errors.append('Server does not have access tokens for this engine') errors.append('Server does not have access tokens for this engine')
return (None, None) return (None, None)
# Do not allow private engines to use forked repos ( We don't have a token! ) # Do not allow private engines to use forked repos ( We don't have a token! )
if requests_illegal_fork(request): if requests_illegal_fork(request, field):
errors.append('Forked Repositories are not allowed for Private engines') errors.append('Forked Repositories are not allowed for Private engines')
return (None, None) return (None, None)
@@ -227,7 +228,7 @@ def collect_github_info(request, errors, field):
try: # Fetch data from the Github API try: # Fetch data from the Github API
path = 'commits' if bysha else 'branches' path = 'commits' if bysha else 'branches'
url = pathjoin(base, path, branch).rstrip('/') url = path_join(base, path, branch)
data = requests.get(url, headers=headers).json() data = requests.get(url, headers=headers).json()
data = data if bysha else data['commit'] data = data if bysha else data['commit']
@@ -242,9 +243,9 @@ def collect_github_info(request, errors, field):
return (None, None) return (None, None)
# Public Engines: Construct the .zip download and return everything # Public Engines: Construct the .zip download and return everything
if not OPENBENCH_CONFIG['engines'][request.POST['enginename']]['private']: if not OPENBENCH_CONFIG['engines'][engine]['private']:
treeurl = data['commit']['tree']['sha'] + '.zip' treeurl = data['commit']['tree']['sha'] + '.zip'
source = pathjoin(request.POST['source'], 'archive', treeurl).rstrip('/') source = path_join(request.POST['%s_repo' % (field)], 'archive', treeurl)
return (source, branch, data['sha'], bench), True return (source, branch, data['sha'], bench), True
## Step 3: Construct the URL for the API request to list all Artifacts ## Step 3: Construct the URL for the API request to list all Artifacts
@@ -252,7 +253,6 @@ def collect_github_info(request, errors, field):
## [B] These should contain combinations for windows/linux, avx2/avx512, popcnt/pext ## [B] These should contain combinations for windows/linux, avx2/avx512, popcnt/pext
## [C] If those artifacts are not found, we flag the test as awaiting, and try later. ## [C] If those artifacts are not found, we flag the test as awaiting, and try later.
engine = request.POST['enginename']
url, has_all = fetch_artifact_url(base, engine, headers, data['sha']) url, has_all = fetch_artifact_url(base, engine, headers, data['sha'])
return (url, branch, data['sha'], bench), has_all return (url, branch, data['sha'], bench), has_all
@@ -260,12 +260,12 @@ def fetch_artifact_url(base, engine, headers, sha):
try: try:
# Fetch the run id for the openbench workflow for this comment # Fetch the run id for the openbench workflow for this comment
url = pathjoin(base, 'actions', 'workflows', 'openbench.yml', 'runs').rstrip('/') url = path_join(base, 'actions', 'workflows', 'openbench.yml', 'runs')
url += '?head_sha=%s' % (sha) url += '?head_sha=%s' % (sha)
run_id = requests.get(url=url, headers=headers).json()['workflow_runs'][0]['id'] run_id = requests.get(url=url, headers=headers).json()['workflow_runs'][0]['id']
# Construct the final URL that will be used to look at artifacts # Construct the final URL that will be used to look at artifacts
url = pathjoin(base, 'actions', 'runs', str(run_id), 'artifacts').rstrip('/') url = path_join(base, 'actions', 'runs', str(run_id), 'artifacts')
artifacts = requests.get(url=url, headers=headers).json()['artifacts'] artifacts = requests.get(url=url, headers=headers).json()['artifacts']
# Verify that all of the artifacts exist and are not expired # Verify that all of the artifacts exist and are not expired
@@ -280,121 +280,187 @@ def fetch_artifact_url(base, engine, headers, sha):
# If anything goes wrong, retry later with the same base URL # If anything goes wrong, retry later with the same base URL
return (base, False) return (base, False)
def verifyNewTest(request): def verify_test_creation(request):
errors = [] errors = []
def verifyInteger(field, fieldName): def verify_integer(field, field_name):
try: int(request.POST[field]) try: int(request.POST[field])
except: errors.append('"{0}" is not an Integer'.format(fieldName)) except: errors.append('"{0}" is not an Integer'.format(field_name))
def verifyGreaterThan(field, fieldName, value): def verify_greater_than(field, field_name, value):
if not float(request.POST[field]) > value: try: assert int(request.POST[field]) > value
errors.append('"{0}" is not greater than {1}'.format(fieldName, value)) except: errors.append('"{0}" is not greater than {1}'.format(field_name, value))
def verifyOptions(field, option, fieldName): def verify_options(field, option, field_name):
if extractOption(request.POST[field], option) == None: try: assert int(extract_option(request.POST[field], option)) >= 1
errors.append('"{0}" was not found as an option for {1}'.format(option, fieldName)) except: errors.append('"{0}" needs to be at least 1 for {1}'.format(option, field_name))
elif int(extractOption(request.POST[field], option)) < 1:
errors.append('"{0}" needs to be at least 1 for {1}'.format(option, fieldName))
def verifyConfiguration(field, fieldName, parent): def verify_configuration(field, field_name, parent):
if request.POST[field] not in OpenBench.config.OPENBENCH_CONFIG[parent].keys(): try: assert request.POST[field] in OpenBench.config.OPENBENCH_CONFIG[parent].keys()
errors.append('"{0}" was not found in the configuration'.format(fieldName)) except: errors.append('{0} was not found in the configuration'.format(field_name))
def verifyTimeControl(field, fieldName): def verify_time_control(field, field_name):
try: parseTimeControl(request.POST[field]) try: parse_time_control(request.POST[field])
except: errors.append('"{0}" is not a parsable {1}'.format(request.POST[field], fieldName)) except: errors.append('{0} is not a parsable'.format(field_name))
def verifyWinAdjudication(field): def verify_win_adj(field):
if (content := request.POST[field]) == 'None': return try:
try: assert re.match('movecount=[0-9]+ score=[0-9]+', content) if (content := request.POST[field]) == 'None': return
except: errors.append('"{0}" is not a parsable Win Adjudication Seting'.format(content)) assert re.match('movecount=[0-9]+ score=[0-9]+', content)
except: errors.append('Invalid Win Adjudication Setting. Try "None"?')
def verifyDrawAdjudication(field): def verify_draw_adj(field):
if (content := request.POST[field]) == 'None': return try:
try: assert re.match('movenumber=[0-9]+ movecount=[0-9]+ score=[0-9]+', content) if (content := request.POST[field]) == 'None': return
except: errors.append('"{0}" is not a parsable Draw Adjudication Seting'.format(content)) assert re.match('movenumber=[0-9]+ movecount=[0-9]+ score=[0-9]+', content)
except: errors.append('Invalid Draw Adjudication Setting. Try "None"?')
def verify_github_repo(field):
try: assert request.POST[field].startswith('https://github.com/')
except: errors.append('Sources must be found on https://github.com/')
def verify_network(field, fieldName):
try:
if request.POST[field] == '': return
Network.objects.get(sha256=request.POST[field])
except: errors.append('Unknown Network Provided for {0}'.format(fieldName))
def verify_test_mode(field):
try: assert request.POST[field] in ['SPRT', 'GAMES']
except: errors.append('Unknown Test Mode')
def verify_sprt_bounds(field):
try:
if request.POST['test_mode'] != 'SPRT': return
pattern = r'^\[(-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\]$'
match = re.match(pattern, request.POST['test_bounds'])
assert float(match.group(1)) < float(match.group(2))
except: errors.append('SPRT Bounds must be formatted as [float1, float2]')
def verify_sprt_conf(field):
try:
if request.POST['test_mode'] != 'SPRT': return
pattern = r'^\[(-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\]$'
match = re.match(pattern, request.POST['test_confidence'])
assert 0.00 < float(match.group(1)) < 1.00
assert 0.00 < float(match.group(2)) < 1.00
except: errors.append('Confidence Bounds must be formatted as [float1, float2], within (0.00, 1.00)')
def verify_max_games(field):
try:
if request.POST['test_mode'] != 'GAMES': return
assert int(request.POST['test_max_games']) > 0
except: errors.append('Fixed Games Tests must last at least one game')
def verify_syzygy_field(field, field_name):
try: assert request.POST[field] in ['OPTIONAL', 'REQUIRED', 'DISABLED']
except: errors.append('{0} must be OPTIONAL, REQUIRED, or DISABLED'.format(field_name))
verifications = [ verifications = [
# Must have all of these values for test settings # Verify everything about the Dev Engine
(verifyInteger, 'priority', 'Priority' ), (verify_configuration, 'dev_engine', 'Dev Engine', 'engines'),
(verifyInteger, 'throughput', 'Throughput' ), (verify_github_repo , 'dev_repo'),
(verifyInteger, 'report_rate', 'Report Rate' ), (verify_network , 'dev_network', 'Dev Network'),
(verifyInteger, 'workload_size', 'Workload Size'), (verify_options , 'dev_options', 'Threads', 'Dev Options'),
(verify_options , 'dev_options', 'Hash', 'Dev Options'),
(verify_time_control , 'dev_time_control', 'Dev Time Control'),
# Can't allow non-natural values for any of these fields # Verify everything about the Base Engine
(verifyGreaterThan, 'throughput', 'Throughput', 0), (verify_configuration, 'base_engine', 'Base Engine', 'engines'),
(verifyGreaterThan, 'report_rate', 'Report Rate', 0), (verify_github_repo , 'base_repo'),
(verifyGreaterThan, 'workload_size', 'Workload Size', 0), (verify_network , 'base_network', 'Base Network'),
(verify_options , 'base_options', 'Threads', 'Base Options'),
(verify_options , 'base_options', 'Hash', 'Base Options'),
(verify_time_control , 'base_time_control', 'Base Time Control'),
(verifyOptions, 'devoptions', 'Threads', 'Dev Options'), # Verify everything about the Test Settings
(verifyOptions, 'devoptions', 'Hash', 'Dev Options'), (verify_configuration, 'book_name', 'Book', 'books'),
(verifyOptions, 'baseoptions', 'Threads', 'Base Options'), (verify_test_mode , 'test_mode'),
(verifyOptions, 'baseoptions', 'Hash', 'Base Options'), (verify_sprt_bounds , 'test_bounds'),
(verifyConfiguration, 'enginename', 'Engine', 'engines'), (verify_sprt_conf , 'test_confidence'),
(verifyConfiguration, 'bookname', 'Book', 'books'), (verify_max_games , 'test_max_games'),
(verifyTimeControl, 'timecontrol', 'Time Control'),
(verifyWinAdjudication, 'win_adj'), # Verify everything about the General Settings
(verifyDrawAdjudication, 'draw_adj'), (verify_integer , 'priority', 'Priority'),
(verify_greater_than , 'throughput', 'Throughput', 0),
(verify_syzygy_field , 'syzygy_wdl', 'Syzygy WDL'),
# Verify everything about the Workload Settings
(verify_greater_than , 'report_rate', 'Report Rate', 0),
(verify_greater_than , 'workload_size', 'Workload Size', 0),
# Verify everything about the Adjudicaton Settings
(verify_syzygy_field , 'syzygy_adj', 'Syzygy Adjudication'),
(verify_win_adj , 'win_adj'),
(verify_draw_adj , 'draw_adj'),
] ]
for verification in verifications: for verification in verifications:
try: verification[0](*verification[1:]) verification[0](*verification[1:])
except: pass
return errors return errors
def createNewTest(request): def create_new_test(request):
errors = verifyNewTest(request) # Verify all of the fields in the request
if errors != []: return None, errors if (errors := verify_test_creation(request)):
return None, errors
# Collect Github meta information (Shas, Sources, Benches)
devinfo, dev_has_all = collect_github_info(request, errors, 'dev') devinfo, dev_has_all = collect_github_info(request, errors, 'dev')
baseinfo, base_has_all = collect_github_info(request, errors, 'base') baseinfo, base_has_all = collect_github_info(request, errors, 'base')
if errors != []: return None, errors if errors != []: return None, errors
test = Test() test = Test()
test.author = request.user.username test.author = request.user.username
test.engine = request.POST['enginename'] test.book_name = request.POST['book_name']
test.test_mode = request.POST['test_mode']
test.source = request.POST['source']
test.devoptions = request.POST['devoptions'].rstrip(' ')
test.baseoptions = request.POST['baseoptions'].rstrip(' ')
test.devnetwork = request.POST['devnetwork']
test.basenetwork = request.POST['basenetwork']
test.bookname = request.POST['bookname']
test.timecontrol = parseTimeControl(request.POST['timecontrol'])
test.priority = int(request.POST['priority'])
test.throughput = int(request.POST['throughput'])
test.syzygy_wdl = request.POST['syzygy_wdl']
test.syzygy_adj = request.POST['syzygy_adj']
test.win_adj = request.POST['win_adj']
test.draw_adj = request.POST['draw_adj']
test.report_rate = int(request.POST['report_rate'])
test.workload_size = int(request.POST['workload_size'])
if request.POST['test_mode'] == 'SPRT': test.dev = getEngine(*devinfo)
test.elolower = float(request.POST['bounds'].split(',')[0].lstrip('[')) test.dev_repo = request.POST['dev_repo']
test.eloupper = float(request.POST['bounds'].split(',')[1].rstrip(']')) test.dev_engine = request.POST['dev_engine']
test.alpha = float(request.POST['confidence'].split(',')[1].rstrip(']')) test.dev_options = request.POST['dev_options']
test.beta = float(request.POST['confidence'].split(',')[0].lstrip('[')) test.dev_network = request.POST['dev_network']
test.dev_time_control = request.POST['dev_time_control']
test.base = getEngine(*baseinfo)
test.base_repo = request.POST['base_repo']
test.base_engine = request.POST['base_engine']
test.base_options = request.POST['base_options']
test.base_network = request.POST['base_network']
test.base_time_control = request.POST['base_time_control']
test.report_rate = int(request.POST['report_rate'])
test.workload_size = int(request.POST['workload_size'])
test.priority = int(request.POST['priority'])
test.throughput = int(request.POST['throughput'])
test.syzygy_wdl = request.POST['syzygy_wdl']
test.syzygy_adj = request.POST['syzygy_adj']
test.win_adj = request.POST['win_adj']
test.draw_adj = request.POST['draw_adj']
test.test_mode = request.POST['test_mode']
test.awaiting = not (dev_has_all and base_has_all)
if test.test_mode == 'SPRT':
test.elolower = float(request.POST['test_bounds'].split(',')[0].lstrip('['))
test.eloupper = float(request.POST['test_bounds'].split(',')[1].rstrip(']'))
test.alpha = float(request.POST['test_confidence'].split(',')[1].rstrip(']'))
test.beta = float(request.POST['test_confidence'].split(',')[0].lstrip('['))
test.lowerllr = math.log(test.beta / (1.0 - test.alpha)) test.lowerllr = math.log(test.beta / (1.0 - test.alpha))
test.upperllr = math.log((1.0 - test.beta) / test.alpha) test.upperllr = math.log((1.0 - test.beta) / test.alpha)
if request.POST['test_mode'] == 'GAMES': if test.test_mode == 'GAMES':
test.max_games = int(request.POST['max_games']) test.max_games = int(request.POST['test_max_games'])
if request.POST['devnetwork']: if test.dev_network:
test.devnetname = Network.objects.get(sha256=request.POST['devnetwork']).name test.dev_netname = Network.objects.get(sha256=test.dev_network ).name
if request.POST['basenetwork']: if test.base_network:
test.basenetname = Network.objects.get(sha256=request.POST['basenetwork']).name test.base_netname = Network.objects.get(sha256=test.base_network).name
test.dev = getEngine(*devinfo)
test.base = getEngine(*baseinfo)
test.awaiting = not (dev_has_all and base_has_all)
test.save() test.save()
profile = Profile.objects.get(user=request.user) profile = Profile.objects.get(user=request.user)
@@ -435,7 +501,7 @@ def get_workload(machine):
result = Result(test=test, machine=machine) result = Result(test=test, machine=machine)
# Update the Machine's status and save everything # Update the Machine's status and save everything
machine.workload = test; machine.save(); result.save() machine.workload = test.id; machine.save(); result.save()
return { 'workload' : workload_to_dictionary(test, result) } return { 'workload' : workload_to_dictionary(test, result) }
@@ -449,7 +515,8 @@ def get_valid_workloads(machine):
# Skip engines that the Machine cannot handle # Skip engines that the Machine cannot handle
for engine in OPENBENCH_CONFIG['engines'].keys(): for engine in OPENBENCH_CONFIG['engines'].keys():
if engine not in machine.info['supported']: if engine not in machine.info['supported']:
tests = tests.exclude(engine=engine) tests = tests.exclude(dev_engine=engine)
tests = tests.exclude(base_engine=engine)
# Skip tests with unmet Syzygy requirments # Skip tests with unmet Syzygy requirments
if not machine.info['syzygy_wdl']: if not machine.info['syzygy_wdl']:
@@ -470,8 +537,8 @@ def get_valid_workloads(machine):
def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads): def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads):
dev_threads = int(extractOption(test.devoptions, 'Threads')) dev_threads = int(extract_option(test.dev_options, 'Threads'))
base_threads = int(extractOption(test.baseoptions, 'Threads')) base_threads = int(extract_option(test.base_options, 'Threads'))
# Each individual cutechess copy must have access to sufficient Threads # Each individual cutechess copy must have access to sufficient Threads
if max(dev_threads, base_threads) > (threads / ncutechess): if max(dev_threads, base_threads) > (threads / ncutechess):
@@ -482,10 +549,13 @@ def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads):
def select_workload(machine, tests, variance=0.25): def select_workload(machine, tests, variance=0.25):
# For reference for later
test_ids = [test.id for test in tests]
# Determine how many threads are assigned to each workload # Determine how many threads are assigned to each workload
table = { test : 0 for test in tests } table = { test : 0 for test in tests }
for m in getRecentMachines(): for m in getRecentMachines():
if m.workload in tests and m != machine: if m.workload in test_ids and m != machine:
table[m.workload] = table[m.workload] + m.info['concurrency'] table[m.workload] = table[m.workload] + m.info['concurrency']
# Find the tests most deserving of resources currently # Find the tests most deserving of resources currently
@@ -493,14 +563,14 @@ def select_workload(machine, tests, variance=0.25):
lowest_idxs = [i for i, r in enumerate(ratios) if r == min(ratios)] lowest_idxs = [i for i, r in enumerate(ratios) if r == min(ratios)]
# Machine is out of date; or there is an unassigned test # Machine is out of date; or there is an unassigned test
if machine.workload not in tests or min(ratios) == 0: if machine.workload not in test_ids or min(ratios) == 0:
return tests[random.choice(lowest_idxs)] return tests[random.choice(lowest_idxs)]
# No test has less than (1-variance)% of its deserved resources, and # No test has less than (1-variance)% of its deserved resources, and
# therefore we may have this machine repeat its existing workload again # therefore we may have this machine repeat its existing workload again
ideal_ratio = sum(table.values()) / sum([x.throughput for x in tests]) ideal_ratio = sum(table.values()) / sum([x.throughput for x in tests])
if min(ratios) / ideal_ratio > 1 - variance: if min(ratios) / ideal_ratio > 1 - variance:
return machine.workload return OpenBench.models.Test.objects(id=machine.workload)
# Fallback to simply doing the least attention given test # Fallback to simply doing the least attention given test
return tests[random.choice(lowest_idxs)] return tests[random.choice(lowest_idxs)]
@@ -509,34 +579,46 @@ def workload_to_dictionary(test, result):
return { return {
'result' : { 'id' : result.id }, 'result' : {
'id' : result.id
},
'test' : { 'test' : {
'id' : test.id, 'id' : test.id,
'engine' : test.engine,
'timecontrol' : test.timecontrol,
'syzygy_wdl' : test.syzygy_wdl, 'syzygy_wdl' : test.syzygy_wdl,
'syzygy_adj' : test.syzygy_adj, 'syzygy_adj' : test.syzygy_adj,
'win_adj' : test.win_adj, 'win_adj' : test.win_adj,
'draw_adj' : test.draw_adj, 'draw_adj' : test.draw_adj,
'report_rate' : test.report_rate, 'report_rate' : test.report_rate,
'workload_size' : test.workload_size, 'workload_size' : test.workload_size,
'nps' : OPENBENCH_CONFIG['engines'][test.engine]['nps'], 'book' : OPENBENCH_CONFIG['books'][test.book_name],
'build' : OPENBENCH_CONFIG['engines'][test.engine]['build'],
'book' : OPENBENCH_CONFIG['books'][test.bookname],
'dev' : { 'dev' : {
'id' : test.dev.id, 'name' : test.dev.name, 'id' : test.dev.id,
'source' : test.dev.source, 'sha' : test.dev.sha, 'name' : test.dev.name,
'bench' : test.dev.bench, 'options' : test.devoptions, 'source' : test.dev.source,
'network' : test.devnetwork, 'sha' : test.dev.sha,
'bench' : test.dev.bench,
'engine' : test.dev_engine,
'options' : test.dev_options,
'network' : test.dev_network,
'time_control' : test.dev_time_control,
'nps' : OPENBENCH_CONFIG['engines'][test.dev_engine]['nps'],
'build' : OPENBENCH_CONFIG['engines'][test.dev_engine]['build'],
}, },
'base' : { 'base' : {
'id' : test.base.id, 'name' : test.base.name, 'id' : test.base.id,
'source' : test.base.source, 'sha' : test.base.sha, 'name' : test.base.name,
'bench' : test.base.bench, 'options' : test.baseoptions, 'source' : test.base.source,
'network' : test.basenetwork, 'sha' : test.base.sha,
'bench' : test.base.bench,
'engine' : test.base_engine,
'options' : test.base_options,
'network' : test.base_network,
'time_control' : test.base_time_control,
'nps' : OPENBENCH_CONFIG['engines'][test.base_engine]['nps'],
'build' : OPENBENCH_CONFIG['engines'][test.base_engine]['build'],
}, },
}, },
} }
+1 -1
View File
@@ -491,7 +491,7 @@ def newTest(request):
data = { 'networks' : list(Network.objects.all().values()) } data = { 'networks' : list(Network.objects.all().values()) }
return render(request, 'newTest.html', data) return render(request, 'newTest.html', data)
test, errors = OpenBench.utils.createNewTest(request) test, errors = OpenBench.utils.create_new_test(request)
if errors != [] and errors != None: if errors != [] and errors != None:
errors = ["[{0}]: {1}".format(i, e) for i, e in enumerate(errors)] errors = ["[{0}]: {1}".format(i, e) for i, e in enumerate(errors)]
longest = max([len(e) for e in errors]) longest = max([len(e) for e in errors])
-1
View File
@@ -100,7 +100,6 @@ def build_all_engines():
os.mkdir('Binaries') os.mkdir('Binaries')
for engine, config in OPENBENCH_CONFIG['engines'].items(): for engine, config in OPENBENCH_CONFIG['engines'].items():
if USE_OLD_BINARIES and os.path.isfile('Binaries/' + engine): if USE_OLD_BINARIES and os.path.isfile('Binaries/' + engine):
continue continue
+17 -16
View File
@@ -9,34 +9,35 @@ def parse_stream_output(stream):
nps = bench = None # Search through output Stream nps = bench = None # Search through output Stream
for line in stream.decode('ascii').strip().split('\n')[::-1]: for line in stream.decode('ascii').strip().split('\n')[::-1]:
# Try to match a wide array of patterns # Convert non alpha-numerics to spaces
line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line) line = re.sub(r'[^a-zA-Z0-9 ]+', ' ', line)
nps_pattern = r'([0-9]+ NPS)|(NPS[ ]+[0-9]+)'
bench_pattern = r'([0-9]+ NODES)|(NODES[ ]+[0-9]+)'
re_nps = re.search(nps_pattern, line.upper())
re_bench = re.search(bench_pattern, line.upper())
# Replace only if not already found earlier # Multiple methods, including Ethereal and Stockfish
if not nps and re_nps: nps = re_nps.group() nps_pattern = r'(\d+\s+nps)|(nps\s+\d+)|(nodes second\s+\d+)'
if not bench and re_bench: bench = re_bench.group() bench_pattern = r'(\d+\s+nodes)|(nodes\s+\d+)|(nodes searched\s+\d+)'
# Search for and set only once the NPS value
if (re_nps := re.search(nps_pattern, line, re.IGNORECASE)):
nps = nps if nps else re_nps.group()
# Search for and set only once the Bench value
if (re_bench := re.search(bench_pattern, line, re.IGNORECASE)):
bench = bench if bench else re_bench.group()
# Parse out the integer portion from our matches # Parse out the integer portion from our matches
nps = int(re.search(r'[0-9]+', nps).group()) if nps else None nps = int(re.search(r'\d+', nps ).group()) if nps else None
bench = int(re.search(r'[0-9]+', bench).group()) if bench else None bench = int(re.search(r'\d+', bench).group()) if bench else None
return (bench, nps) return (bench, nps)
def single_core_bench(engine, outqueue): def single_core_bench(engine, outqueue):
# Launch the bench and wait for results # Launch the bench and wait for results
stdout, stderr = subprocess.Popen( stdout, stderr = subprocess.Popen(
"./{0} bench".format(engine).split(), './{0} bench'.format(engine).split(),
stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate() stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
# Parse output streams for the benchmark data outqueue.put(parse_stream_output(stdout))
bench, speed = parse_stream_output(stdout)
if bench is None or speed is None:
bench, speed = parse_stream_output(stderr)
outqueue.put((int(bench), int(speed)))
def multi_core_bench(engine, threads): def multi_core_bench(engine, threads):
+9 -3
View File
@@ -1,13 +1,19 @@
{% load mytags %} {% load mytags %}
<tr> <tr>
<td><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td> <td><a href="/user/{{test.author}}">{{test.author|capfirst|slice:":6"}}</a></td>
<td>{{test.engine}}</td> <td>
{{test.dev_engine}}
{% if test.dev_engine != test.base_engine %} <span style="color: yellow">*</span> {% endif %}
</td>
<td> <td>
<a href="/test/{{test.id}}">{{test|prettyDevName}}</a> <a href="/test/{{test.id}}">{{test|prettyDevName}}</a>
{% if test.error %} <span style="color: red">*</span> {% endif %} {% if test.error %} <span style="color: red">*</span> {% endif %}
{% if test|testIsFRC %} <span style="color: green">[FRC]</span> {% endif %} {% if test|testIsFRC %} <span style="color: green">*</span> {% endif %}
</td> </td>
<td class="textcenter"><a href="{{test|gitDiffLink}}">diff</a></td> <td class="textcenter"><a href="{{test|gitDiffLink}}">diff</a></td>
<td>{{test.timecontrol}}</td> <td>
{{test.dev_time_control}}
{% if test.dev_time_control != test.base_time_control %} <span style="color: yellow">*</span> {% endif %}
</td>
<td class='statblock statblock-{{test|testResultColour}}'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td> <td class='statblock statblock-{{test|testResultColour}}'><strong>{{test|shortStatBlock|linebreaksbr}}</strong></td>
</tr> </tr>
+4 -7
View File
@@ -5,25 +5,22 @@
{% load static %} {% load static %}
<head> <head>
<link rel="icon" type="image/svg+xml" href="{% static 'logo.svg' %}">
<link rel="stylesheet" href="{% static 'style.css' %}"> <link rel="stylesheet" href="{% static 'style.css' %}">
<link rel="stylesheet" href="{% static 'base.css' %}"> <link rel="stylesheet" href="{% static 'base.css' %}">
<link rel="stylesheet" href="{% static 'form.css' %}"> <link rel="stylesheet" href="{% static 'form.css' %}">
<link rel="stylesheet" href="{% static 'paging.css' %}"> <link rel="stylesheet" href="{% static 'paging.css' %}">
<link rel="icon" type="image/svg+xml" href="{% static 'logo.svg' %}">
<link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css' rel='stylesheet'> <link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css' rel='stylesheet'>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,200;0,400;1,100&amp;display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap" rel="stylesheet">
<title>OpenBench</title> <title>OpenBench</title>
{% block json %} {% block scripts %}
{% endblock %} {% endblock %}
<script> <script>
{% block scripts %}
{% endblock %}
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
var timestamps = document.getElementsByClassName('timestamp'); var timestamps = document.getElementsByClassName('timestamp');
@@ -99,7 +96,7 @@
<ul> <ul>
<li class="header">Engines</li> <li class="header">Engines</li>
{% for engine, data in config.engines.items|dictsort:"0.lower" %} {% for engine, data in config.engines.items %}
<li><a href="{{data.source}}">{{engine}}</a></li> <li><a href="{{data.source}}">{{engine}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
+39 -35
View File
@@ -5,51 +5,55 @@
{% block scripts %} {% block scripts %}
var Networks = [ <script>
{% for network in networks %}
{
'default' : "{{network.default}}",
'engine' : "{{network.engine}}",
'author' : "{{network.author|capfirst}}",
'name' : "{{network.name}}",
'hash' : "{{network.sha256}}",
},
{% endfor %}
];
var Network_Sorting; var Networks = [
{% for network in networks %}
{
'default' : "{{network.default}}",
'engine' : "{{network.engine}}",
'author' : "{{network.author|capfirst}}",
'name' : "{{network.name}}",
'hash' : "{{network.sha256}}",
},
{% endfor %}
];
function swap_networks(index1, index2) { var Network_Sorting;
var temp = Networks[index1]; function swap_networks(index1, index2) {
Networks[index1] = Networks[index2];
Networks[index2] = temp;
var table = document.getElementById("network-table"); var temp = Networks[index1];
var temp_row = table.rows[index1+1].innerHTML Networks[index1] = Networks[index2];
table.rows[index1+1].innerHTML = table.rows[index2+1].innerHTML; Networks[index2] = temp;
table.rows[index2+1].innerHTML = temp_row;
}
function invert_networks() { var table = document.getElementById("network-table");
for (let i = 0; Networks.length > i * 2; i++) var temp_row = table.rows[index1+1].innerHTML
swap_networks(i, Networks.length-i-1); table.rows[index1+1].innerHTML = table.rows[index2+1].innerHTML;
} table.rows[index2+1].innerHTML = temp_row;
}
function sort_networks(field) { function invert_networks() {
for (let i = 0; Networks.length > i * 2; i++)
swap_networks(i, Networks.length-i-1);
}
if (Network_Sorting == field) function sort_networks(field) {
return invert_networks();
for (let i = 0; i != Networks.length; i++) if (Network_Sorting == field)
for (let j = i + 1; j != Networks.length; j++) return invert_networks();
if (Networks[j][field] > Networks[i][field])
swap_networks(i, j);
Network_Sorting = field; for (let i = 0; i != Networks.length; i++)
}; for (let j = i + 1; j != Networks.length; j++)
if (Networks[j][field] > Networks[i][field])
swap_networks(i, j);
document.addEventListener('DOMContentLoaded', function () { sort_networks("default"); }, false); Network_Sorting = field;
};
document.addEventListener('DOMContentLoaded', function () { sort_networks("default"); }, false);
</scrpipt>
{% endblock %} {% endblock %}
+63 -186
View File
@@ -1,159 +1,23 @@
{% extends "OpenBench/base.html" %} {% extends "OpenBench/base.html" %}
{% block json %} {% load static %}
{{ config.engines|json_script:"json-engines" }}
{{ networks|json_script:"json-networks" }}
{% endblock %}
{% block scripts %} {% block scripts %}
{{ config|json_script:"json-config" }}
{{ networks|json_script:"json-networks" }}
var engines = JSON.parse(document.getElementById("json-engines" ).textContent); <script src="{% static 'create_test.js' %}"></script>
var networks = JSON.parse(document.getElementById("json-networks").textContent);
function set_test_type() {
//// When the test mode is set or changed, run this.
//// Sets the bounds, confidence intervals, and max games fields.
var selectA = document.getElementById("test_mode");
var mode = selectA.options[selectA.selectedIndex].value;
var selectB = document.getElementById("enginename");
var engine = selectB.options[selectB.selectedIndex].value;
if (mode == "SPRT") {
document.getElementById("test_bounds" ).value = engines[engine].bounds
document.getElementById("test_confidence").value = "{{ config.tests.confidence }}";
document.getElementById("test_max_games" ).value = "N/A";
}
if (mode == "GAMES") {
document.getElementById("test_bounds" ).value = "N/A";
document.getElementById("test_confidence").value = "N/A";
document.getElementById("test_max_games" ).value = "{{ config.tests.max_games }}";
}
}
function set_test_mode(mode_str) {
var selection = document.getElementById("enginename");
var engine = selection.options[selection.selectedIndex].value;
var mode = engines[engine].testmodes[mode_str];
document.getElementById("report_rate" ).value = mode["report_rate"] || 8;
document.getElementById("workload_size").value = mode["workload_size"] || 32;
document.getElementById("devoptions" ).value = mode["options"] || "Threads=1 Hash=8";
document.getElementById("baseoptions" ).value = mode["options"] || "Threads=1 Hash=8";
document.getElementById("timecontrol" ).value = mode["timecontrol"] || "10.0+0.1";
document.getElementById("bookname" ).value = mode["book"] || engines[engine].book;
if (mode["bounds"] != null) {
document.getElementById("test_mode").value = "SPRT"; set_test_type();
document.getElementById("test_bounds").value = mode["bounds"];
}
if (mode["games"] != null) {
document.getElementById("test_mode").value = "GAMES"; set_test_type();
document.getElementById("test_max_games").value = mode["games"];
}
if (mode["bounds"] == null && mode["games"] == null) {
document.getElementById("test_mode").value = "SPRT"; set_test_type();
}
}
function set_engine(engine) {
//// Creates a button to setup test modes, as specififed in the Engine's
//// entry in config.py. Also sets the opening book, and default base branch
//// based on the same config entry. Finally, creates a list of all uploaded
//// Network files that can be selected. The default Network is set as such,
//// if it exists. In all cases, a blank Network is included in the options.
document.getElementById("enginename").value = engine;
var button_div = document.getElementById("test-mode-buttons");
while (button_div.hasChildNodes())
button_div.removeChild(button_div.lastChild);
var index = -1;
for (let mode in engines[engine].testmodes) {
index++;
btn = document.createElement('button')
btn.innerHTML = mode;
btn.onclick = function() { set_test_mode(mode); };
btn.classList.add("anchorbutton");
btn.classList.add("btn-preset");
btn.classList.add("mt-2");
btn.classList.add("w-100");
div = document.createElement('div')
div.appendChild(btn)
div.classList.add("col-half");
if ((index % 4) != 0)
div.classList.add("pl-1");
if ((index % 4) != 3)
div.classList.add("pr-1");
button_div.append(div);
}
var devnet = document.getElementById("devnetwork");
var basenet = document.getElementById("basenetwork");
var hasdefault = false;
while (devnet.length) devnet.remove(0);
while (basenet.length) basenet.remove(0);
for (const network of networks) {
if (network.engine !== engine) continue;
var devopt = document.createElement("option");
var baseopt = document.createElement("option");
devopt.text = baseopt.text = network.name;
devopt.value = baseopt.value = network.sha256;
devopt.selected = network.default;
baseopt.selected = network.default;
devnet.add(devopt); basenet.add(baseopt);
hasdefault = hasdefault || network.default;
}
{
var devopt = document.createElement("option");
var baseopt = document.createElement("option");
devopt.text = baseopt.text = "None";
devopt.value = baseopt.value = "";
devopt.selected = !hasdefault; devnet.add(devopt);
baseopt.selected = !hasdefault; basenet.add(baseopt);
}
document.getElementById("basebranch").value = engines[engine].base;
document.getElementById("bookname" ).value = engines[engine].book;
document.getElementById("win_adj" ).value = engines[engine].win_adj;
document.getElementById("draw_adj" ).value = engines[engine].draw_adj;
set_test_mode("STC");
}
document.addEventListener(
'DOMContentLoaded', function () {
set_test_type();
set_engine("{{ profile.engine }}");
set_test_mode("STC");
}, false
);
<script>
document.addEventListener(
'DOMContentLoaded', function () {
set_test_type();
set_engine("{{ profile.engine }}", "dev");
set_engine("{{ profile.engine }}", "base");
set_test_mode("STC");
}, false
);
</script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@@ -164,76 +28,81 @@
<div class="form w-100"> <div class="form w-100">
<div class="col"> <div class="col">
<h3> Engine </h3> <h3> Engines </h3>
<div class="row"> <div class="row">
<label> Engine </label> <label> Dev Engine </label>
<select id="enginename" name="enginename" onchange="set_engine(value);"> <select id="dev_engine" name="dev_engine" onchange="set_engine(value, 'dev');">
{% for engine in config.engines %} {% for engine in config.engines %}
<option value="{{ engine }}">{{ engine }}</option> <option value="{{ engine }}">{{ engine }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="row"> <div class="row">
<label> Source </label> <input value="{{ profile.repo }}" name="source"> <label> Dev Source </label> <input value="{{ profile.repo }}" name="dev_repo">
</div>
<div class="row">
<label> Base Engine </label>
<select id="base_engine" name="base_engine" onchange="set_engine(value, 'base');">
{% for engine in config.engines %}
<option value="{{ engine }}">{{ engine }}</option>
{% endfor %}
</select>
</div>
<div class="row">
<label> Base Source </label> <input value="{{ profile.repo }}" name="base_repo">
</div> </div>
<h3> Dev Settings </h3> <h3> Dev Settings </h3>
<div class="row"> <div class="row">
<label> Dev Bench </label> <input name="devbench"> <label> Dev Branch </label> <input id="dev_branch" name="dev_branch" autofocus>
</div> </div>
<div class="row"> <div class="row">
<label> Dev Branch </label> <input name="devbranch" autofocus> <label> Dev Bench </label> <input value="Autofill" name="dev_bench">
</div> </div>
<div class="row"> <div class="row">
<label> Dev Options </label> <input id="devoptions" name="devoptions"> <label> Dev Network </label> <select id="dev_network" name="dev_network"></select>
</div> </div>
<div class="row"> <div class="row">
<label> Dev Network </label> <select id="devnetwork" name="devnetwork"></select> <label> Dev Options </label> <input id="dev_options" name="dev_options">
</div>
<div class="row">
<label> Dev Time </label> <input id="dev_time_control" name="dev_time_control">
</div> </div>
<h3> Base Settings </h3> <h3> Base Settings </h3>
<div class="row"> <div class="row">
<label> Base Bench </label> <input name="basebench"> <label> Base Branch </label> <input id="base_branch" name="base_branch">
</div> </div>
<div class="row"> <div class="row">
<label> Base Branch </label> <input id="basebranch" name="basebranch"> <label> Base Bench </label> <input value="Autofill" name="base_bench">
</div> </div>
<div class="row"> <div class="row">
<label> Base Options </label> <input id="baseoptions" name="baseoptions"> <label> Base Network </label> <select id="base_network" name="base_network"></select>
</div> </div>
<div class="row"> <div class="row">
<label> Base Network </label> <select id="basenetwork" name="basenetwork"></select> <label> Base Options </label> <input id="base_options" name="base_options">
</div>
<div class="row">
<label> Base Time </label> <input id="base_time_control" name="base_time_control">
</div> </div>
<h3> Workload Settings </h3>
<div class="row">
<label> Report Rate </label> <input id="report_rate" name="report_rate">
</div>
<div class="row">
<label> Workload Size </label> <input id="workload_size" name="workload_size">
</div>
</div> </div>
<div class="col"> <div class="col">
<h3> Game Settings </h3> <h3> Test Settings </h3>
<div class="row"> <div class="row">
<label> Book </label> <select id="bookname" name="bookname"> <label> Opening Book </label> <select id="book_name" name="book_name">
{% for name, data in config.books.items %} {% for name, data in config.books.items %}
<option value="{{ name }}">{{ name }}</option> <option value="{{ name }}">{{ name }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="row">
<label> Time </label> <input id="timecontrol" name="timecontrol">
</div>
<h3> Test Settings </h3>
<div class="row"> <div class="row">
<label> Test Mode </label> <label> Test Mode </label>
<select onchange='set_test_type()' id="test_mode" name="test_mode"> <select onchange='set_test_type()' id="test_mode" name="test_mode">
@@ -242,16 +111,15 @@
</select> </select>
</div> </div>
<div class="row"> <div class="row">
<label> Bounds </label> <input id="test_bounds" name="bounds"> <label> Bounds </label> <input id="test_bounds" name="test_bounds">
</div> </div>
<div class="row"> <div class="row">
<label> Confidence </label> <input id="test_confidence" name="confidence"> <label> Confidence </label> <input id="test_confidence" name="test_confidence">
</div> </div>
<div class="row"> <div class="row">
<label> Max Games </label> <input id="test_max_games" name="max_games"> <label> Max Games </label> <input id="test_max_games" name="test_max_games">
</div> </div>
<h3> General Settings </h3> <h3> General Settings </h3>
<div class="row"> <div class="row">
<label> Priority </label> <input value="0" name="priority"> <label> Priority </label> <input value="0" name="priority">
@@ -259,12 +127,21 @@
<div class="row"> <div class="row">
<label> Throughput </label> <input value="1000" id="throughput" , name="throughput"> <label> Throughput </label> <input value="1000" id="throughput" , name="throughput">
</div> </div>
<div class="row"> <div class="row">
<label> Syzygy WDL </label> <select name="syzygy_wdl"> <label> Syzygy WDL </label> <select name="syzygy_wdl">
<option value="OPTIONAL"> Optional</option> <option value="OPTIONAL"> Optional</option>
<option value="REQUIRED"> Required</option> <option value="REQUIRED"> Required</option>
<option selected value="DISABLED"> Disabled</option> <option selected value="DISABLED"> Disabled</option>
</select> </select>
</div>
<h3> Workload Settings </h3>
<div class="row">
<label> Report Rate </label> <input id="report_rate" name="report_rate">
</div>
<div class="row">
<label> Workload Size </label> <input id="workload_size" name="workload_size">
</div> </div>
<h3> Adjudication Settings </h3> <h3> Adjudication Settings </h3>
+43 -36
View File
@@ -3,38 +3,41 @@
{% load mytags %} {% load mytags %}
{% block style %} {% block style %}
{% load static %}
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
function copy_statblock() { <script>
var text = document.getElementById("long-statblock").innerHTML; function copy_statblock() {
text = text.replace(/<br>/g, "\n");
text += "\n" + window.location.href;
// navigator.clipboard.writeText(text); // Optimal solution var text = document.getElementById("long-statblock").innerHTML;
text = text.replace(/<br>/g, "\n");
text += "\n" + window.location.href;
// Suboptimal, HTTP solution // navigator.clipboard.writeText(text); // Optimal solution
var area = document.createElement("textarea"); // Suboptimal, HTTP solution
area.value = text;
document.body.append(area);
area.focus(); var area = document.createElement("textarea");
area.select(); area.value = text;
document.body.append(area);
try { area.focus();
document.execCommand("copy"); area.select();
document.body.removeChild(area);
try {
document.execCommand("copy");
document.body.removeChild(area);
}
catch (err) {
document.body.removeChild(area);
console.error("Unable to copy to Clipboard");
}
} }
catch (err) { </script>
document.body.removeChild(area);
console.error("Unable to copy to Clipboard");
}
}
{% endblock %} {% endblock %}
@@ -44,29 +47,33 @@
<table class="test-config left-align wrappable" style="table-layout: auto; width: 100%;"> <table class="test-config left-align wrappable" style="table-layout: auto; width: 100%;">
<tr><td class="td-label">Author</td><td>{{test.author|capfirst}}</td></tr> <tr><td class="td-label">Author</td><td>{{test.author|capfirst}}</td></tr>
<tr><td class="td-label">Creation</td><td class="timestamp">{{test.creation|date:'U'}}</td></tr> <tr><td class="td-label">Creation</td><td class="timestamp">{{test.creation|date:'U'}}</td></tr>
<tr><td class="td-label">Engine</td><td>{{test.engine}}</td></tr>
<tr><td class="td-label">Dev Engine</td><td>{{test.dev_engine}}</td></tr>
<tr><td class="td-label">Dev Source</td><td><a href="{{test.dev_repo}}">{{test.dev_repo}}</a></td></tr>
<tr><td class="td-label">Dev Sha</td><td>{{test.dev.sha}}</td></tr>
<tr><td class="td-label">Dev Branch</td><td>{{test.dev.name|prettyName}}</td></tr> <tr><td class="td-label">Dev Branch</td><td>{{test.dev.name|prettyName}}</td></tr>
<tr><td class="td-label">Dev Bench</td><td>{{test.dev.bench}}</td></tr> <tr><td class="td-label">Dev Bench</td><td>{{test.dev.bench}}</td></tr>
<tr><td class="td-label">Dev Options</td><td>{{test.devoptions}}</td></tr> {% if test.dev_network %}
<tr><td class="td-label">Dev Sha</td><td>{{test.dev.sha}}</td></tr>
{% if test.devnetwork %}
<tr> <tr>
<td class="td-label">Dev Network</td> <td class="td-label">Dev Network</td>
<td><a href="{{test.devnetwork|resolveNetworkURL}}">{{test.devnetname}}</td> <td><a href="{{test.devnetwork|resolveNetworkURL}}">{{test.dev_netname}}</td>
</tr> </tr> {% endif %}
{% endif %} <tr><td class="td-label">Dev Options</td><td>{{test.dev_options}}</td></tr>
<tr><td class="td-label">Base Branch</td><td>{{test.base.name|prettyName}}</td></tr> <tr><td class="td-label">Dev Time</td><td>{{test.dev_time_control}}</td></tr>
<tr><td class="td-label">Base Bench</td><td>{{test.base.bench}}</td></tr>
<tr><td class="td-label">Base Options</td><td>{{test.baseoptions}}</td></tr> <tr><td class="td-label">Base Engine</td><td>{{test.base_engine}}</td></tr>
<tr><td class="td-label">Base Source</td><td><a href="{{test.base_repo}}">{{test.base_repo}}</a></td></tr>
<tr><td class="td-label">Base Sha</td><td>{{test.base.sha}}</td></tr> <tr><td class="td-label">Base Sha</td><td>{{test.base.sha}}</td></tr>
{% if test.basenetwork %} <tr><td class="td-label">Base Bench</td><td>{{test.base.bench}}</td></tr>
{% if test.base_network %}
<tr> <tr>
<td class="td-label">Base Network</td> <td class="td-label">Base Network</td>
<td><a href="{{test.basenetwork|resolveNetworkURL}}">{{test.basenetname}}</td> <td><a href="{{test.basenetwork|resolveNetworkURL}}">{{test.base_netname}}</td>
</tr> </tr> {% endif %}
{% endif %} <tr><td class="td-label">Base Options</td><td>{{test.base_options}}</td></tr>
<tr><td class="td-label">Source Repo</td><td><a href="{{test.source}}">{{test.source}}</a></td></tr> <tr><td class="td-label">Base Time</td><td>{{test.base_time_control}}</td></tr>
<tr><td class="td-label">Opening Book</td><td><a href="{{config.framework}}raw/master/Books/{{test.bookname}}.zip">{{test.bookname}}</a></td></tr>
<tr><td class="td-label">Opening Book</td><td><a href="{{config.framework}}raw/master/Books/{{test.bookname}}.zip">{{test.book_name}}</a></td></tr>
<tr><td class="td-label">Syzygy WDL</td><td>{{test.syzygy_wdl}}</td></tr> <tr><td class="td-label">Syzygy WDL</td><td>{{test.syzygy_wdl}}</td></tr>
<tr><td class="td-label">Syzygy ADJ.</td><td>{{test.syzygy_adj}}</td></tr> <tr><td class="td-label">Syzygy ADJ.</td><td>{{test.syzygy_adj}}</td></tr>
<tr><td class="td-label">Win ADJ.</td><td>{{test.win_adj}}</td></tr> <tr><td class="td-label">Win ADJ.</td><td>{{test.win_adj}}</td></tr>