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

Allowing multiline commands to be launched from launchBatches.py

parent ff1a5ee6
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ def prepareExperiment(lang, template, expName) : ...@@ -21,7 +21,7 @@ def prepareExperiment(lang, template, expName) :
def addNamesAndCommandsTrain(names, commands, mode, expName, arguments, seed) : def addNamesAndCommandsTrain(names, commands, mode, expName, arguments, seed) :
names.append("\""+expName+"\"") names.append("\""+expName+"\"")
commands.append("\""+"./train.sh {} bin/{} {} --silent --seed {}".format(mode, expName,arguments,seed)+"\"") commands.append("'"+"./train.sh {} bin/{} {} --silent --seed {}".format(mode, expName,arguments,seed)+"'")
############################################################################### ###############################################################################
############################################################################### ###############################################################################
...@@ -63,13 +63,31 @@ module load python/3.7.5 ...@@ -63,13 +63,31 @@ module load python/3.7.5
names=({}) names=({})
commands=({}) commands=({})
mv $SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".out" ${{names[$SLURM_ARRAY_TASK_ID]}}".stdout" newOut=${{names[$SLURM_ARRAY_TASK_ID]}}".stdout"
mv $SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".err" ${{names[$SLURM_ARRAY_TASK_ID]}}".stderr" newErr=${{names[$SLURM_ARRAY_TASK_ID]}}".stderr"
${{commands[$SLURM_ARRAY_TASK_ID]}} oldOut=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".out"
""".format(len(names), limit, mode, jobName, "qos_gpu-t4" if nbHours > 20 else "qos_gpu-t3", nbHours, " ".join(names), " ".join(commands)), file=sFile) oldErr=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".err"
tmpFile=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".tmp"
touch $newOut
cp $newOut $tmpFile
mv $oldOut $newOut
cat $tmpFile >> $newOut
touch $newErr
cp $newErr $tmpFile
mv $oldErr $newErr
cat $tmpFile >> $newErr
rm $tmpFile
eval "${{commands[$SLURM_ARRAY_TASK_ID]}}"
""".format(len(names)-1, limit, mode, jobName, "qos_gpu-t4" if nbHours > 20 else "qos_gpu-t3", nbHours, " ".join(names), " ".join(commands)), file=sFile)
sFile.close() sFile.close()
elif hostname == "sms.liscluster" : elif hostname == "sms.liscluster" :
print("""#! /usr/bin/env bash print('''#! /usr/bin/env bash
#SBATCH --array=0-{}%{} #SBATCH --array=0-{}%{}
#SBATCH --job-name={}:{} #SBATCH --job-name={}:{}
...@@ -88,10 +106,28 @@ module purge ...@@ -88,10 +106,28 @@ module purge
names=({}) names=({})
commands=({}) commands=({})
mv $SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".out" ${{names[$SLURM_ARRAY_TASK_ID]}}".stdout" newOut=${{names[$SLURM_ARRAY_TASK_ID]}}".stdout"
mv $SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".err" ${{names[$SLURM_ARRAY_TASK_ID]}}".stderr" newErr=${{names[$SLURM_ARRAY_TASK_ID]}}".stderr"
${{commands[$SLURM_ARRAY_TASK_ID]}} oldOut=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".out"
""".format(len(names), limit, mode, jobName, "cpu" if device == "cpu" else "gpu\n#SBATCH --gres=gpu", nbHours, " ".join(names), commandList), file=sFile) oldErr=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".err"
tmpFile=$SLURM_ARRAY_JOB_ID"_"$SLURM_ARRAY_TASK_ID".tmp"
touch $newOut
cp $newOut $tmpFile
mv $oldOut $newOut
cat $tmpFile >> $newOut
touch $newErr
cp $newErr $tmpFile
mv $oldErr $newErr
cat $tmpFile >> $newErr
rm $tmpFile
eval "${{commands[$SLURM_ARRAY_TASK_ID]}}"
'''.format(len(names)-1, limit, mode, jobName, "cpu" if device == "cpu" else "gpu\n#SBATCH --gres=gpu", nbHours, " ".join(names), commandList), file=sFile)
sFile.close() sFile.close()
else : else :
print("ERROR : Unknown hostname \'%s\'"%hostname) print("ERROR : Unknown hostname \'%s\'"%hostname)
......
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