diff --git a/.gitignore b/.gitignore index e660fd93d3196215552065b1e63bf6a2f393ed86..d74fb18f9757b82a083069c005dbdfb9498f4c89 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ bin/ +*\.stderr +*\.stdout +__pycache__ diff --git a/UD_any/launchBatches.py b/UD_any/launchBatches.py new file mode 100755 index 0000000000000000000000000000000000000000..b4294c4f81ff80d50fa5329a8ca7fd2889673899 --- /dev/null +++ b/UD_any/launchBatches.py @@ -0,0 +1,59 @@ +#! /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") + +############################################################################### +