Initial commit of working progress
This commit is contained in:
1 parent
b0227bc282
commit
6fb21cbd7d
7 files changed
+723
-121
No files matched your search
+69
-28
@@ -29,7 +29,7 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
# Link to the repo on the sidebar, as well as the core files
|
||||
'framework' : 'http://github.com/AndyGrant/OpenBench/',
|
||||
'corefiles' : 'http://github.com/AndyGrant/OpenBench/raw/master/CoreFiles/',
|
||||
'corefiles' : 'http://github.com/AndyGrant/OpenBench/raw/openV2/CoreFiles/',
|
||||
|
||||
# SPRT Elo bounds and type I/II errors
|
||||
'sprt' : { 'elolower' : 0.00, 'eloupper' : 5.00, 'alpha' : 0.05, 'beta' : 0.05 },
|
||||
@@ -44,28 +44,28 @@ OPENBENCH_CONFIG = {
|
||||
'2moves_v1.epd' : {
|
||||
'name' : '2moves_v1.epd',
|
||||
'sha' : '7bec98239836f219dc41944a768c0506abed950aaec48da69a0782643e90f237',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/2moves_v1.epd',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/openV2/Books/2moves_v1.epd.zip',
|
||||
'default' : False,
|
||||
},
|
||||
|
||||
'8moves_v3.epd' : {
|
||||
'name' : '8moves_v3.epd',
|
||||
'sha' : '38d1b6c456bc3d3f69a4927e2667ef3f3fa231e253b6dc4040093f00a1c2ccb3',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/8moves_v3.epd',
|
||||
'sha' : '1f055af431656f09ee6a09d2448e0b876125f78bb7b404fca2031c403a1541e5',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/openV2/Books/8moves_v3.epd.zip',
|
||||
'default' : False,
|
||||
},
|
||||
|
||||
'3moves_FRC.epd' : {
|
||||
'name' : '3moves_FRC.epd',
|
||||
'sha' : '4be746a91e3f8af0c9344b1e72d611e9fcfe486843867a55760970a4896f284d',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/3moves_FRC.epd',
|
||||
'sha' : '38d1b6c456bc3d3f69a4927e2667ef3f3fa231e253b6dc4040093f00a1c2ccb3',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/openV2/Books/3moves_FRC.epd.zip',
|
||||
'default' : False,
|
||||
},
|
||||
|
||||
'4moves_noob.epd' : {
|
||||
'name' : '4moves_noob.epd',
|
||||
'sha' : '1f055af431656f09ee6a09d2448e0b876125f78bb7b404fca2031c403a1541e5',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/4moves_noob.epd',
|
||||
'sha' : '4be746a91e3f8af0c9344b1e72d611e9fcfe486843867a55760970a4896f284d',
|
||||
'source' : 'http://github.com/AndyGrant/OpenBench/raw/openV2/Books/4moves_noob.epd.zip',
|
||||
'default' : True,
|
||||
},
|
||||
},
|
||||
@@ -79,11 +79,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Ethereal' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 1075000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['gcc'] },
|
||||
'source' : 'https://github.com/AndyGrant/Ethereal',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['gcc'],
|
||||
'cpuflags' : ['AVX2', 'AVX', 'FMA', 'POPCNT', 'SSE2', 'SSE'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -94,11 +98,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Laser' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 720000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['g++'] },
|
||||
'source' : 'https://github.com/jeffreyan11/uci-chess-engine',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['g++'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -109,11 +117,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Weiss' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 2400000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['gcc'] },
|
||||
'source' : 'https://github.com/TerjeKir/weiss',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['gcc'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -124,11 +136,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Demolito' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 1075000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['clang', 'gcc'] },
|
||||
'source' : 'https://github.com/lucasart/Demolito',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['clang', 'gcc'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '8.0+0.08' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '32.0+0.32'},
|
||||
@@ -139,11 +155,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'RubiChess' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 1500000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['g++'] },
|
||||
'source' : 'https://github.com/Matthies/RubiChess',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['g++'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -154,11 +174,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'FabChess' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 640000,
|
||||
'build' : { 'path' : '', 'compilers' : ['cargo>=1.41.0'] },
|
||||
'source' : 'https://github.com/fabianvdW/FabChess',
|
||||
|
||||
'build' : {
|
||||
'path' : '',
|
||||
'compilers' : ['cargo>=1.41.0'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -169,11 +193,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Igel' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 475000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['g++'] },
|
||||
'source' : 'https://github.com/vshcherbyna/igel',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['g++'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -184,11 +212,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Winter' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 380000,
|
||||
'build' : { 'path' : '/', 'compilers' : ['clang++', 'g++'] },
|
||||
'source' : 'https://github.com/rosenthj/Winter',
|
||||
|
||||
'build' : {
|
||||
'path' : '',
|
||||
'compilers' : ['clang++', 'g++'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -199,11 +231,15 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
'Halogen' : {
|
||||
|
||||
'proto' : 'uci',
|
||||
'nps' : 1350000,
|
||||
'build' : { 'path' : '/Halogen/src/', 'compilers' : ['g++'] },
|
||||
'source' : 'https://github.com/KierenP/Halogen',
|
||||
|
||||
'build' : {
|
||||
'path' : 'Halogen/src',
|
||||
'compilers' : ['g++'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
@@ -213,11 +249,16 @@ OPENBENCH_CONFIG = {
|
||||
},
|
||||
|
||||
'Stash' : {
|
||||
'proto' : 'uci',
|
||||
|
||||
'nps' : 1415000,
|
||||
'build' : { 'path' : '/src/', 'compilers' : ['gcc', 'clang'] },
|
||||
'source' : 'https://github.com/mhouppin/stash-bot',
|
||||
|
||||
'build' : {
|
||||
'path' : 'src',
|
||||
'compilers' : ['gcc', 'clang'],
|
||||
'cpuflags' : ['POPCNT'],
|
||||
},
|
||||
|
||||
'testmodes' : {
|
||||
'stc' : { 'threads' : 1, 'hash' : 16, 'timecontrol' : '10.0+0.1' },
|
||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||
|
||||
@@ -27,7 +27,6 @@ class Engine(Model):
|
||||
|
||||
name = CharField(max_length=128)
|
||||
source = CharField(max_length=1024)
|
||||
protocol = CharField(max_length=16)
|
||||
sha = CharField(max_length=64)
|
||||
bench = IntegerField(default=0)
|
||||
|
||||
|
||||
+1
-1
@@ -52,13 +52,13 @@ urlpatterns = [
|
||||
# Links for viewing and managing Networks
|
||||
django.urls.path(r'networks/', OpenBench.views.networks),
|
||||
django.urls.path(r'networks/<str:action>/', OpenBench.views.networks),
|
||||
django.urls.path(r'networks/<str:action>/<str:sha256>', OpenBench.views.networks),
|
||||
django.urls.path(r'networks/<str:action>/<str:sha256>/', OpenBench.views.networks),
|
||||
|
||||
# Links for the Client to work with the Server
|
||||
django.urls.path(r'clientGetFiles/', OpenBench.views.clientGetFiles),
|
||||
django.urls.path(r'clientGetBuildInfo/', OpenBench.views.clientGetBuildInfo),
|
||||
django.urls.path(r'clientGetWorkload/', OpenBench.views.clientGetWorkload),
|
||||
django.urls.path(r'clientGetNetwork/<str:sha256>/', OpenBench.views.clientGetNetwork),
|
||||
django.urls.path(r'clientWrongBench/', OpenBench.views.clientWrongBench),
|
||||
django.urls.path(r'clientSubmitNPS/', OpenBench.views.clientSubmitNPS),
|
||||
django.urls.path(r'clientSubmitError/', OpenBench.views.clientSubmitError),
|
||||
|
||||
+27
-29
@@ -18,7 +18,7 @@
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
import math, re, requests, random, datetime, os
|
||||
import math, re, requests, random, datetime, os, json
|
||||
|
||||
import OpenBench.models, OpenBench.stats
|
||||
|
||||
@@ -112,18 +112,11 @@ def getPaging(content, page, url, pagelen=25):
|
||||
return start, end, context
|
||||
|
||||
|
||||
def getEngine(source, name, sha, bench, protocol):
|
||||
def getEngine(source, name, sha, bench):
|
||||
|
||||
engine = Engine.objects.filter(
|
||||
name=name, source=source,
|
||||
protocol=protocol, sha=sha, bench=bench)
|
||||
|
||||
if engine.first() != None:
|
||||
return engine.first()
|
||||
|
||||
return Engine.objects.create(
|
||||
name=name, source=source,
|
||||
protocol=protocol, sha=sha, bench=bench)
|
||||
engine = Engine.objects.filter(name=name, source=source, sha=sha, bench=bench)
|
||||
if engine.first() != None: return engine.first()
|
||||
return Engine.objects.create(name=name, source=source, sha=sha, bench=bench)
|
||||
|
||||
def getBranch(request, errors, name):
|
||||
|
||||
@@ -236,7 +229,6 @@ def createNewTest(request):
|
||||
|
||||
devinfo = getBranch(request, errors, 'dev')
|
||||
baseinfo = getBranch(request, errors, 'base')
|
||||
protocol = OPENBENCH_CONFIG['engines'][request.POST['enginename']]['proto']
|
||||
if errors != []: return None, errors
|
||||
|
||||
test = Test()
|
||||
@@ -257,8 +249,8 @@ def createNewTest(request):
|
||||
test.beta = float(request.POST['beta'])
|
||||
test.lowerllr = math.log(test.beta / (1.0 - test.alpha))
|
||||
test.upperllr = math.log((1.0 - test.beta) / test.alpha)
|
||||
test.dev = getEngine(*devinfo, protocol)
|
||||
test.base = getEngine(*baseinfo, protocol)
|
||||
test.dev = getEngine(*devinfo)
|
||||
test.base = getEngine(*baseinfo)
|
||||
test.save()
|
||||
|
||||
profile = Profile.objects.get(user=request.user)
|
||||
@@ -306,20 +298,26 @@ def getWorkload(user, request):
|
||||
machine = getMachine(machineid, user, osname, int(threads))
|
||||
if type(machine) == str: return machine
|
||||
|
||||
# Compare supported Machines vs Existing
|
||||
supported = request.POST['supported'].split()
|
||||
existing = OPENBENCH_CONFIG['engines'].keys()
|
||||
|
||||
# Filter only to active tests
|
||||
tests = Test.objects.filter(finished=False)
|
||||
tests = tests.filter(deleted=False)
|
||||
tests = tests.filter(approved=True)
|
||||
|
||||
# Remove tests that this Machine cannot complete
|
||||
for engine in existing:
|
||||
# Filter to compilable engines
|
||||
supported = request.POST['supported'].split()
|
||||
cpuflags = request.POST['cpuflags'].split()
|
||||
|
||||
# Remove tests that this Machine cannot complete (Compile)
|
||||
for engine in OPENBENCH_CONFIG['engines'].keys():
|
||||
if engine not in supported:
|
||||
tests = tests.exclude(engine=engine)
|
||||
|
||||
# Remove tests that this Machine cannot complete (Architecture)
|
||||
for engine, data in OPENBENCH_CONFIG['engines'].items():
|
||||
for flag in data['build']['cpuflags']:
|
||||
if flag not in cpuflags:
|
||||
tests = tests.exclude(engine=engine)
|
||||
|
||||
# If we don't get a Test back, there was an error
|
||||
test = selectWorkload(tests, machine)
|
||||
if type(test) == str: return test
|
||||
@@ -364,7 +362,7 @@ def workloadDictionary(test, result, machine):
|
||||
# The Client must know his Machine ID, his Result ID, and his Test
|
||||
# ID. Also, all information about the Test and the associated engines
|
||||
|
||||
return {
|
||||
return json.dumps({
|
||||
|
||||
'machine' : { 'id' : machine.id },
|
||||
|
||||
@@ -381,19 +379,19 @@ def workloadDictionary(test, result, machine):
|
||||
|
||||
'dev' : {
|
||||
'id' : test.dev.id, 'name' : test.dev.name,
|
||||
'source' : test.dev.source, 'protocol' : test.dev.protocol,
|
||||
'sha' : test.dev.sha, 'bench' : test.dev.bench,
|
||||
'options' : test.devoptions, 'network' : test.devnetwork,
|
||||
'source' : test.dev.source, 'sha' : test.dev.sha,
|
||||
'bench' : test.dev.bench, 'options' : test.devoptions,
|
||||
'network' : test.devnetwork,
|
||||
},
|
||||
|
||||
'base' : {
|
||||
'id' : test.base.id, 'name' : test.base.name,
|
||||
'source' : test.base.source, 'protocol' : test.base.protocol,
|
||||
'sha' : test.base.sha, 'bench' : test.base.bench,
|
||||
'options' : test.baseoptions, 'network' : test.basenetwork,
|
||||
'source' : test.base.source, 'sha' : test.base.sha,
|
||||
'bench' : test.base.bench, 'options' : test.baseoptions,
|
||||
'network' : test.basenetwork,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
def updateTest(request, user):
|
||||
|
||||
+77
-60
@@ -18,7 +18,7 @@
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
import os, hashlib, mimetypes, datetime
|
||||
import os, hashlib, mimetypes, datetime, json
|
||||
|
||||
import django.http
|
||||
import django.shortcuts
|
||||
@@ -38,9 +38,14 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from htmlmin.decorators import not_minified_response
|
||||
|
||||
def render(request, template, content={}):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# GENERAL UTILITIES #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
template = 'OpenBench/{0}'.format(template)
|
||||
class UnableToAuthenticate(Exception):
|
||||
pass
|
||||
|
||||
def render(request, template, content={}):
|
||||
|
||||
data = content.copy()
|
||||
data.update({'config' : OpenBench.config.OPENBENCH_CONFIG})
|
||||
@@ -56,8 +61,22 @@ def render(request, template, content={}):
|
||||
if request.user.is_authenticated and not profile.first():
|
||||
data.update({'error' : data['config']['error']['fakeuser']})
|
||||
|
||||
return django.shortcuts.render(request, template, data)
|
||||
return django.shortcuts.render(request, 'OpenBench/{0}'.format(template), data)
|
||||
|
||||
def authenticate(request):
|
||||
|
||||
try:
|
||||
user = django.contrib.auth.authenticate(
|
||||
username = request.POST['username'],
|
||||
password = request.POST['password'])
|
||||
|
||||
except Exception:
|
||||
raise UnableToAuthenticate()
|
||||
|
||||
if user is None:
|
||||
raise UnableToAuthenticate()
|
||||
|
||||
return user
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# ADMINISTRATIVE VIEWS #
|
||||
@@ -103,25 +122,22 @@ def login(request):
|
||||
# #
|
||||
# GET : Return the HTML template used for logging in a User #
|
||||
# #
|
||||
# POST : Attempt to login the User and authenticate their credentials. #
|
||||
# If their login is invalid, let them know. In all cases, return #
|
||||
# the User back to the main page #
|
||||
# POST : Attempt to login the User. If their login is invalid, let them #
|
||||
# know. In all cases, return the User back to the main page #
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if request.method == 'GET':
|
||||
return render(request, 'login.html')
|
||||
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
try:
|
||||
user = authenticate(request)
|
||||
django.contrib.auth.login(request, user)
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
|
||||
if user is None:
|
||||
except UnableToAuthenticate:
|
||||
return index(request, error='Unable to Authenticate User')
|
||||
|
||||
django.contrib.auth.login(request, user)
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
|
||||
def logout(request):
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
@@ -452,18 +468,19 @@ def newTest(request):
|
||||
# NETWORK MANAGEMENT VIEWS #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
def networks(request, action=None, sha256=None):
|
||||
def networks(request, action=None, sha256=None, client=False):
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
# GET : There are three possible GET lookups. [1] Fetch a view of all #
|
||||
# the Networks on the framework. [2] Fetch a template to upload a #
|
||||
# new Network to the framework. [3] Download the contents of a #
|
||||
# Network that is already saved on the framework. #
|
||||
# Network that is already saved on the framework. Anyone may view #
|
||||
# the list of Network weights, but only some may interact #
|
||||
# #
|
||||
# POST : There are four possible POST lookups. Download, Upload, Default #
|
||||
# and Delete. Downloads are open, but all others are gated by the #
|
||||
# credentials of the User. #
|
||||
# POST : There are three possible POST lookups. They are Upload, Default #
|
||||
# and Delete. All of these are placed behind a login and approver #
|
||||
# flag wall. This view is not meant to distribute Networks #
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
@@ -471,24 +488,10 @@ def networks(request, action=None, sha256=None):
|
||||
networks = Network.objects.all().order_by('-id')
|
||||
return render(request, 'networks.html', {'networks' : networks})
|
||||
|
||||
if action.upper() == 'DOWNLOAD':
|
||||
|
||||
if not Network.objects.filter(sha256=sha256):
|
||||
return index(request, error='No Network found with matching SHA256')
|
||||
|
||||
netfile = os.path.join(MEDIA_ROOT, sha256)
|
||||
fwrapper = FileWrapper(open(netfile, 'rb'), 8192)
|
||||
response = FileResponse(fwrapper, content_type='application/octet-stream')
|
||||
|
||||
response['Expires'] = (datetime.datetime.utcnow() + datetime.timedelta(days=7)).ctime()
|
||||
response['Content-Length'] = os.path.getsize(netfile)
|
||||
response['Content-Disposition'] = 'attachment; filename=' + sha256
|
||||
return response
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
return django.http.HttpResponseRedirect('/login/')
|
||||
|
||||
if not Profile.objects.get(user=request.user).approver:
|
||||
if not client and not Profile.objects.get(user=request.user).approver:
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
|
||||
if action.upper() == 'UPLOAD':
|
||||
@@ -510,7 +513,7 @@ def networks(request, action=None, sha256=None):
|
||||
|
||||
Network.objects.create(
|
||||
sha256=sha256, name=request.POST['name'],
|
||||
engine=engine, author=request.user.username);
|
||||
engine=engine, author=request.user.username)
|
||||
|
||||
return index(request)
|
||||
|
||||
@@ -535,6 +538,20 @@ def networks(request, action=None, sha256=None):
|
||||
|
||||
return django.http.HttpResponseRedirect('/networks/')
|
||||
|
||||
if action.upper() == 'DOWNLOAD':
|
||||
|
||||
if not Network.objects.filter(sha256=sha256):
|
||||
return index(request, error='No Network found with matching SHA256')
|
||||
|
||||
netfile = os.path.join(MEDIA_ROOT, sha256)
|
||||
fwrapper = FileWrapper(open(netfile, 'rb'), 8192)
|
||||
response = FileResponse(fwrapper, content_type='application/octet-stream')
|
||||
|
||||
response['Expires'] = (datetime.datetime.utcnow() + datetime.timedelta(days=7)).ctime()
|
||||
response['Content-Length'] = os.path.getsize(netfile)
|
||||
response['Content-Disposition'] = 'attachment; filename=' + sha256
|
||||
return response
|
||||
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# CLIENT HOOK VIEWS #
|
||||
@@ -545,8 +562,7 @@ def clientGetFiles(request):
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
# GET : Return a URL pointing to the location of Cutechess-cli, as well #
|
||||
# as any DLLs or Shared Object files needed for Cutechess-cli #
|
||||
# GET : Return a URL to the location of Cutechess for Windows and Linux #
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
@@ -562,10 +578,10 @@ def clientGetBuildInfo(request):
|
||||
# #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
data = {} # Return all engine-compiler information
|
||||
data = {}
|
||||
for engine, config in OpenBench.config.OPENBENCH_CONFIG['engines'].items():
|
||||
data[engine] = config['build']['compilers']
|
||||
return HttpResponse(str(data))
|
||||
data[engine] = config['build']
|
||||
return HttpResponse(json.dumps(data))
|
||||
|
||||
@csrf_exempt
|
||||
@not_minified_response
|
||||
@@ -582,14 +598,23 @@ def clientGetWorkload(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
# Verify the User's credentials
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
if user == None: return HttpResponse('Bad Credentials')
|
||||
try: user = authenticate(request)
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# getWorkload() will verify the integrity of the request
|
||||
return HttpResponse(OpenBench.utils.getWorkload(user, request))
|
||||
|
||||
@csrf_exempt
|
||||
@not_minified_response
|
||||
def clientGetNetwork(request, sha256):
|
||||
|
||||
# Verify the User's credentials
|
||||
try: django.contrib.auth.login(request, authenticate(request))
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# Return the requested Neural Network file for the Client
|
||||
return networks(request, action='DOWNLOAD', sha256=sha256, client=True)
|
||||
|
||||
@csrf_exempt
|
||||
@not_minified_response
|
||||
def clientWrongBench(request):
|
||||
@@ -603,10 +628,8 @@ def clientWrongBench(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
# Verify the User's credentials
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
if user == None: return HttpResponse('Bad Credentials')
|
||||
try: user = authenticate(request)
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# Verify the Machine belongs to the User
|
||||
machine = Machine.objects.get(id=int(request.POST['machineid']))
|
||||
@@ -646,10 +669,8 @@ def clientSubmitNPS(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
# Verify the User's credentials
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
if user == None: return HttpResponse('Bad Credentials')
|
||||
try: user = authenticate(request)
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# Verify the Machine belongs to the User
|
||||
machine = Machine.objects.get(id=int(request.POST['machineid']))
|
||||
@@ -672,10 +693,8 @@ def clientSubmitError(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
# Verify the User's credentials
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
if user == None: return HttpResponse('Bad Credentials')
|
||||
try: user = authenticate(request)
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# Verify the Machine belongs to the User
|
||||
machine = Machine.objects.get(id=int(request.POST['machineid']))
|
||||
@@ -698,10 +717,8 @@ def clientSubmitError(request):
|
||||
def clientSubmitResults(request):
|
||||
|
||||
# Verify the User's credentials
|
||||
user = django.contrib.auth.authenticate(
|
||||
username=request.POST['username'],
|
||||
password=request.POST['password'])
|
||||
if user == None: return HttpResponse('Bad Credentials')
|
||||
try: user = authenticate(request)
|
||||
except UnableToAuthenticate: return HttpResponse('Bad Credentials')
|
||||
|
||||
# Verify the Machine belongs to the User
|
||||
machine = Machine.objects.get(id=int(request.POST['machineid']))
|
||||
|
||||
Reference in new issue
Block a user