Merge pull request #140 from AndyGrant/client_cleanup

Collection of massive breaking changes
This commit is contained in:
Andrew Grant authored and GitHub committed 2023-06-26 07:32:48 -04:00
commit 0c1d539279
27 files changed
+812 -685

No files matched your search

+650 -573
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["gcc"],
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["cargo>=1.57.0"],
"cpuflags" : [ "AVX2", "FMA", "POPCNT"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["clang", "gcc"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["clang", "gcc"],
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["cargo>=1.41.0"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src_files",
"compilers" : ["g++"],
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "build",
"compilers" : ["g++>=9.0.0"],
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["gcc", "clang"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "src",
"compilers" : ["gcc"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["clang++", "g++"],
"cpuflags" : ["POPCNT"]
"cpuflags" : ["POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+2 -1
View File
@@ -12,7 +12,8 @@
"build" : {
"path" : "",
"compilers" : ["go"],
"cpuflags" : ["AVX", "POPCNT"]
"cpuflags" : ["AVX", "POPCNT"],
"systems" : ["Windows", "Linux"]
},
"testmodes" : {
+9 -5
View File
@@ -18,12 +18,16 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import json, os.path
import json, os.path, sys
from OpenSite.settings import PROJECT_PATH
def load_json_config(*path):
with open(os.path.join(PROJECT_PATH, *path)) as fin:
return json.load(fin)
try:
with open(os.path.join(PROJECT_PATH, *path)) as fin:
return json.load(fin)
except:
print ('Error reading ', path)
sys.exit()
def load_folder_of_configs(*path):
return {
@@ -38,11 +42,11 @@ REQUIRE_MANUAL_REGISTRATION = False # Disable the public facing registration pag
OPENBENCH_CONFIG = {
# Server Client version control
'client_version' : '9',
'client_version' : '10',
# Generic Error Messages useful to those setting up their own instance
'error' : {
'disabled' : 'Account has not been enabled. Contact andrew@grantnet.us',
'disabled' : 'Account has not been enabled. Contact an Administrator',
'fakeuser' : 'This is not a real OpenBench User. Create an OpenBench account',
'requires_login' : 'All pages require a user login to access',
'manual_registration' : 'Registration can only be done via an Administrator',
+36 -15
View File
@@ -1,29 +1,46 @@
import django.apps
import threading, time
import requests, sys, threading, time
import OpenBench.utils
from django.core.management.commands.runserver import Command as BaseRunserverCommand
class ArtifactWatcher(threading.Thread):
def check_for_artifacts(self, data):
# Success, if we had all artifacts. Otherwise consider re-running the Workflow
retval, has_all = OpenBench.utils.fetch_artifact_url(*data, return_data=True)
if has_all: return retval, True
# Otherwise, we may have returned the Jobs + Artifacts
jobs, artifacts = retval
# Catch expired artifacts, or a Github API bug and run the Workflow
if all(job['conclusion'] == 'success' for job in jobs):
run_id = jobs[0]['run_id']
url = OpenBench.utils.path_join(data[0], 'actions', 'runs', str(run_id), 'rerun')
requests.post(url=url, headers=data[2]).json()
# We did not have all artifacts needed, return the original source
return data[0], False
def update_test(self, test):
dev_has_all = test.dev.source.endswith('artifacts')
base_has_all = test.base.source.endswith('artifacts')
dev_headers = OpenBench.utils.read_git_credentials(test.dev_engine)
base_headers = OpenBench.utils.read_git_credentials(test.base_engine)
if dev_headers and not dev_has_all:
test.dev.source, dev_has_all = OpenBench.utils.fetch_artifact_url(
test.dev.source, test.dev_engine, dev_headers, test.dev.sha)
# Check for Artifacts for Dev, and re-run if needed
if not (dev_has_all := test.dev.source.endswith('artifacts')):
dev_headers = OpenBench.utils.read_git_credentials(test.dev_engine)
data = [test.dev.source, test.dev_engine, dev_headers, test.dev.sha]
test.dev.source, dev_has_all = self.check_for_artifacts(data)
test.dev.save()
if base_headers and not base_has_all:
test.base.source, base_has_all = OpenBench.utils.fetch_artifact_url(
test.base.source, test.base_engine, base_headers, test.base.sha)
# Check for Artifacts for Base, and re-run if needed
if not (base_has_all := test.base.source.endswith('artifacts')):
base_headers = OpenBench.utils.read_git_credentials(test.base_engine)
data = [test.base.source, test.base_engine, base_headers, test.base.sha]
test.base.source, base_has_all = self.check_for_artifacts(data)
test.base.save()
# If both finished, flag the test as no longer awaiting
if dev_has_all and base_has_all:
test.awaiting = False
test.save()
@@ -31,8 +48,12 @@ class ArtifactWatcher(threading.Thread):
def run(self):
while True:
for test in OpenBench.utils.get_awaiting_tests():
self.update_test(test)
time.sleep(10)
try: self.update_test(test)
except:
import traceback, sys
traceback.print_exc()
sys.stdout.flush()
time.sleep(15)
class Command(BaseRunserverCommand):
+8 -6
View File
@@ -49,12 +49,14 @@ class Profile(Model):
class Machine(Model):
user = ForeignKey(User, PROTECT, related_name='owner')
mnps = FloatField(default=0.00)
updated = DateTimeField(auto_now=True)
secret = CharField(max_length=64, default='None')
info = JSONField()
workload = IntegerField(default=0)
user = ForeignKey(User, PROTECT, related_name='owner')
mnps = FloatField(default=0.00)
dev_mnps = FloatField(default=0.00)
base_mnps = FloatField(default=0.00)
updated = DateTimeField(auto_now=True)
secret = CharField(max_length=64, default='None')
info = JSONField()
workload = IntegerField(default=0)
def __str__(self):
return '[%d] %s' % (self.id, self.user.username)
+43 -54
View File
@@ -119,36 +119,6 @@ def getMachineStatus(username=None):
"{0} Threads / ".format(sum([f.info['concurrency'] for f in machines])) + \
"{0} MNPS ".format(round(sum([f.info['concurrency'] * f.mnps for f in machines]), 2))
def get_test_context(test):
# Select the Test, and all Result objects attached
results = Result.objects.filter(test=test).order_by('machine_id')
data = { 'test' : test, 'results': {} }
for result in results:
# Insert the Result into the results
if result.machine.id not in data['results'].keys():
data['results'][result.machine.id] = {
'games' : 0, 'wins' : 0, 'losses' : 0,
'draws' : 0, 'timeloss' : 0, 'crashes' : 0,
}
# Always use the latest Time stamp, by virtue of sorting Results
data['results'][result.machine.id]['machine_id'] = result.machine.id
data['results'][result.machine.id]['username' ] = result.machine.user.username
data['results'][result.machine.id]['updated' ] = result.updated
# Sum up all results from a given machine into a single value
data['results'][result.machine.id]['games' ] += result.games
data['results'][result.machine.id]['wins' ] += result.wins
data['results'][result.machine.id]['losses' ] += result.losses
data['results'][result.machine.id]['draws' ] += result.draws
data['results'][result.machine.id]['timeloss' ] += result.timeloss
data['results'][result.machine.id]['crashes' ] += result.crashes
return data
def getPaging(content, page, url, pagelen=25):
start = max(0, pagelen * (page - 1))
@@ -269,6 +239,10 @@ def collect_github_info(request, errors, field):
# Actual branches have to go one layer deeper
elif not bysha: data = data['commit']
# Check that all the data we need going forward is present
assert 'message' in data['commit'] and 'sha' in data
assert private or 'sha' in data['commit']['tree']
except: # Unable to find for whatever reason
errors.append('%s could not be found' % (branch))
return (None, None)
@@ -279,7 +253,7 @@ def collect_github_info(request, errors, field):
return (None, None)
# Public Engines: Construct the .zip download and return everything
if not OPENBENCH_CONFIG['engines'][engine]['private']:
if not private:
treeurl = data['commit']['tree']['sha'] + '.zip'
source = path_join(request.POST['%s_repo' % (field)], 'archive', treeurl)
return (source, branch, data['sha'], bench), True
@@ -292,7 +266,7 @@ def collect_github_info(request, errors, field):
url, has_all = fetch_artifact_url(base, engine, headers, data['sha'])
return (url, branch, data['sha'], bench), has_all
def fetch_artifact_url(base, engine, headers, sha):
def fetch_artifact_url(base, engine, headers, sha, return_data=False):
try:
# Fetch the run id for the openbench workflow for this comment
@@ -300,17 +274,26 @@ def fetch_artifact_url(base, engine, headers, sha):
url += '?head_sha=%s' % (sha)
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
# Fetch information about individual job results
url = path_join(base, 'actions', 'runs', str(run_id), 'jobs')
jobs = requests.get(url=url, headers=headers).json()['jobs']
# Fetch information about individual artifact
url = path_join(base, 'actions', 'runs', str(run_id), 'artifacts')
artifacts = requests.get(url=url, headers=headers).json()['artifacts']
# Verify that all of the artifacts exist and are not expired
available = [ f['name'] for f in artifacts if f['expired'] == False ]
required = OPENBENCH_CONFIG['engines'][engine]['build']['artifacts']
has_all = all(['%s-%s' % (sha, name) in available for name in required])
# All jobs finished, with an associated, non-expired Artifact
error = any(job['conclusion'] != 'success' for job in jobs)
error = error or any(artifact['expired'] for artifact in artifacts)
error = error or len(jobs) != len(artifacts)
# Return the URL iff we found them; otherwise base
return (url if has_all else base, has_all)
# Toss back the data if we care about it
if error and return_data:
return ((jobs, artifacts), False)
# Only set the url if we have everything we need
assert not error
return (url, True)
except Exception as error:
# If anything goes wrong, retry later with the same base URL
@@ -353,8 +336,9 @@ def verify_test_creation(request):
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/')
pattern = r'^https:\/\/github\.com\/[A-Za-z0-9-]+\/[A-Za-z0-9_.-]+\/?$'
try: assert re.match(pattern, request.POST[field])
except: errors.append('Sources must be found on https://github.com/<User>/<Repo>')
def verify_network(field, fieldName):
try:
@@ -390,8 +374,9 @@ def verify_test_creation(request):
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))
candidates = ['OPTIONAL', 'DISABLED', '3-MAN', '4-MAN', '5-MAN', '6-MAN']
try: assert request.POST[field] in candidates
except: errors.append('%s must be in %s' % (field_name, ', '.join(candidates)))
verifications = [
@@ -532,9 +517,11 @@ def get_workload(machine):
if not (tests := get_valid_workloads(machine)):
return {}
# Select from valid workloads and create a Result object
test = select_workload(machine, tests)
result = Result(test=test, machine=machine)
# Select from valid workloads the most needing test
test = select_workload(machine, tests)
try: result = Result.objects.get(test=test, machine=machine)
except: result = Result(test=test, machine=machine)
# Update the Machine's status and save everything
machine.workload = test.id; machine.save(); result.save()
@@ -555,33 +542,33 @@ def get_valid_workloads(machine):
tests = tests.exclude(base_engine=engine)
# Skip tests with unmet Syzygy requirments
if not machine.info['syzygy_wdl']:
tests = tests.exclude(syzygy_adj='REQUIRED')
tests = tests.exclude(syzygy_wdl='REQUIRED')
for K in range(machine.info['syzygy_max'] + 1, 10):
tests = tests.exclude(syzygy_adj='%d-MAN' % (K))
tests = tests.exclude(syzygy_wdl='%d-MAN' % (K))
# Skip tests that would waste available Threads or exceed them
threads = machine.info['concurrency']
ncutechess = machine.info['ncutechesses']
sockets = machine.info['sockets']
hyperthreads = machine.info['physical_cores'] < threads
options = [x for x in tests if
test_maps_onto_thread_count(x, threads, ncutechess, hyperthreads)]
test_maps_onto_thread_count(x, threads, sockets, hyperthreads)]
# Finally refine for tests of the highest priority
if not options: return []
highest_prio = max(options, key=lambda x: x.priority).priority
return [test for test in options if test.priority == highest_prio]
def test_maps_onto_thread_count(test, threads, ncutechess, hyperthreads):
def test_maps_onto_thread_count(test, threads, sockets, hyperthreads):
dev_threads = int(extract_option(test.dev_options, 'Threads'))
base_threads = int(extract_option(test.base_options, '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 / sockets):
return False
# Intentional Thread Imbalance, or real cores, or evenly distributed
return dev_threads != base_threads or not hyperthreads or (threads / ncutechess) % dev_threads == 0
return dev_threads != base_threads or not hyperthreads or (threads / sockets) % dev_threads == 0
def select_workload(machine, tests, variance=0.25):
@@ -638,6 +625,7 @@ def workload_to_dictionary(test, result):
'time_control' : test.dev_time_control,
'nps' : OPENBENCH_CONFIG['engines'][test.dev_engine]['nps'],
'build' : OPENBENCH_CONFIG['engines'][test.dev_engine]['build'],
'private' : OPENBENCH_CONFIG['engines'][test.dev_engine]['private'],
},
'base' : {
@@ -652,6 +640,7 @@ def workload_to_dictionary(test, result):
'time_control' : test.base_time_control,
'nps' : OPENBENCH_CONFIG['engines'][test.base_engine]['nps'],
'build' : OPENBENCH_CONFIG['engines'][test.base_engine]['build'],
'private' : OPENBENCH_CONFIG['engines'][test.base_engine]['private'],
},
},
}
+13 -4
View File
@@ -18,7 +18,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import os, hashlib, datetime, json, secrets, re
import os, hashlib, datetime, json, secrets, sys, re
import django.http
import django.shortcuts
@@ -365,7 +365,8 @@ def test(request, id, action=None):
return django.http.HttpResponseRedirect('/index/')
if action not in ['APPROVE', 'RESTART', 'STOP', 'DELETE', 'MODIFY']:
return render(request, 'test.html', OpenBench.utils.get_test_context(test))
data = { 'test' : test, 'results': Result.objects.filter(test=test) }
return render(request, 'test.html', data)
if not request.user.is_authenticated:
return redirect(request, '/login/', error='Only users may interact with tests')
@@ -590,6 +591,7 @@ def client_get_build_info(request):
data = {}
for engine, config in OPENBENCH_CONFIG['engines'].items():
data[engine] = config['build']
data[engine]['private'] = config['private']
return JsonResponse(data)
@csrf_exempt
@@ -628,6 +630,10 @@ def client_worker_info(request):
if not data['private'] and engine not in machine.info['compilers'].keys():
continue
# Must match the Operating Systems supported by the engine
if machine.info['os_name'] not in data['build']['systems']:
continue
# All requirements are met, and this Machine can play with the given engine
machine.info['supported'].append(engine)
@@ -696,8 +702,11 @@ def client_submit_nps(request):
machine, response = client_verify_worker(request)
if response != None: return response
# Update the NPS counter for the GUI views
machine.mnps = float(request.POST['nps']) / 1e6; machine.save()
# Update the NPS counters for the GUI views
machine.mnps = float(request.POST['nps' ]) / 1e6;
machine.dev_mnps = float(request.POST['dev_nps' ]) / 1e6;
machine.base_mnps = float(request.POST['base_nps']) / 1e6;
machine.save()
# Pass back an empty JSON response
return JsonResponse({})
+12 -6
View File
@@ -132,9 +132,12 @@
<div class="row">
<label> Syzygy WDL </label> <select name="syzygy_wdl">
<option value="OPTIONAL"> Optional</option>
<option value="REQUIRED"> Required</option>
<option selected value="DISABLED"> Disabled</option>
<option selected value="DISABLED"> Disabled </option>
<option value="OPTIONAL"> Optional </option>
<option value="6-MAN"> 6-Man </option>
<option value="5-MAN"> 5-Man </option>
<option value="4-MAN"> 4-Man </option>
<option value="3-MAN"> 3-Man </option>
</select>
</div>
@@ -150,9 +153,12 @@
<div class="row">
<label> Syzygy ADJ. </label>
<select name="syzygy_adj">
<option selected value="OPTIONAL"> Optional</option>
<option value="REQUIRED"> Required</option>
<option value="DISABLED"> Disabled</option>
<option selected value="DISABLED"> Disabled </option>
<option value="OPTIONAL"> Optional </option>
<option value="6-MAN"> 6-Man </option>
<option value="5-MAN"> 5-Man </option>
<option value="4-MAN"> 4-Man </option>
<option value="3-MAN"> 3-Man </option>
</select>
</div>
<div class="row">
+1 -1
View File
@@ -25,7 +25,7 @@
<tr><td class="td-label">Logical Cores</td><td>{{machine.info.logical_cores}}</td></tr>
<tr><td class="td-label">Physical Cores</td><td>{{machine.info.physical_cores}}</td></tr>
<tr><td class="td-label">Total RAM (MB)</td><td>{{machine.info.ram_total_mb}}</td></tr>
<tr><td class="td-label">Syzygy WDL-6</td><td>{{machine.info.syzygy_wdl}}</td></tr>
<tr><td class="td-label">Syzygy WDL</td><td>{{machine.info.syzygy_max}}-Man</td></tr>
<tr><td class="td-label"></td><td><br></td></tr>
+4 -3
View File
@@ -64,6 +64,7 @@
<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 Branch</td><td>{{test.base.name|prettyName}}</td></tr>
<tr><td class="td-label">Base Bench</td><td>{{test.base.bench}}</td></tr>
{% if test.base_network %}
<tr>
@@ -172,10 +173,10 @@
<th style="width: 60px">Crash</th>
</tr>
{% for id, result in results.items %}
{% for result in results %}
<tr>
<td>{{result.machine_id}}</td>
<td>{{result.username|capfirst}}</td>
<td><a href="/machines/{{result.machine.id}}">{{result.machine.id}}</a></td>
<td>{{result.machine.user.username|capfirst}}</td>
<td class="timestamp">{{result.updated|date:'U'}}</td>
<td class="numeric">{{result.games}}</td>
<td class="numeric">{{result.wins}}</td>