speedups + llr history graph z-index fix
This commit is contained in:
1 parent
4e8c6c9423
commit
8bb8bd421b
12 files changed
+406
-69
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
import OpenBench.utils
|
||||
from OpenBench.models import Test
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
help = 'Build compact LLR history caches for SPRT tests'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--force',
|
||||
action='store_true',
|
||||
help='Rebuild compact caches even when they already look fresh',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
rebuilt = 0
|
||||
skipped = 0
|
||||
missing = 0
|
||||
|
||||
tests = Test.objects.filter(test_mode='SPRT').order_by('id')
|
||||
|
||||
for test in tests:
|
||||
history_path = OpenBench.utils.llr_history_path(test.id)
|
||||
if not os.path.exists(history_path):
|
||||
missing += 1
|
||||
continue
|
||||
|
||||
if not options['force'] and OpenBench.utils.has_fresh_compact_llr_history(test):
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
history = OpenBench.utils.load_llr_history(test)
|
||||
OpenBench.utils.write_compact_llr_history(test, history)
|
||||
rebuilt += 1
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
'LLR compact cache complete: rebuilt %d, skipped %d, missing %d'
|
||||
% (rebuilt, skipped, missing)
|
||||
)
|
||||
)
|
||||
@@ -121,4 +121,4 @@
|
||||
|
||||
#content #engines-container span input {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
@@ -313,9 +313,14 @@ body, html, main{
|
||||
margin: 0.5rem 0 0.75rem;
|
||||
}
|
||||
|
||||
#content .llr-history-loader {
|
||||
width: 372px;
|
||||
}
|
||||
|
||||
#content .llr-history-widget {
|
||||
position: relative;
|
||||
width: 372px;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
#content .llr-history-chart {
|
||||
@@ -343,6 +348,25 @@ body, html, main{
|
||||
|
||||
#content .llr-history-plot {
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
#content .llr-history-placeholder {
|
||||
width: 320px;
|
||||
height: 112px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #4C566A;
|
||||
background: linear-gradient(135deg, #242933 0%, #2C3440 100%);
|
||||
color: #A7B1C2;
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
#content .llr-history-placeholder-error {
|
||||
color: #E07A7A;
|
||||
}
|
||||
|
||||
#content .llr-history-label {
|
||||
@@ -455,6 +479,7 @@ body, html, main{
|
||||
transform: translateY(2px);
|
||||
transition: opacity 0.12s ease, transform 0.12s ease;
|
||||
white-space: nowrap;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#content .llr-history-tooltip.active {
|
||||
@@ -547,6 +572,7 @@ td pre {
|
||||
overflow-y: auto;
|
||||
transition: transform cubic-bezier(0.82, 0.08, 0.1, 0.93) 0.3s;
|
||||
transform: translateX(-100%);
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
body.sidebar-open #sidebar {
|
||||
@@ -560,7 +586,7 @@ td pre {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
z-index: 21;
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
|
||||
@@ -583,7 +609,7 @@ td pre {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
#content-header h2 {
|
||||
@@ -618,6 +644,12 @@ td pre {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#content .llr-history-loader,
|
||||
#content .llr-history-widget,
|
||||
#content .llr-history-plot {
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
#content #actions {
|
||||
order: -1;
|
||||
margin: 0 0 1rem 0;
|
||||
|
||||
+5
-2
@@ -29,6 +29,8 @@
|
||||
import math
|
||||
import scipy
|
||||
|
||||
NORMAL_95_PERCENT_Z = 1.959963984540054
|
||||
|
||||
def TrinomialSPRT(results, elo0, elo1):
|
||||
|
||||
# Needs at least 1 Loss, 1 Draw, and 1 Win
|
||||
@@ -80,8 +82,9 @@ def Elo(results):
|
||||
mu = sum((f / div) * results[f] for f in range(len(results))) / N
|
||||
var = sum(((f / div) - mu)**2 * results[f] for f in range(len(results))) / N
|
||||
|
||||
mu_min = mu + scipy.stats.norm.ppf(0.025) * math.sqrt(var) / math.sqrt(N)
|
||||
mu_max = mu + scipy.stats.norm.ppf(0.975) * math.sqrt(var) / math.sqrt(N)
|
||||
delta = NORMAL_95_PERCENT_Z * math.sqrt(var) / math.sqrt(N)
|
||||
mu_min = mu - delta
|
||||
mu_max = mu + delta
|
||||
|
||||
return logistic_elo(mu_min), logistic_elo(mu), logistic_elo(mu_max)
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ urlpatterns = [
|
||||
django.urls.path(r'api/networks/<str:engine>/<str:identifier>/', OpenBench.views.api_network_download),
|
||||
django.urls.path(r'api/buildinfo/', OpenBench.views.api_build_info),
|
||||
django.urls.path(r'api/pgns/<int:pgn_id>/', OpenBench.views.api_pgns),
|
||||
django.urls.path(r'api/test/<int:id>/llr-history/', OpenBench.views.test_llr_history),
|
||||
|
||||
# Redirect anything else to the Index
|
||||
django.urls.path(r'', OpenBench.views.index),
|
||||
|
||||
+114
-30
@@ -133,9 +133,21 @@ def read_git_credentials(engine):
|
||||
def path_join(*args):
|
||||
return "/".join([f.lstrip("/").rstrip("/") for f in args]).rstrip('/')
|
||||
|
||||
LLR_HISTORY_SAMPLE_POINTS = 120
|
||||
|
||||
def llr_history_path(test_id):
|
||||
return os.path.join(MEDIA_ROOT, 'llr_history', '%d.json' % (test_id))
|
||||
|
||||
def llr_history_compact_path(test_id, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
return os.path.join(MEDIA_ROOT, 'llr_history_compact', '%d-%d.json' % (test_id, max_points))
|
||||
|
||||
def write_json_file(path, contents):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
temporary_path = '%s.tmp' % (path)
|
||||
with open(temporary_path, 'w') as fout:
|
||||
json.dump(contents, fout)
|
||||
os.replace(temporary_path, path)
|
||||
|
||||
def load_llr_history(test):
|
||||
|
||||
path = llr_history_path(test.id)
|
||||
@@ -149,30 +161,80 @@ def load_llr_history(test):
|
||||
except Exception:
|
||||
return [[0, 0.0]]
|
||||
|
||||
def interpolate_llr_history(history, max_points=120):
|
||||
def has_fresh_compact_llr_history(test, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
|
||||
if not history:
|
||||
return []
|
||||
compact_path = llr_history_compact_path(test.id, max_points=max_points)
|
||||
full_path = llr_history_path(test.id)
|
||||
|
||||
if not os.path.exists(compact_path):
|
||||
return False
|
||||
|
||||
try:
|
||||
return not os.path.exists(full_path) or os.path.getmtime(compact_path) >= os.path.getmtime(full_path)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def load_compact_llr_history(test, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
|
||||
compact_path = llr_history_compact_path(test.id, max_points=max_points)
|
||||
if not has_fresh_compact_llr_history(test, max_points=max_points):
|
||||
return None
|
||||
|
||||
try:
|
||||
with open(compact_path) as fin:
|
||||
history = json.load(fin)
|
||||
return history if history else [[0, 0.0, False]]
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def normalize_llr_history(history):
|
||||
|
||||
def append_point(points, point):
|
||||
if points and points[-1][0] == point[0]:
|
||||
points[-1] = point
|
||||
else:
|
||||
points.append(point)
|
||||
|
||||
normalized = []
|
||||
for games, llr in sorted(history, key=lambda point: point[0]):
|
||||
ordered = True
|
||||
previous_games = None
|
||||
|
||||
for games, llr in history:
|
||||
point = [int(games), float(llr), False]
|
||||
if normalized and normalized[-1][0] == point[0]:
|
||||
normalized[-1] = point
|
||||
else:
|
||||
normalized.append(point)
|
||||
|
||||
if previous_games is not None and point[0] < previous_games:
|
||||
ordered = False
|
||||
break
|
||||
|
||||
append_point(normalized, point)
|
||||
previous_games = point[0]
|
||||
|
||||
if not ordered:
|
||||
normalized = []
|
||||
for games, llr in sorted(history, key=lambda point: point[0]):
|
||||
append_point(normalized, [int(games), float(llr), False])
|
||||
|
||||
if not normalized or normalized[0][0] != 0:
|
||||
normalized.insert(0, [0, 0.0, False])
|
||||
|
||||
if len(normalized) == 1:
|
||||
return normalized
|
||||
|
||||
def interpolate_llr_history(history, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
|
||||
if not history:
|
||||
return []
|
||||
|
||||
normalized = normalize_llr_history(history)
|
||||
|
||||
if len(normalized) <= max_points:
|
||||
return normalized
|
||||
|
||||
final_games = max(normalized[-1][0], 1)
|
||||
desired_points = min(max_points, max(2, final_games + 1))
|
||||
step = final_games / float(desired_points - 1)
|
||||
source_index = 0
|
||||
estimated = []
|
||||
exact_points = { games : llr for games, llr, _ in normalized }
|
||||
sampled = {}
|
||||
|
||||
for index in range(desired_points):
|
||||
target_games = final_games if index == desired_points - 1 else index * step
|
||||
@@ -193,18 +255,36 @@ def interpolate_llr_history(history, max_points=120):
|
||||
llr = left[1] + ratio * (right[1] - left[1])
|
||||
|
||||
display_games = int(round(target_games))
|
||||
estimated.append([display_games, round(llr, 4), True])
|
||||
exact_llr = exact_points.get(display_games)
|
||||
sampled[display_games] = [
|
||||
display_games,
|
||||
round(exact_llr if exact_llr is not None else llr, 4),
|
||||
exact_llr is None,
|
||||
]
|
||||
|
||||
merged = {}
|
||||
for games, llr, is_estimated in estimated + normalized:
|
||||
existing = merged.get(games)
|
||||
if existing is None or (existing[2] and not is_estimated):
|
||||
merged[games] = [games, llr, is_estimated]
|
||||
sampled[normalized[0][0]] = normalized[0]
|
||||
sampled[normalized[-1][0]] = normalized[-1]
|
||||
|
||||
return [merged[key] for key in sorted(merged.keys())]
|
||||
return [sampled[key] for key in sorted(sampled.keys())]
|
||||
|
||||
def get_llr_history(test, max_points=120):
|
||||
return interpolate_llr_history(load_llr_history(test), max_points=max_points)
|
||||
def write_compact_llr_history(test, history, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
compact_history = interpolate_llr_history(history, max_points=max_points)
|
||||
write_json_file(llr_history_compact_path(test.id, max_points=max_points), compact_history)
|
||||
return compact_history
|
||||
|
||||
def get_llr_history(test, max_points=LLR_HISTORY_SAMPLE_POINTS):
|
||||
cached_history = load_compact_llr_history(test, max_points=max_points)
|
||||
if cached_history is not None:
|
||||
return cached_history
|
||||
|
||||
compact_history = interpolate_llr_history(load_llr_history(test), max_points=max_points)
|
||||
|
||||
try:
|
||||
write_json_file(llr_history_compact_path(test.id, max_points=max_points), compact_history)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return compact_history
|
||||
|
||||
def extract_option(options, option):
|
||||
|
||||
@@ -221,25 +301,25 @@ def extract_option(options, option):
|
||||
|
||||
|
||||
def get_pending_tests():
|
||||
t = Test.objects.filter(approved=False)
|
||||
t = Test.objects.select_related('dev', 'base').filter(approved=False)
|
||||
t = t.exclude(finished=True)
|
||||
t = t.exclude(deleted=True)
|
||||
return t.order_by('-creation')
|
||||
|
||||
def get_active_tests():
|
||||
t = Test.objects.filter(approved=True)
|
||||
t = Test.objects.select_related('dev', 'base').filter(approved=True)
|
||||
t = t.exclude(awaiting=True)
|
||||
t = t.exclude(finished=True)
|
||||
t = t.exclude(deleted=True)
|
||||
return t.order_by('-priority', '-currentllr')
|
||||
|
||||
def get_completed_tests():
|
||||
t = Test.objects.filter(finished=True)
|
||||
t = Test.objects.select_related('dev', 'base').filter(finished=True)
|
||||
t = t.exclude(deleted=True)
|
||||
return t.order_by('-updated')
|
||||
|
||||
def get_awaiting_tests():
|
||||
t = Test.objects.filter(awaiting=True)
|
||||
t = Test.objects.select_related('dev', 'base').filter(awaiting=True)
|
||||
t = t.exclude(finished=True)
|
||||
t = t.exclude(deleted=True)
|
||||
return t.order_by('-creation')
|
||||
@@ -249,7 +329,7 @@ def getRecentMachines(minutes=5):
|
||||
target = datetime.datetime.utcnow()
|
||||
target = target.replace(tzinfo=timezone.utc)
|
||||
target = target - datetime.timedelta(minutes=minutes)
|
||||
return Machine.objects.filter(updated__gte=target)
|
||||
return Machine.objects.select_related('user').filter(updated__gte=target)
|
||||
|
||||
def getMachineStatus(username=None):
|
||||
|
||||
@@ -258,6 +338,7 @@ def getMachineStatus(username=None):
|
||||
if username != None:
|
||||
machines = machines.filter(user__username=username)
|
||||
|
||||
machines = list(machines)
|
||||
return ": {0} Machines / ".format(len(machines)) + \
|
||||
"{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))
|
||||
@@ -265,8 +346,9 @@ def getMachineStatus(username=None):
|
||||
def getPaging(content, page, url, pagelen=25):
|
||||
|
||||
start = max(0, pagelen * (page - 1))
|
||||
end = min(content.count(), pagelen * page)
|
||||
count = 1 + math.ceil(content.count() / pagelen)
|
||||
total = content.count()
|
||||
end = min(total, pagelen * page)
|
||||
count = 1 + math.ceil(total / pagelen)
|
||||
|
||||
part1 = list(range(1, min(4, count)))
|
||||
part2 = list(range(page - 2, page + 1))
|
||||
@@ -596,7 +678,9 @@ def record_llr_history(test):
|
||||
if not history or history[0][0] != 0:
|
||||
history.insert(0, [0, 0.0])
|
||||
|
||||
path = llr_history_path(test.id)
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, 'w') as fout:
|
||||
json.dump(history, fout)
|
||||
write_json_file(llr_history_path(test.id), history)
|
||||
|
||||
try:
|
||||
write_compact_llr_history(test, history)
|
||||
except Exception:
|
||||
pass
|
||||
+66
-13
@@ -76,13 +76,13 @@ def render(request, template, content={}, always_allow=False, error=None, warnin
|
||||
|
||||
if request.user.is_authenticated:
|
||||
|
||||
profile = Profile.objects.filter(user=request.user)
|
||||
data.update({'profile' : profile.first()})
|
||||
profile = Profile.objects.select_related('user').filter(user=request.user).first()
|
||||
data.update({'profile' : profile})
|
||||
|
||||
if profile.first() and not profile.first().enabled:
|
||||
if profile and not profile.enabled:
|
||||
request.session['error_message'] = ERROR_MESSAGES['disabled']
|
||||
|
||||
elif request.user.is_authenticated and not profile.first():
|
||||
elif request.user.is_authenticated and not profile:
|
||||
request.session['error_message'] = ERROR_MESSAGES['fakeuser']
|
||||
|
||||
if error:
|
||||
@@ -314,7 +314,7 @@ def search(request):
|
||||
if request.method == 'GET':
|
||||
return render(request, 'search.html', {})
|
||||
|
||||
tests = Test.objects.all()
|
||||
tests = Test.objects.select_related('dev', 'base').all()
|
||||
|
||||
# Optional Selection box filters
|
||||
|
||||
@@ -417,7 +417,7 @@ def search(request):
|
||||
|
||||
def users(request):
|
||||
|
||||
data = { 'profiles' : Profile.objects.order_by('-games', '-tests') }
|
||||
data = { 'profiles' : Profile.objects.select_related('user').order_by('-games', '-tests') }
|
||||
return render(request, 'users.html', data)
|
||||
|
||||
def event(request, id):
|
||||
@@ -432,26 +432,64 @@ def events_actions(request, page=1):
|
||||
|
||||
events = LogEvent.objects.all().filter(machine_id=0).order_by('-id')
|
||||
start, end, paging = OpenBench.utils.getPaging(events, page, 'events')
|
||||
events = list(events[start:end])
|
||||
preload_event_tests(events)
|
||||
|
||||
data = { 'events' : events[start:end], 'paging' : paging };
|
||||
data = { 'events' : events, 'paging' : paging };
|
||||
return render(request, 'events.html', data)
|
||||
|
||||
def events_errors(request, page=1):
|
||||
|
||||
events = LogEvent.objects.all().exclude(machine_id=0).order_by('-id')
|
||||
start, end, paging = OpenBench.utils.getPaging(events, page, 'errors')
|
||||
events = list(events[start:end])
|
||||
preload_event_tests(events)
|
||||
|
||||
data = { 'events' : events[start:end], 'paging' : paging };
|
||||
data = { 'events' : events, 'paging' : paging };
|
||||
return render(request, 'errors.html', data)
|
||||
|
||||
def preload_event_tests(events):
|
||||
|
||||
test_ids = { event.test_id for event in events if event.test_id }
|
||||
tests = {
|
||||
test.id : test
|
||||
for test in Test.objects.select_related('dev').filter(id__in=test_ids)
|
||||
}
|
||||
|
||||
for event in events:
|
||||
event.test_name = str(event.test_id)
|
||||
event.test_time_control = ''
|
||||
|
||||
test = tests.get(event.test_id)
|
||||
if not test:
|
||||
continue
|
||||
|
||||
event.test_name = test.dev.name[:16].upper() if re.search('^[0-9a-fA-F]{40}$', test.dev.name) else test.dev.name
|
||||
event.test_time_control = test.dev_time_control
|
||||
|
||||
def machines(request, machineid=None):
|
||||
|
||||
if machineid == None:
|
||||
data = { 'machines' : OpenBench.utils.getRecentMachines() }
|
||||
machines = list(OpenBench.utils.getRecentMachines())
|
||||
workload_ids = [machine.workload for machine in machines if machine.workload]
|
||||
workloads = {
|
||||
workload.id : workload
|
||||
for workload in Test.objects.select_related('dev').filter(id__in=workload_ids)
|
||||
}
|
||||
|
||||
for machine in machines:
|
||||
workload = workloads.get(machine.workload)
|
||||
machine.workload_url = '/%s/%d/' % (
|
||||
'tune' if workload and workload.test_mode == 'SPSA' else 'test',
|
||||
machine.workload
|
||||
) if workload else None
|
||||
machine.workload_name = workload.dev.name[:16].lower() if workload and re.search('^[0-9a-fA-F]{40}$', workload.dev.name) else (workload.dev.name if workload else None)
|
||||
|
||||
data = { 'machines' : machines }
|
||||
return render(request, 'machines.html', data)
|
||||
|
||||
try:
|
||||
data = { 'machine' : OpenBench.models.Machine.objects.get(id=machineid) }
|
||||
data = { 'machine' : OpenBench.models.Machine.objects.select_related('user').get(id=machineid) }
|
||||
return render(request, 'machine.html', data)
|
||||
|
||||
except:
|
||||
@@ -469,7 +507,7 @@ def test(request, id, action=None):
|
||||
return modify_workload(request, id, action)
|
||||
|
||||
# Verify that the Test id exists
|
||||
if not (test := Test.objects.filter(id=id).first()):
|
||||
if not (test := Test.objects.select_related('dev', 'base').filter(id=id).first()):
|
||||
return redirect(request, '/index/', error='No such Test exists')
|
||||
|
||||
# Verify that it is indeed a Test and not a Tune
|
||||
@@ -489,7 +527,7 @@ def tune(request, id, action=None):
|
||||
return modify_workload(request, id, action)
|
||||
|
||||
# Verify that the Tune id exists
|
||||
if not (tune := Test.objects.filter(id=id).first()):
|
||||
if not (tune := Test.objects.select_related('dev', 'base').filter(id=id).first()):
|
||||
return redirect(request, '/index/', error='No such Tune exists')
|
||||
|
||||
# Verify that it is indeed a Tune and not a Test
|
||||
@@ -509,7 +547,7 @@ def datagen(request, id, action=None):
|
||||
return modify_workload(request, id, action)
|
||||
|
||||
# Verify that the Datagen id exists
|
||||
if not (datagen := Test.objects.filter(id=id).first()):
|
||||
if not (datagen := Test.objects.select_related('dev', 'base').filter(id=id).first()):
|
||||
return redirect(request, '/index/', error='No such Datagen exists')
|
||||
|
||||
# Verify that it is indeed a Datagen and not a Tune
|
||||
@@ -522,6 +560,21 @@ def datagen(request, id, action=None):
|
||||
|
||||
return view_workload(request, datagen, 'DATAGEN')
|
||||
|
||||
def test_llr_history(request, id):
|
||||
|
||||
if OPENBENCH_CONFIG['require_login_to_view'] and not request.user.is_authenticated:
|
||||
return HttpResponse(status=403)
|
||||
|
||||
if not (test := Test.objects.filter(id=id).first()):
|
||||
return HttpResponse(status=404)
|
||||
|
||||
if test.test_mode != 'SPRT':
|
||||
return HttpResponse(status=204)
|
||||
|
||||
from OpenBench.templatetags.mytags import llr_history_graph
|
||||
|
||||
return HttpResponse(str(llr_history_graph(test)), content_type='text/plain; charset=utf-8')
|
||||
|
||||
def create_test(request):
|
||||
return create_workload(request, 'TEST')
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
# A Workload can be a "DATAGEN", which is a Data Generation session
|
||||
|
||||
import datetime
|
||||
import OpenBench.config
|
||||
import OpenBench.views
|
||||
|
||||
from django.utils import timezone
|
||||
@@ -38,11 +39,36 @@ def view_workload(request, workload, workload_type):
|
||||
data = {
|
||||
'workload' : workload,
|
||||
'results' : [],
|
||||
'dev_network_url' : '/networks/%s/' % (workload.dev_engine),
|
||||
'base_network_url' : '/networks/%s/' % (workload.base_engine),
|
||||
}
|
||||
|
||||
for result in Result.objects.filter(test=workload):
|
||||
for result in Result.objects.select_related('machine__user').filter(test=workload):
|
||||
data['results'].append({ 'data' : result, 'active' : is_active(result) })
|
||||
|
||||
network_pairs = set()
|
||||
if workload.dev_network:
|
||||
network_pairs.add((workload.dev_engine, workload.dev_network))
|
||||
if workload.base_network:
|
||||
network_pairs.add((workload.base_engine, workload.base_network))
|
||||
|
||||
if network_pairs:
|
||||
engines = [engine for engine, _ in network_pairs]
|
||||
shas = [sha for _, sha in network_pairs]
|
||||
existing_networks = set(Network.objects.filter(engine__in=engines, sha256__in=shas).values_list('engine', 'sha256'))
|
||||
|
||||
if (workload.dev_engine, workload.dev_network) in existing_networks:
|
||||
data['dev_network_url'] = '/networks/%s/download/%s/' % (workload.dev_engine, workload.dev_network)
|
||||
|
||||
if (workload.base_engine, workload.base_network) in existing_networks:
|
||||
data['base_network_url'] = '/networks/%s/download/%s/' % (workload.base_engine, workload.base_network)
|
||||
|
||||
if workload.test_mode == 'SPRT':
|
||||
data['llr_history_endpoint'] = '/api/test/%d/llr-history/' % (workload.id)
|
||||
|
||||
if workload.book_name in OpenBench.config.OPENBENCH_CONFIG['books']:
|
||||
data['book_url'] = OpenBench.config.OPENBENCH_CONFIG['books'][workload.book_name]['source']
|
||||
|
||||
if workload_type == 'TEST':
|
||||
data['type'] = workload_type
|
||||
data['dev_text'] = 'Dev'
|
||||
@@ -64,4 +90,4 @@ def is_active(result):
|
||||
target = target.replace(tzinfo=timezone.utc)
|
||||
target = target - datetime.timedelta(minutes=1)
|
||||
|
||||
return result.test.id == result.machine.workload and result.machine.updated >= target
|
||||
return result.test_id == result.machine.workload and result.machine.updated >= target
|
||||
@@ -1,7 +1,5 @@
|
||||
{% extends "OpenBench/base.html" %}
|
||||
|
||||
{% load mytags %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table class="hoverable">
|
||||
@@ -20,13 +18,13 @@
|
||||
<td class="timestamp">{{event.created|date:'U'}}</td>
|
||||
<td><a href="/machines/{{event.machine_id}}">{{event.machine_id}}</a></td>
|
||||
<td>{{event.author|capfirst}}</td>
|
||||
<td><a href="/test/{{event.test_id}}">{{event.test_id|testIdToPrettyName}}</a></td>
|
||||
<td><a href="/test/{{event.test_id}}">{{event.test_name}}</a></td>
|
||||
<td>{{event.summary}}</td>
|
||||
<td>{% if event.log_file %}<a href='/event/{{event.id}}'>View</a>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
<table>
|
||||
</table>
|
||||
|
||||
{% include "OpenBench/Blocks/pagebrowser.html" %}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
{% extends "OpenBench/base.html" %}
|
||||
|
||||
{% load mytags %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table class="hoverable">
|
||||
@@ -18,13 +16,13 @@
|
||||
<tr>
|
||||
<td class="timestamp">{{event.created|date:'U'}}</td>
|
||||
<td>{{event.author|capfirst}}</td>
|
||||
<td><a href="/test/{{event.test_id}}">{{event.test_id|testIdToPrettyName}}</a></td>
|
||||
<td>{{event.test_id|testIdToTimeControl}}</td>
|
||||
<td><a href="/test/{{event.test_id}}">{{event.test_name}}</a></td>
|
||||
<td>{{event.test_time_control}}</td>
|
||||
<td>{{event.summary}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
<table>
|
||||
</table>
|
||||
|
||||
{% include "OpenBench/Blocks/pagebrowser.html" %}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<td>{{machine.info.machine_name}}</td>
|
||||
<td>{{machine.info.os_name}}</td>
|
||||
<td>
|
||||
{% if machine.workload %}
|
||||
<a href="{{machine.workload|workload_url}}">
|
||||
{{machine.workload|workload_pretty_name}}
|
||||
{% if machine.workload_url %}
|
||||
<a href="{{machine.workload_url}}">
|
||||
{{machine.workload_name}}
|
||||
</a>
|
||||
{% else %}
|
||||
None
|
||||
|
||||
@@ -7,7 +7,13 @@
|
||||
<script src="{% static 'copy_text.js' %}?{{ static_version }}"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.llr-history-widget').forEach(function(widget) {
|
||||
var llrHistoryRequest = null;
|
||||
|
||||
function initializeLlrHistoryWidget(widget) {
|
||||
if (!widget || widget.dataset.initialized === 'true') return;
|
||||
|
||||
widget.dataset.initialized = 'true';
|
||||
|
||||
var history = JSON.parse(widget.dataset.history || '[]');
|
||||
if (!history.length) return;
|
||||
var realPoints = history.filter(function(point) { return !point.estimated; });
|
||||
@@ -104,7 +110,79 @@
|
||||
});
|
||||
|
||||
clearActivePoint();
|
||||
});
|
||||
}
|
||||
|
||||
function initializeLlrHistoryWidgets(root) {
|
||||
(root || document).querySelectorAll('.llr-history-widget').forEach(function(widget) {
|
||||
initializeLlrHistoryWidget(widget);
|
||||
});
|
||||
}
|
||||
|
||||
function ensureLlrHistoryWidget() {
|
||||
var existing = document.querySelector('.llr-history-widget');
|
||||
if (existing) {
|
||||
initializeLlrHistoryWidget(existing);
|
||||
return Promise.resolve(existing);
|
||||
}
|
||||
|
||||
var container = document.getElementById('llr-history-container');
|
||||
if (!container || !container.dataset.historyUrl) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
if (llrHistoryRequest) {
|
||||
return llrHistoryRequest;
|
||||
}
|
||||
|
||||
llrHistoryRequest = fetch(container.dataset.historyUrl, {
|
||||
credentials: 'same-origin'
|
||||
}).then(function(response) {
|
||||
if (!response.ok) {
|
||||
throw new Error('Unable to load history graph');
|
||||
}
|
||||
|
||||
return response.text();
|
||||
}).then(function(markup) {
|
||||
container.innerHTML = markup;
|
||||
container.removeAttribute('data-history-url');
|
||||
|
||||
var widget = container.querySelector('.llr-history-widget');
|
||||
initializeLlrHistoryWidget(widget);
|
||||
llrHistoryRequest = null;
|
||||
return widget;
|
||||
}).catch(function() {
|
||||
container.innerHTML = '<div class="llr-history-placeholder llr-history-placeholder-error">Unable to load history graph.</div>';
|
||||
llrHistoryRequest = null;
|
||||
return null;
|
||||
});
|
||||
|
||||
return llrHistoryRequest;
|
||||
}
|
||||
|
||||
function queueLlrHistoryWidgetLoad() {
|
||||
var container = document.getElementById('llr-history-container');
|
||||
if (!container || !container.dataset.historyUrl) return;
|
||||
|
||||
function requestGraphAfterPaint() {
|
||||
window.requestAnimationFrame(function() {
|
||||
window.requestAnimationFrame(function() {
|
||||
setTimeout(function() {
|
||||
ensureLlrHistoryWidget();
|
||||
}, 250);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
requestGraphAfterPaint();
|
||||
return;
|
||||
}
|
||||
|
||||
window.addEventListener('load', requestGraphAfterPaint, { once: true });
|
||||
}
|
||||
|
||||
initializeLlrHistoryWidgets(document);
|
||||
queueLlrHistoryWidgetLoad();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -124,7 +202,7 @@
|
||||
<tr><td class="td-label">{{dev_text}} Sha</td><td>{{workload.dev.sha}}</td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Branch</td><td class="branch_name">{{workload.dev.name|prettyName}}</td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Bench</td><td>{{workload.dev.bench}}</td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Network</td><td><a href="{{workload|network_download_link:'dev'}}">{{workload.dev_netname}}</td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Network</td><td><a href="{{dev_network_url}}">{{workload.dev_netname}}</a></td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Options</td><td>{{workload.dev_options}}</td></tr>
|
||||
<tr><td class="td-label">{{dev_text}} Time</td><td>{{workload.dev_time_control}}</td></tr>
|
||||
|
||||
@@ -134,13 +212,13 @@
|
||||
<tr><td class="td-label">Base Sha</td><td>{{workload.base.sha}}</td></tr>
|
||||
<tr><td class="td-label">Base Branch</td><td class="branch_name">{{workload.base.name|prettyName}}</td></tr>
|
||||
<tr><td class="td-label">Base Bench</td><td>{{workload.base.bench}}</td></tr>
|
||||
<tr><td class="td-label">Base Network</td><td><a href="{{workload|network_download_link:'base'}}">{{workload.base_netname}}</td></tr>
|
||||
<tr><td class="td-label">Base Network</td><td><a href="{{base_network_url}}">{{workload.base_netname}}</a></td></tr>
|
||||
<tr><td class="td-label">Base Options</td><td>{{workload.base_options}}</td></tr>
|
||||
<tr><td class="td-label">Base Time</td><td>{{workload.base_time_control}}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if workload|book_download_link %}
|
||||
<tr><td class="td-label">Opening Book</td><td><a href="{{workload|book_download_link}}">{{workload.book_name}}</a></td></tr>
|
||||
{% if book_url %}
|
||||
<tr><td class="td-label">Opening Book</td><td><a href="{{book_url}}">{{workload.book_name}}</a></td></tr>
|
||||
{% else %}
|
||||
<tr><td class="td-label">Opening Book</td><td><a>{{workload.book_name}}</a></td></tr>
|
||||
{% endif %}
|
||||
@@ -298,7 +376,25 @@
|
||||
{% if workload.test_mode == "SPRT" %}
|
||||
<div class="llr-history-panel" title="LLR history over the lifetime of the test">
|
||||
<div class="llr-history-label">LLR History</div>
|
||||
{{workload|llr_history_graph}}
|
||||
<div id="llr-history-container" class="llr-history-loader" data-history-url="{{llr_history_endpoint}}">
|
||||
<div class="llr-history-chart">
|
||||
<div class="llr-history-yaxis">
|
||||
<div></div>
|
||||
<div></div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div class="llr-history-main">
|
||||
<div class="llr-history-plot">
|
||||
<div class="llr-history-placeholder">Loading history graph...</div>
|
||||
</div>
|
||||
<div class="llr-history-xaxis">
|
||||
<div>0</div>
|
||||
<div></div>
|
||||
<div>{{workload.games}} g</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user