Reporting NPS

This commit is contained in:
AndyGrant committed 2018-06-12 00:35:05 -04:00
1 parent dcce521447
commit ab92826282
5 files changed
+50 -16

No files matched your search

+23 -10
View File
@@ -168,22 +168,23 @@ def getCutechessCommand(data, scalefactor):
# Find Threads for the Dev Engine # Find Threads for the Dev Engine
tokens = data['test']['dev']['options'].split(' ') tokens = data['test']['dev']['options'].split(' ')
devthreads = tokens[0].split('=')[1] devthreads = int(tokens[0].split('=')[1])
# Find Threads for the Base Engine # Find Threads for the Base Engine
tokens = data['test']['base']['options'].split(' ') tokens = data['test']['base']['options'].split(' ')
basethreads = tokens[0].split('=')[1] basethreads = int(tokens[0].split('=')[1])
# Finally, output the time control for the user # Finally, output the time control for the user
print ('ORIGINAL :\n', data['test']['timecontrol']), print ('ORIGINAL :', data['test']['timecontrol'])
print ('SCALED :\n', timecontrol) print ('SCALED :', timecontrol)
print ('')
generalFlags = ( generalFlags = (
'-repeat' '-repeat'
' -srand ' + str(int(time.time())) + ' -srand ' + str(int(time.time())) +
' -resign movecount=3 score=400' ' -resign movecount=3 score=400'
' -draw movenumber=40 movecount=8 score=10' ' -draw movenumber=40 movecount=8 score=10'
' -concurrency ' + str(floor(THREADS / max(devthreads, basethreads))) + ' -concurrency ' + str(math.floor(THREADS / max(devthreads, basethreads))) +
' -games 1000' ' -games 1000'
' -recover' ' -recover'
' -wait 10' ' -wait 10'
@@ -229,7 +230,7 @@ def singleCoreBench(name, outqueue):
def getBenchSignature(engine): def getBenchSignature(engine):
print ('Running Benchmark for {0} on {1} cores'.format(engine['name'], THREADS)) print ('\nRunning Benchmark for {0} on {1} cores'.format(engine['name'], THREADS))
# Allow each process to send back completition times # Allow each process to send back completition times
outqueue = multiprocessing.Queue() outqueue = multiprocessing.Queue()
@@ -261,7 +262,7 @@ def getBenchSignature(engine):
def reportWrongBench(data, engine): def reportWrongBench(data, engine):
# Server wants verification for reporting # Server wants verification for reporting wrong benchs
postdata = { postdata = {
'username' : USERNAME, 'username' : USERNAME,
'password' : PASSWORD, 'password' : PASSWORD,
@@ -269,6 +270,16 @@ def reportWrongBench(data, engine):
'testid' : data['test']['id']} 'testid' : data['test']['id']}
requests.post('{0}/wrongBench/'.format(SERVER), data=postdata) requests.post('{0}/wrongBench/'.format(SERVER), data=postdata)
def reportNPS(data, nps):
# Server wants verification for reporting nps counts
postdata = {
'nps' : nps,
'username' : USERNAME,
'password' : PASSWORD,
'machineid' : data['machine']['id']}
requests.post('{0}/submitNPS/'.format(SERVER), data=postdata)
def reportResults(data, wins, losses, draws, crashes, timeloss): def reportResults(data, wins, losses, draws, crashes, timeloss):
pass pass
@@ -297,6 +308,7 @@ def completeWorkload(data):
# Compute and report CPU scaling factor # Compute and report CPU scaling factor
avgnps = (devnps + basenps) / 2.0 avgnps = (devnps + basenps) / 2.0
reportNPS(data, avgnps)
scalefactor = 2650000 / avgnps scalefactor = 2650000 / avgnps
print ('FACTOR : {0}'.format(round(1 / scalefactor, 2))) print ('FACTOR : {0}'.format(round(1 / scalefactor, 2)))
@@ -398,7 +410,8 @@ if __name__ == '__main__':
# Try to complete the workload, rest for a few # Try to complete the workload, rest for a few
# seconds in the event of an error, giving the # seconds in the event of an error, giving the
# server time to correct the mistake ... # server time to correct the mistake ...
try: completeWorkload(data) completeWorkload(data)
except Exception as error:
print ('<WARNING> {0}'.format(error)) #except Exception as error:
# print ('<WARNING> {0}'.format(error))
time.sleep(15) time.sleep(15)
+1
View File
@@ -28,5 +28,6 @@ urlpatterns = [
path(r'getFiles/', OpenBench.views.getFiles), path(r'getFiles/', OpenBench.views.getFiles),
path(r'getWorkload/', OpenBench.views.getWorkload), path(r'getWorkload/', OpenBench.views.getWorkload),
path(r'wrongBench/', OpenBench.views.wrongBench), path(r'wrongBench/', OpenBench.views.wrongBench),
path(r'submitNPS/', OpenBench.views.submitNPS),
path(r'submitResults/', OpenBench.views.submitResults), path(r'submitResults/', OpenBench.views.submitResults),
] ]
+5 -5
View File
@@ -81,7 +81,7 @@ def getMachine(machineid, username, osname, threads):
# Client has no saved machine ID, make a new machine # Client has no saved machine ID, make a new machine
if machineid == 'None': if machineid == 'None':
return Machine.objects.create(owner=username, osname=osname, threads=threads) return Machine.objects.create(owner=username, osname=osname, threads=int(threads))
# Fetch and verify the claimed machine ID # Fetch and verify the claimed machine ID
machine = Machine.objects.get(id=machineid) machine = Machine.objects.get(id=machineid)
@@ -89,7 +89,7 @@ def getMachine(machineid, username, osname, threads):
assert machine.osname == osname assert machine.osname == osname
# Update to reflect new worload # Update to reflect new worload
machine.threads = threads machine.threads = int(threads)
machine.mnps = 0.00 machine.mnps = 0.00
machine.save() machine.save()
return machine return machine
@@ -102,7 +102,7 @@ def getWorkload(machine):
tests = list(tests.filter(approved=True)) tests = list(tests.filter(approved=True))
# No tests, error out and let views handle it # No tests, error out and let views handle it
if len(tests) == 0: raise Exception('ANone') if len(tests) == 0: raise Exception('None')
options = [] # Highest priority with acceptable threads options = [] # Highest priority with acceptable threads
@@ -111,11 +111,11 @@ def getWorkload(machine):
# Find Threads for the Dev Engine # Find Threads for the Dev Engine
tokens = test.devoptions.split(' ') tokens = test.devoptions.split(' ')
devthreads = tokens[0].split('=')[1] devthreads = int(tokens[0].split('=')[1])
# Find Threads for the Base Engine # Find Threads for the Base Engine
tokens = test.baseoptions.split(' ') tokens = test.baseoptions.split(' ')
basethreads = tokens[0].split('=')[1] basethreads = int(tokens[0].split('=')[1])
# Minimum threads to support Dev & Base # Minimum threads to support Dev & Base
threadcnt = max(devthreads, basethreads) threadcnt = max(devthreads, basethreads)
+21 -1
View File
@@ -113,7 +113,7 @@ def index(request, page=0, username=None, error=''):
# Get tests pending approval # Get tests pending approval
pending = Test.objects.filter(approved=False) pending = Test.objects.filter(approved=False)
pending = pending.exclude(finished=False) pending = pending.exclude(finished=True)
pending = pending.exclude(deleted=True) pending = pending.exclude(deleted=True)
pending = pending.order_by('-creation') pending = pending.order_by('-creation')
@@ -383,6 +383,7 @@ def wrongBench(request):
password=request.POST['password'])) password=request.POST['password']))
except: return HttpResponse('Bad Credentials') except: return HttpResponse('Bad Credentials')
try:
# Find the engine with the bad bench # Find the engine with the bad bench
engineid = int(request.POST['engineid']) engineid = int(request.POST['engineid'])
engine = Engine.objects.get(id=engineid) engine = Engine.objects.get(id=engineid)
@@ -398,6 +399,25 @@ def wrongBench(request):
data='Invalid bench for {0} with {1}'.format(str(test), str(engine)), data='Invalid bench for {0} with {1}'.format(str(test), str(engine)),
author=request.POST['username'] author=request.POST['username']
) )
except: pass
return HttpResponse('None')
@csrf_exempt
def submitNPS(request):
# Attempt to login in user
try: loginUser(request, authenticate(
username=request.POST['username'],
password=request.POST['password']))
except: return HttpResponse('Bad Credentials')
# Try to update the NPS for the machine
try:
machine = Machine.objects.get(id=int(request.POST['machineid']))
machine.mnps = float(request.POST['nps']) / 1e6
machine.save()
except: return HttpResponse('Bad Machine ID')
return HttpResponse('None') return HttpResponse('None')
BIN
View File
Binary file not shown.