Provide each engine the option for a custom path and custom build command

This commit is contained in:
AndyGrant committed 2019-11-26 04:52:47 -05:00
1 parent 018ecd526e
commit d31d9b6763
1 file changed
+37 -28
+37 -28
View File
@@ -10,11 +10,11 @@ ERROR_TIMEOUT = 60 # Timeout when an error is thrown
GAMES_PER_TASK = 250 # Total games to play per workload GAMES_PER_TASK = 250 # Total games to play per workload
REPORT_RATE = 5 # Games played for each upload cycle REPORT_RATE = 5 # Games played for each upload cycle
COMPILATION_FLAGS = { CUSTOM_SETTINGS = {
'ETHEREAL' : [], # Custom makefile flags for Ethereal 'ETHEREAL' : { 'path' : '/src/', 'args' : [] }, # Configuration for Ethereal
'LASER' : [], # Custom makefile flags for Laser 'LASER' : { 'path' : '/src/', 'args' : [] }, # Configuration for Laser
'WEISS' : [], # Custom makefile flags for Weiss 'WEISS' : { 'path' : '/src/', 'args' : [] }, # Configuration for Weiss
'DEMOLITO' : [], # Custom makefile flags for Demolito 'DEMOLITO' : { 'path' : '/src/', 'args' : [] }, # Configuration for Demolito
}; };
@@ -22,7 +22,8 @@ COMPILATION_FLAGS = {
IS_WINDOWS = platform.system() == 'Windows' IS_WINDOWS = platform.system() == 'Windows'
IS_LINUX = platform.system() != 'Windows' IS_LINUX = platform.system() != 'Windows'
def urljoin(*args):
def pathjoin(*args):
# Join a set of URL paths while maintaining the correct # Join a set of URL paths while maintaining the correct
# format of "/"'s between each part of the URL's pathway # format of "/"'s between each part of the URL's pathway
@@ -74,7 +75,7 @@ def getCutechess(server):
# Ask the server where the core files are saved # Ask the server where the core files are saved
source = requests.get( source = requests.get(
urljoin(server, 'getFiles'), pathjoin(server, 'getFiles'),
timeout=HTTP_TIMEOUT).content.decode('utf-8') timeout=HTTP_TIMEOUT).content.decode('utf-8')
# Windows workers need the cutechess.exe and the Qt5Core dll. # Windows workers need the cutechess.exe and the Qt5Core dll.
@@ -82,17 +83,17 @@ def getCutechess(server):
# Make sure Linux binaries are set to be executable. # Make sure Linux binaries are set to be executable.
if IS_WINDOWS and not os.path.isfile('cutechess.exe'): if IS_WINDOWS and not os.path.isfile('cutechess.exe'):
getFile(urljoin(source, 'cutechess-windows.exe'), 'cutechess.exe') getFile(pathjoin(source, 'cutechess-windows.exe'), 'cutechess.exe')
if IS_WINDOWS and not os.path.isfile('Qt5Core.dll'): if IS_WINDOWS and not os.path.isfile('Qt5Core.dll'):
getFile(urljoin(source, 'cutechess-qt5core.dll'), 'Qt5Core.dll') getFile(pathjoin(source, 'cutechess-qt5core.dll'), 'Qt5Core.dll')
if IS_LINUX and not os.path.isfile('cutechess'): if IS_LINUX and not os.path.isfile('cutechess'):
getFile(urljoin(source, 'cutechess-linux'), 'cutechess') getFile(pathjoin(source, 'cutechess-linux'), 'cutechess')
os.system('chmod 777 cutechess') os.system('chmod 777 cutechess')
if IS_LINUX and not os.path.isfile('libcutechess.so.1'): if IS_LINUX and not os.path.isfile('libcutechess.so.1'):
getFile(urljoin(source, 'libcutechess.so.1'), 'libcutechess.so.1') getFile(pathjoin(source, 'libcutechess.so.1'), 'libcutechess.so.1')
def getMachineID(): def getMachineID():
@@ -108,32 +109,40 @@ def getMachineID():
def getEngine(data, engine): def getEngine(data, engine):
# Log the fact that we are setting up a new engine # Log the fact that we are setting up a new engine
print('\nSetting Up Engine') print('\nBuilding New Engine')
print('Engine {0}'.format(engine['name'])) print('Engine {0}'.format(engine['name']))
print('Commit {0}'.format(engine['sha'])) print('Commit {0}'.format(engine['sha']))
print('Source {0}'.format(engine['source'])) print('Source {0}'.format(engine['source']))
# Format: https://github.com/User/Engine/archive/SHA.zip
# Extract the zipfile to /tmp/ for future processing # Extract the zipfile to /tmp/ for future processing
# Format: https://github.com/User/Engine/archive/SHA.zip
tokens = engine['source'].split('/') tokens = engine['source'].split('/')
unzipname = '{0}-{1}'.format(tokens[-3], tokens[-1].replace('.zip', '')) unzipname = '{0}-{1}'.format(tokens[-3], tokens[-1].replace('.zip', ''))
getAndUnzipFile(engine['source'], '{0}.zip'.format(engine['name']), 'tmp') getAndUnzipFile(engine['source'], '{0}.zip'.format(engine['name']), 'tmp')
# Build the Engine. Include any custom makefile arguments # By default, build at the root with a simple make
pathway = 'tmp/{0}/'.format(unzipname)
command = ['make', 'EXE={0}'.format(engine['name'])] command = ['make', 'EXE={0}'.format(engine['name'])]
if data['test']['engine'].upper() in COMPILATION_FLAGS:
command.extend(COMPILATION_FLAGS[data['test']['engine'].upper()])
subprocess.Popen(command, cwd='tmp/{0}/src/'.format(unzipname)).wait()
# Move the compiled engine ( check for a .exe extension ) # Check CUSTOM_SETTINGS for a custom configuration
if os.path.isfile('tmp/{0}/src/{1}.exe'.format(unzipname, engine['name'])): if data['test']['engine'].upper() in CUSTOM_SETTINGS:
os.rename('tmp/{0}/src/{1}.exe'.format(unzipname, engine['name']), 'Engines/{0}'.format(engine['sha'])) config = CUSTOM_SETTINGS[data['test']['engine'].upper()]
pathway = pathjoin(pathway, config['path'])
command.extend(config['args'])
# Move the compiled engine ( check for no .exe extension ) # Build the engine. If something goes wrong with the
elif os.path.isfile('tmp/{0}/src/{1}'.format(unzipname, engine['name'])): # compilation process, we will figure this out later on
os.rename('tmp/{0}/src/{1}'.format(unzipname, engine['name']), 'Engines/{0}'.format(engine['sha'])) subprocess.Popen(command, cwd=pathway).wait()
# Cleanup all downloaded source files # Move the binary to the /Engines/ directory
output = '{0}{1}'.format(pathway, engine['name'])
destination = 'Engines/{0}'.format(engine['sha'])
# Check to see if the compiler included a file extension or not
if os.path.isfile(output): os.rename(output, destination)
if os.path.isfile(output + '.exe'): os.rename(output + '.exe', destination)
# Cleanup the zipfile directory
shutil.rmtree('tmp') shutil.rmtree('tmp')
def getCutechessCommand(arguments, data, nps): def getCutechessCommand(arguments, data, nps):
@@ -333,7 +342,7 @@ def reportWrongBenchmark(arguments, data, engine):
} }
# Hit the server with information about wrong benchmark # Hit the server with information about wrong benchmark
url = urljoin(arguments.server, 'wrongBench') url = pathjoin(arguments.server, 'wrongBench')
return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
def reportNodesPerSecond(arguments, data, nps): def reportNodesPerSecond(arguments, data, nps):
@@ -348,7 +357,7 @@ def reportNodesPerSecond(arguments, data, nps):
} }
# Hit the server with information about nps # Hit the server with information about nps
url = urljoin(arguments.server, 'submitNPS') url = pathjoin(arguments.server, 'submitNPS')
return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
def reportResults(arguments, data, wins, losses, draws, crashes, timelosses): def reportResults(arguments, data, wins, losses, draws, crashes, timelosses):
@@ -364,7 +373,7 @@ def reportResults(arguments, data, wins, losses, draws, crashes, timelosses):
} }
# Hit the server with the updated test results # Hit the server with the updated test results
url = urljoin(arguments.server, 'submitResults') url = pathjoin(arguments.server, 'submitResults')
try: return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text try: return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
except: print('[NOTE] Unable To Reach Server'); return "Unable" except: print('[NOTE] Unable To Reach Server'); return "Unable"
@@ -433,7 +442,7 @@ def completeWorkload(workRequestData, arguments):
# Get the next workload # Get the next workload
data = requests.post( data = requests.post(
urljoin(arguments.server, 'getWorkload'), pathjoin(arguments.server, 'getWorkload'),
data=workRequestData, timeout=HTTP_TIMEOUT).content.decode('utf-8') data=workRequestData, timeout=HTTP_TIMEOUT).content.decode('utf-8')
# Check for an empty workload # Check for an empty workload