From def5d077e953d1ff6b2bc171612c447656d9e2f7 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Sat, 11 Apr 2020 18:31:13 +0200 Subject: [PATCH] updated script launchBatches so that it doesn't send more than 2 jobs without bestEffort --- UD_any/launchBatches.py | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/UD_any/launchBatches.py b/UD_any/launchBatches.py index 8db6ab9..621db11 100755 --- a/UD_any/launchBatches.py +++ b/UD_any/launchBatches.py @@ -18,11 +18,11 @@ def prepareExperiment(lang, template, expName) : ############################################################################### ############################################################################### -def launchTrain(mode, expName, arguments, launcher, nbHours, jobIndex) : +def launchTrain(mode, expName, arguments, launcher, nbHours) : if launcher == "bash" : launchTrainBash(mode, expName, arguments) elif launcher == "oar" : - launchTrainOar(mode, expName, arguments, nbHours, jobIndex) + launchTrainOar(mode, expName, arguments, nbHours) else : printUsageAndExit() ############################################################################### @@ -35,12 +35,19 @@ def launchTrainBash(mode, expName, arguments) : ############################################################################### ############################################################################### -def launchTrainOar(mode, expName, arguments, nbHours, jobIndex) : +def nbMaxLongJobs() : + return 2 +############################################################################### + +############################################################################### +def launchTrainOar(mode, expName, arguments, nbHours) : devScore = "--devScore" + bestEffort = getOarNbLongJobs() >= nbMaxLongJobs() + command = "oarsub" - command += " -t besteffort" if jobIndex > 1 else "" - command += " -t idempotent" if jobIndex > 1 else "" + command += " -t besteffort" if bestEffort else "" + command += " -t idempotent" if bestEffort else "" command += " -n train:%s"%expName command += " -E %s.stderr"%expName command += " -O %s.stdout"%expName @@ -52,11 +59,11 @@ def launchTrainOar(mode, expName, arguments, nbHours, jobIndex) : ############################################################################### ############################################################################### -def launchEval(mode, expName, launcher, nbHours, jobIndex) : +def launchEval(mode, expName, launcher, nbHours) : if launcher == "bash" : launchEvalBash(mode, expName) elif launcher == "oar" : - launchEvalOar(mode, expName, nbHours, jobIndex) + launchEvalOar(mode, expName, nbHours) else : printUsageAndExit() ############################################################################### @@ -68,10 +75,12 @@ def launchEvalBash(mode, expName) : ############################################################################### ############################################################################### -def launchEvalOar(mode, expName,nbHours, jobIndex) : +def launchEvalOar(mode, expName,nbHours) : + bestEffort = getOarNbLongJobs() >= nbMaxLongJobs() + command = "oarsub" - command += " -t besteffort" if jobIndex > 1 else "" - command += " -t idempotent" if jobIndex > 1 else "" + command += " -t besteffort" if bestEffort else "" + command += " -t idempotent" if bestEffort else "" command += " -n eval:%s"%expName command += " -E %s.stderr"%expName command += " -O %s.stdout"%expName @@ -82,6 +91,13 @@ def launchEvalOar(mode, expName,nbHours, jobIndex) : os.system(command) ############################################################################### +############################################################################### +def getOarNbLongJobs() : + return int(subprocess.Popen('oarstat -u | grep "Q=long" | wc -l', + shell=True, stdout=subprocess.PIPE).stdout.read()) + +############################################################################### + ############################################################################### if __name__ == "__main__" : if len(sys.argv) < 4 : @@ -105,7 +121,6 @@ if __name__ == "__main__" : 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) : @@ -113,9 +128,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,nbHours,jobIndex) + launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher,nbHours) else : - launchEval(xp['mode'],xp['expName'],launcher,nbHours,jobIndex) + launchEval(xp['mode'],xp['expName'],launcher,nbHours) ############################################################################### -- GitLab