Skip to content
Snippets Groups Projects
Commit 89a31d12 authored by Franck Dary's avatar Franck Dary
Browse files

Added script to launch batches of experiments

parent f5f522b4
No related branches found
No related tags found
No related merge requests found
bin/ bin/
*\.stderr
*\.stdout
__pycache__
#! /usr/bin/python3
import sys
import os
import subprocess
###############################################################################
def printUsageAndExit() :
print("USAGE : %s (train | eval) (bash | oar) batchesDescription.py"%sys.argv[0],
file=sys.stderr)
exit(1)
###############################################################################
###############################################################################
def prepareExperiment(lang, template, expName) :
subprocess.Popen("./prepareExperiment.sh %s %s %s"%(lang,template,expName),
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
###############################################################################
###############################################################################
def launchTrain(mode, expName, arguments, launcher) :
if launcher == "bash" :
launchTrainBash(mode, expName, arguments)
###############################################################################
###############################################################################
def launchTrainBash(mode, expName, arguments) :
devScore = "--devScore"
subprocess.Popen("./train.sh %s bin/%s %s --silent %s"%(mode,expName,arguments,devScore),
shell=True, stdout=open("%s.stdout"%expName,'w'), stderr=open("%s.stderr"%expName,'w'))
###############################################################################
###############################################################################
if __name__ == "__main__" :
if len(sys.argv) != 4 :
printUsageAndExit()
mode = sys.argv[1]
launcher = sys.argv[2]
batchesDescription = sys.argv[3]
if mode not in ["train","eval"] or launcher not in ["bash","oar"] :
printUsageAndExit()
desc = __import__(os.path.splitext(batchesDescription)[0])
for lang in desc.langs :
for xp in desc.templatesExperiments :
for i in range(desc.nbReplicas) :
xp['lang'] = lang
xp['expName'] = xp['expName'].split('.')[0]+"."+str(i)
if mode == "train" :
prepareExperiment(xp['lang'],xp['template'],xp['expName'])
launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher)
else :
print("todo")
###############################################################################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment