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

Added time option and updated besteffort policy for launchBatches.py

parent 69278bd4
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ import subprocess
###############################################################################
def printUsageAndExit() :
print("USAGE : %s (train | eval) (bash | oar) batchesDescription.py"%sys.argv[0],
print("USAGE : %s (train | eval) (bash | oar) batchesDescription.py (--time nbHours)"%sys.argv[0],
file=sys.stderr)
exit(1)
###############################################################################
......@@ -18,11 +18,11 @@ def prepareExperiment(lang, template, expName) :
###############################################################################
###############################################################################
def launchTrain(mode, expName, arguments, launcher) :
def launchTrain(mode, expName, arguments, launcher, nbHours, jobIndex) :
if launcher == "bash" :
launchTrainBash(mode, expName, arguments)
elif launcher == "oar" :
launchTrainOar(mode, expName, arguments)
launchTrainOar(mode, expName, arguments, nbHours, jobIndex)
else :
printUsageAndExit()
###############################################################################
......@@ -35,28 +35,28 @@ def launchTrainBash(mode, expName, arguments) :
###############################################################################
###############################################################################
def launchTrainOar(mode, expName, arguments) :
def launchTrainOar(mode, expName, arguments, nbHours, jobIndex) :
devScore = "--devScore"
command = "oarsub"
command += " -t besteffort"
command += " -t idempotent"
command += " -t besteffort" if jobIndex > 1 else ""
command += " -t idempotent" if jobIndex > 1 else ""
command += " -n train:%s"%expName
command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName
command += " -p \"gpu IS NOT NULL\""
command += " -l walltime=15:00:00"
command += " -l walltime=%d:00:00"%nbHours
command += " \"" + "./train.sh %s bin/%s %s --silent %s"%(mode,expName,arguments,devScore) + "\""
os.system(command)
###############################################################################
###############################################################################
def launchEval(mode, expName, launcher) :
def launchEval(mode, expName, launcher, nbHours, jobIndex) :
if launcher == "bash" :
launchEvalBash(mode, expName)
elif launcher == "oar" :
launchEvalOar(mode, expName)
launchEvalOar(mode, expName, nbHours, jobIndex)
else :
printUsageAndExit()
###############################################################################
......@@ -68,14 +68,15 @@ def launchEvalBash(mode, expName) :
###############################################################################
###############################################################################
def launchEvalOar(mode, expName) :
def launchEvalOar(mode, expName,nbHours, jobIndex) :
command = "oarsub"
command += " -t besteffort"
command += " -t besteffort" if jobIndex > 1 else ""
command += " -t idempotent" if jobIndex > 1 else ""
command += " -n eval:%s"%expName
command += " -E %s.stderr"%expName
command += " -O %s.stdout"%expName
command += " -p \"gpu IS NOT NULL\""
command += " -l walltime=2:00:00"
command += " -l walltime=%d:00:00"%nbHours
command += " \"" + "./evaluate.sh %s bin/%s --silent"%(mode,expName) + "\""
os.system(command)
......@@ -83,18 +84,28 @@ def launchEvalOar(mode, expName) :
###############################################################################
if __name__ == "__main__" :
if len(sys.argv) != 4 :
if len(sys.argv) < 4 :
printUsageAndExit()
mode = sys.argv[1]
launcher = sys.argv[2]
batchesDescription = sys.argv[3]
nbHours = 92
if len(sys.argv) > 4 :
if sys.argv[4] == "--time" :
if 5 not in range(4,len(sys.argv)) :
printUsageAndExit()
nbHours = int(sys.argv[5])
else :
printUsageAndExit()
if mode not in ["train","eval"] or launcher not in ["bash","oar"] :
printUsageAndExit()
desc = __import__(os.path.splitext(batchesDescription)[0])
jobIndex = 0
for lang in desc.langs :
for xp in desc.templatesExperiments :
for i in range(desc.nbReplicas) :
......@@ -102,9 +113,9 @@ if __name__ == "__main__" :
xp['expName'] = xp['expName'].split('.')[0]+"."+lang+"."+str(i)
if mode == "train" :
prepareExperiment(xp['lang'],xp['template'],xp['expName'])
launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher)
launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher,nbHours,jobIndex)
else :
launchEval(xp['mode'],xp['expName'],launcher)
launchEval(xp['mode'],xp['expName'],launcher,nbHours,jobIndex)
###############################################################################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment