Replace PGN books with the EPD books

This commit is contained in:
Andrew Grant committed 2021-05-08 22:57:01 -04:00
1 parent 5ca88c392e
commit b0227bc282
9 files changed
+55 -39

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+37 -21
View File
@@ -63,8 +63,15 @@ def addExtension(name):
def pathjoin(*args):
# Join a set of URL paths while maintaining the correct
# format of "/"'s between each part of the URL's pathway
# Join a set of file paths while maintaining the correct
# format of "/"'s between each part of the file's pathway
return '/'.join([f.lstrip('/').rstrip('/') for f in args])
def urljoin(*args):
# Join a set of file paths while maintaining the correct
# format of "/"'s between each part of the file's pathway
return '/'.join([f.lstrip('/').rstrip('/') for f in args]) + '/'
@@ -95,6 +102,7 @@ def killCutechess(cutechess):
except KeyboardInterrupt: sys.exit()
except Exception as error: pass
def cleanupEnginesDirectory():
SECONDS_PER_DAY = 60 * 60 * 24;
@@ -102,7 +110,17 @@ def cleanupEnginesDirectory():
for file in os.listdir('Engines/'):
if time.time() - os.path.getmtime('Engines/{0}'.format(file)) > SECONDS_PER_DAY:
os.remove('Engines/{0}'.format(file))
print ("[NOTE] Deleted old engine", file)
print ("[NOTE] Deleted Engine", file)
def cleanupNetworksDirectory():
SECONDS_PER_MONTH = 60 * 60 * 24 * 30;
for file in os.listdir('Networks/'):
if time.time() - os.path.getmtime('Networks/{0}'.format(file)) > SECONDS_PER_MONTH:
os.remove('Networks/{0}'.format(file))
print ("[NOTE] Deleted Network", file)
def getCutechess(server):
@@ -111,28 +129,28 @@ def getCutechess(server):
# Fetch the source location if we are missing the binary
source = requests.get(
pathjoin(server, 'clientGetFiles'),
urljoin(server, 'clientGetFiles'),
timeout=HTTP_TIMEOUT).content.decode('utf-8')
# Windows workers simply need a static compile (64-bit)
getFile(pathjoin(source, 'cutechess-windows.exe'), 'cutechess.exe')
getFile(urljoin(source, 'cutechess-windows.exe'), 'cutechess.exe')
if IS_LINUX and not os.path.isfile('cutechess'):
# Fetch the source location if we are missing the binary
source = requests.get(
pathjoin(server, 'clientGetFiles'),
urljoin(server, 'clientGetFiles'),
timeout=HTTP_TIMEOUT).content.decode('utf-8')
# Linux workers need a static compile (64-bit) with execute permissions
getFile(pathjoin(source, 'cutechess-linux'), 'cutechess')
getFile(urljoin(source, 'cutechess-linux'), 'cutechess')
os.system('chmod 777 cutechess')
def getCompilationSettings(server):
# Get a dictionary of engine -> compilers
data = requests.get(
pathjoin(server, 'clientGetBuildInfo'),
urljoin(server, 'clientGetBuildInfo'),
timeout=HTTP_TIMEOUT).content.decode('utf-8')
data = ast.literal_eval(data)
@@ -173,7 +191,7 @@ def getCompilationSettings(server):
print("Unable to find compiler for {0}".format(engine))
def getFile(source, output):
def getFile(source, output, post=None):
# Download the source file
print('Downloading {0}'.format(source))
@@ -245,7 +263,7 @@ def getEngine(arguments, data, engine, network):
# Move the binary to the /Engines/ directory
output = '{0}{1}'.format(pathway, engine['name'])
destination = addExtension(pathjoin('Engines', savedEngineName(engine['sha'], network)).rstrip('/'))
destination = addExtension(pathjoin('Engines', savedEngineName(engine['sha'], network)))
# Check to see if the compiler included a file extension or not
if os.path.isfile(output): os.rename(output, destination)
@@ -260,9 +278,9 @@ def getNetworkWeights(server, network):
return
print ('Fetching and Verifying Network ({0})'.format(network))
fname = pathjoin('Networks', network).rstrip('/')
fname = pathjoin('Networks', network)
if not os.path.isfile(fname):
getFile(pathjoin(server, 'networks', 'download', network), fname)
getFile(urljoin(server, 'networks', 'download', network), fname)
with open(fname, 'rb') as weights:
sha256 = hashlib.sha256(weights.read()).hexdigest()[:8].upper()
@@ -491,7 +509,7 @@ def verifyEngine(arguments, data, engine, network):
# Download the engine if we do not already have it
name = savedEngineName(engine['sha'], network)
pathway = addExtension(pathjoin('Engines', name).rstrip('/'))
pathway = addExtension(pathjoin('Engines', name))
if not os.path.isfile(pathway): getEngine(arguments, data, engine, network)
# Run a group of benchmarks in parallel in order to better scale NPS
@@ -509,7 +527,6 @@ def verifyEngine(arguments, data, engine, network):
def reportWrongBenchmark(arguments, data, engine, bench):
data = {
'username' : arguments.username, 'testid' : data['test']['id'],
'password' : arguments.password, 'machineid' : data['machine']['id'],
@@ -517,19 +534,18 @@ def reportWrongBenchmark(arguments, data, engine, bench):
'engine' : engine['name'],
}
url = pathjoin(arguments.server, 'clientWrongBench')
url = urljoin(arguments.server, 'clientWrongBench')
data = requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
if data == 'Bad Machine': raise Exception('Bad Machine')
def reportNodesPerSecond(arguments, data, nps):
data = {
'username' : arguments.username, 'machineid' : data['machine']['id'],
'password' : arguments.password, 'nps' : nps,
}
url = pathjoin(arguments.server, 'clientSubmitNPS')
url = urljoin(arguments.server, 'clientSubmitNPS')
data = requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
if data == 'Bad Machine': raise Exception('Bad Machine')
@@ -548,7 +564,7 @@ def reportEngineError(arguments, data, line):
'error' : error,
}
url = pathjoin(arguments.server, 'clientSubmitError')
url = urljoin(arguments.server, 'clientSubmitError')
data = requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
if data == 'Bad Machine': raise Exception('Bad Machine')
@@ -562,9 +578,9 @@ def reportResults(arguments, data, wins, losses, draws, crashes, timelosses):
'testid' : data['test']['id'], 'timeloss' : timelosses,
}
url = pathjoin(arguments.server, 'clientSubmitResults')
url = urljoin(arguments.server, 'clientSubmitResults')
try: return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
except: print('[NOTE] Unable To Reach Server'); return 'Unable'
except Exception: print('[NOTE] Unable To Reach Server'); return 'Unable'
def processCutechess(arguments, data, cutechess, concurrency):
@@ -638,7 +654,7 @@ def completeWorkload(workRequestData, arguments):
# Get the next workload
data = requests.post(
pathjoin(arguments.server, 'clientGetWorkload'),
urljoin(arguments.server, 'clientGetWorkload'),
data=workRequestData, timeout=HTTP_TIMEOUT).content.decode('utf-8')
# Check for an empty workload
+18 -18
View File
@@ -36,36 +36,36 @@ OPENBENCH_CONFIG = {
# Book confgiruation. When addding a book, follow the provided template.
# The SHA is defined by hashlib.sha256(book).hexdigest(). OpenBench.py
# (Client File) has an example to show you how to find a hash digest
# The SHA is defined by hashlib.sha256(book).hexdigest(). Client.py has
# code to generate and verify sha256 values, as an example.
'books' : {
'2moves_v1.pgn' : {
'name' : '2moves_v1.pgn',
'sha' : '46aed7f2696618b2b914942032957b7a97a8f343bf54ba83e20a47818f0d42e0',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/2moves_v1.pgn',
'2moves_v1.epd' : {
'name' : '2moves_v1.epd',
'sha' : '7bec98239836f219dc41944a768c0506abed950aaec48da69a0782643e90f237',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/2moves_v1.epd',
'default' : False,
},
'8moves_v3.pgn' : {
'name' : '8moves_v3.pgn',
'sha' : '04fcce1488a94f3b7795cef6f74d89016eb278328897c1018e6162c5967273f5',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/8moves_v3.pgn',
'8moves_v3.epd' : {
'name' : '8moves_v3.epd',
'sha' : '38d1b6c456bc3d3f69a4927e2667ef3f3fa231e253b6dc4040093f00a1c2ccb3',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/8moves_v3.epd',
'default' : False,
},
'3moves_FRC.pgn' : {
'name' : '3moves_FRC.pgn',
'sha' : '4c801140e3a52d3a306cb226ccd6225c47789409c5f2d0e1d7cf86152ea1f973',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/3moves_FRC.pgn',
'3moves_FRC.epd' : {
'name' : '3moves_FRC.epd',
'sha' : '4be746a91e3f8af0c9344b1e72d611e9fcfe486843867a55760970a4896f284d',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/3moves_FRC.epd',
'default' : False,
},
'4moves_noob.pgn' : {
'name' : '4moves_noob.pgn',
'sha' : '377c0eef1d4b291ece226da89d8f7e8000396ca836abcb84f733417c31916664',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/4moves_noob.pgn',
'4moves_noob.epd' : {
'name' : '4moves_noob.epd',
'sha' : '1f055af431656f09ee6a09d2448e0b876125f78bb7b404fca2031c403a1541e5',
'source' : 'http://github.com/AndyGrant/OpenBench/raw/master/Books/4moves_noob.epd',
'default' : True,
},
},