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:
1 parent
ce3eeef3c2
commit
526588c594
3 files changed
+50
-60
No files matched your search
@@ -402,22 +402,3 @@ if __name__ == "__main__":
|
|||||||
print (response)
|
print (response)
|
||||||
|
|
||||||
sys.exit(0)
|
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)
|
|
||||||
|
|
||||||
+27
-24
@@ -15,27 +15,6 @@ def getSourceLocation(branch, repo):
|
|||||||
except:
|
except:
|
||||||
raise Exception('Unable to find branch ({0})'.format(branch))
|
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):
|
def newEngine(name, source, protocol, sha, bench):
|
||||||
|
|
||||||
# Engine may already exist, which is okay
|
# Engine may already exist, which is okay
|
||||||
@@ -101,7 +80,28 @@ def newTest(request):
|
|||||||
test.save()
|
test.save()
|
||||||
return test
|
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
|
# Get a list of all active tests
|
||||||
tests = Test.objects.filter(finished=False)
|
tests = Test.objects.filter(finished=False)
|
||||||
@@ -128,12 +128,12 @@ def getWorkload(threads):
|
|||||||
threadcnt = max(devthreads, basethreads)
|
threadcnt = max(devthreads, basethreads)
|
||||||
|
|
||||||
# Empty list or higher priority found for workable test
|
# 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
|
highest = test.priority
|
||||||
options = [test]
|
options = [test]
|
||||||
|
|
||||||
# New workable test with the same priority
|
# 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)
|
options.append(test)
|
||||||
|
|
||||||
# Sum of throughputs, for weighted randomness
|
# Sum of throughputs, for weighted randomness
|
||||||
@@ -150,3 +150,6 @@ def getWorkload(threads):
|
|||||||
# Drop the test from selection
|
# Drop the test from selection
|
||||||
target -= options[0].throughput
|
target -= options[0].throughput
|
||||||
options = options[1:]
|
options = options[1:]
|
||||||
|
|
||||||
|
def getResults(machine, test):
|
||||||
|
pass
|
||||||
+23
-17
@@ -355,31 +355,37 @@ def getFiles(request):
|
|||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def getWorkload(request):
|
def getWorkload(request):
|
||||||
|
|
||||||
try: # Attempt to login in user
|
# Attempt to login in user
|
||||||
user = authenticate(
|
try: loginUser(request, authenticate(
|
||||||
username=request.POST['username'],
|
username=request.POST['username'],
|
||||||
password=request.POST['password'])
|
password=request.POST['password']))
|
||||||
loginUser(request, user)
|
except: return HttpResponse('Bad Credentials')
|
||||||
except:
|
|
||||||
return HttpResponse('Bad Credentials')
|
|
||||||
|
|
||||||
try: # Create or fetch the Machine
|
# Create or fetch the Machine
|
||||||
machine = OpenBench.utils.verifyMachine(
|
try: machine = OpenBench.utils.getMachine(
|
||||||
request.POST['machineid'],
|
request.POST['machineid'],
|
||||||
request.POST['username'],
|
request.POST['username'],
|
||||||
request.POST['osname'],
|
request.POST['osname'],
|
||||||
request.POST['threads'])
|
request.POST['threads'])
|
||||||
except:
|
except: return HttpResponse('Bad Machine')
|
||||||
return HttpResponse('Bad Machine')
|
|
||||||
|
|
||||||
try: # Find an active Test to work on
|
# Find an active Test to work on
|
||||||
test = OpenBench.utils.getWorkload(machine.threads)
|
try: test = OpenBench.utils.getWorkload(machine)
|
||||||
except:
|
except: return HttpResponse('None')
|
||||||
return HttpResponse('None')
|
|
||||||
|
|
||||||
print(user)
|
# Create or fetch the Results
|
||||||
print(machine)
|
try: results = OpenBench.utils.getResults(machine, test)
|
||||||
print(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
|
@csrf_exempt
|
||||||
def submitResults(request):
|
def submitResults(request):
|
||||||
|
|||||||
Reference in new issue
Block a user