Prepare to get a Results() for each machine-test combination.

Need to add back the dictionary() dump for the Client
This commit is contained in:
AndyGrant committed 2018-06-11 01:36:42 -04:00
1 parent ce3eeef3c2
commit 526588c594
3 files changed
+52 -62

No files matched your search

+1 -20
View File
@@ -401,23 +401,4 @@ if __name__ == "__main__":
print (response)
sys.exit(0)
#while True:
# try:
# request = requests.get("{0}/getWorkload/{1}".format(server, cores))
# asstring = request.content.decode("utf-8")
#
# if asstring == "No Workloads":
# time.sleep(60)
#
# else:
# asdictionary = ast.literal_eval(asstring)
# completeWorkload(server, cores, asdictionary)
# time.sleep(1)
#
# except:
# print ("<Error> : ", sys.exc_info()[0])
# time.sleep(10)
sys.exit(0)
+28 -25
View File
@@ -15,27 +15,6 @@ def getSourceLocation(branch, repo):
except:
raise Exception('Unable to find branch ({0})'.format(branch))
def verifyMachine(machineid, username, osname, threads):
# Machine does not exist, make a new one
if machineid == 'None':
machine = Machine()
machine.owner = username
machine.osname = osname
machine.threads = threads
machine.mnps = 0.00
machine.save()
return machine
# Verify the selected machine is the user's
machine = Machine.objects.get(id=machineid)
assert machine.owner == username
assert machine.osname == osname
machine.threads = threads
machine.mnps = 0.00
machine.save()
return machine
def newEngine(name, source, protocol, sha, bench):
# Engine may already exist, which is okay
@@ -101,7 +80,28 @@ def newTest(request):
test.save()
return test
def getWorkload(threads):
def getMachine(machineid, username, osname, threads):
# Machine does not exist, make a new one
if machineid == 'None':
machine = Machine()
machine.owner = username
machine.osname = osname
machine.threads = threads
machine.mnps = 0.00
machine.save()
return machine
# Verify the selected machine is the user's
machine = Machine.objects.get(id=machineid)
assert machine.owner == username
assert machine.osname == osname
machine.threads = threads
machine.mnps = 0.00
machine.save()
return machine
def getWorkload(machine):
# Get a list of all active tests
tests = Test.objects.filter(finished=False)
@@ -128,12 +128,12 @@ def getWorkload(threads):
threadcnt = max(devthreads, basethreads)
# Empty list or higher priority found for workable test
if (options == [] or test.priority > highest) and threadcnt <= threads:
if (options == [] or test.priority > highest) and threadcnt <= machine.threads:
highest = test.priority
options = [test]
# New workable test with the same priority
elif options != [] and test.priority == highest and threadcnt <= threads:
elif options != [] and test.priority == highest and threadcnt <= machine.threads:
options.append(test)
# Sum of throughputs, for weighted randomness
@@ -149,4 +149,7 @@ def getWorkload(threads):
# Drop the test from selection
target -= options[0].throughput
options = options[1:]
options = options[1:]
def getResults(machine, test):
pass
+23 -17
View File
@@ -355,31 +355,37 @@ def getFiles(request):
@csrf_exempt
def getWorkload(request):
try: # Attempt to login in user
user = authenticate(
# Attempt to login in user
try: loginUser(request, authenticate(
username=request.POST['username'],
password=request.POST['password'])
loginUser(request, user)
except:
return HttpResponse('Bad Credentials')
password=request.POST['password']))
except: return HttpResponse('Bad Credentials')
try: # Create or fetch the Machine
machine = OpenBench.utils.verifyMachine(
# Create or fetch the Machine
try: machine = OpenBench.utils.getMachine(
request.POST['machineid'],
request.POST['username'],
request.POST['osname'],
request.POST['threads'])
except:
return HttpResponse('Bad Machine')
except: return HttpResponse('Bad Machine')
try: # Find an active Test to work on
test = OpenBench.utils.getWorkload(machine.threads)
except:
return HttpResponse('None')
# Find an active Test to work on
try: test = OpenBench.utils.getWorkload(machine)
except: return HttpResponse('None')
print(user)
print(machine)
print(test)
# Create or fetch the Results
try: results = OpenBench.utils.getResults(machine, test)
except: return HttpResponse('None')
# Convert everything for the Client
data = {
"machine" : machine.dictionary(),
"test" : test.dictionary(),
"result" : results.dictionary()
}
# Send context as a string0
return HttpResponse(str(data))
@csrf_exempt
def submitResults(request):