From ba62ebc65dfb4ec391ce9dfe4bb6ba1ec8f03e17 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Tue, 30 Jun 2020 10:56:03 +0200
Subject: [PATCH] launchBatches now uses seed program argument

---
 UD_any/launchBatches.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/UD_any/launchBatches.py b/UD_any/launchBatches.py
index b7f4316..34729fe 100755
--- a/UD_any/launchBatches.py
+++ b/UD_any/launchBatches.py
@@ -18,20 +18,20 @@ def prepareExperiment(lang, template, expName) :
 ###############################################################################
 
 ###############################################################################
-def launchTrain(mode, expName, arguments, launcher, nbHours) :
+def launchTrain(mode, expName, arguments, launcher, nbHours, seed) :
   if launcher == "bash" :
-    launchTrainBash(mode, expName, arguments)
+    launchTrainBash(mode, expName, arguments, seed)
   elif launcher == "oar" :
-    launchTrainOar(mode, expName, arguments, nbHours)
+    launchTrainOar(mode, expName, arguments, nbHours, seed)
   elif launcher == "slurm" :
-    launchTrainSlurm(mode, expName, arguments, nbHours)
+    launchTrainSlurm(mode, expName, arguments, nbHours, seed)
   else :
     printUsageAndExit()
 ###############################################################################
 
 ###############################################################################
-def launchTrainBash(mode, expName, arguments) :
-  subprocess.Popen("./train.sh %s bin/%s %s --silent"%(mode,expName,arguments),
+def launchTrainBash(mode, expName, arguments, seed) :
+  subprocess.Popen("./train.sh %s bin/%s %s --silent --seed %d"%(mode,expName,arguments,seed),
     shell=True, stdout=open("%s.stdout"%expName,'w'), stderr=open("%s.stderr"%expName,'w'))
 ###############################################################################
 
@@ -41,7 +41,7 @@ def nbMaxLongJobs() :
 ###############################################################################
 
 ###############################################################################
-def launchTrainOar(mode, expName, arguments, nbHours) :
+def launchTrainOar(mode, expName, arguments, nbHours, seed) :
   bestEffort = getOarNbLongJobs() >= nbMaxLongJobs()
 
   command = "oarsub"
@@ -52,13 +52,13 @@ def launchTrainOar(mode, expName, arguments, nbHours) :
   command += " -O %s.stdout"%expName
   command += " -p \"gpu IS NOT NULL%s\""%getBestHostConstraint()
   command += " -l walltime=%d:00:00"%nbHours
-  command += " \'" + "./train.sh %s bin/%s %s --silent"%(mode,expName,arguments) + "\'"
+  command += " \'" + "./train.sh %s bin/%s %s --silent --seed"%(mode,expName,arguments,seed) + "\'"
 
   subprocess.Popen(command, shell=True).wait()
 ###############################################################################
 
 ###############################################################################
-def launchTrainSlurm(mode, expName, arguments, nbHours) :
+def launchTrainSlurm(mode, expName, arguments, nbHours, seed) :
   filename = "train.{}.slurm".format(expName)
   sFile = open(filename, "w")
 
@@ -80,8 +80,8 @@ module purge
 module load gcc/9.1.0
 module load python/3.7.5
 
-./train.sh {} bin/{} {} --silent
-""".format(expName, expName, expName, "qos_gpu-t4" if nbHours > 20 else "qos_gpu-t3", nbHours, mode, expName, arguments), file=sFile)
+./train.sh {} bin/{} {} --silent --seed {}
+""".format(expName, expName, expName, "qos_gpu-t4" if nbHours > 20 else "qos_gpu-t3", nbHours, mode, expName, arguments, seed), file=sFile)
   sFile.close()
 
   subprocess.Popen("sbatch {}".format(filename), shell=True).wait()
@@ -261,7 +261,7 @@ 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)
+          launchTrain(xp['mode'],xp['expName'],xp['arguments'],launcher,nbHours,seed=100+i)
         else :
           launchEval(xp['mode'],xp['expName'],launcher,nbHours)
 
-- 
GitLab