You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2022/01/05 16:45:58 UTC

[airavata] 01/02: Updating the slurm script to override parmaters with pre job commands

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 44ad2071fd3d7ed798d5ebb799a239185a11bf22
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Dec 23 17:36:23 2020 -0500

    Updating the slurm script to override parmaters with pre job commands
---
 .../src/main/resources/SLURM_Groovy.template       | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/configuration/server/src/main/resources/SLURM_Groovy.template b/modules/configuration/server/src/main/resources/SLURM_Groovy.template
index a30cecb..457ceee 100644
--- a/modules/configuration/server/src/main/resources/SLURM_Groovy.template
+++ b/modules/configuration/server/src/main/resources/SLURM_Groovy.template
@@ -2,10 +2,32 @@
 
 # SLURM job submission script generated by Apache Airavata
 <%
-if (queueName != null && queueName != "") out.print '#SBATCH -p ' + queueName + '\n'
-   if (nodes != null && nodes != "") out.print '#SBATCH -N ' + nodes + '\n'
-   if (cpuCount != null && cpuCount != "") out.print '#SBATCH -n ' + cpuCount + '\n'
-   if (usedMem != null && usedMem != "") out.print '#SBATCH --mem=' + usedMem + 'M\n'
+   def checkCommand = {items, prefix -> for (it in items) if (it.startsWith(prefix)) return it}
+
+   def extQueue = checkCommand(preJobCommands, '#SBATCH -p')
+   def rmQueue = checkCommand(preJobCommands, 'RM #SBATCH -p')
+   preJobCommands = preJobCommands - extQueue
+   preJobCommands = preJobCommands - rmQueue
+   if (queueName != null && queueName != "" && rmQueue == null) out.print extQueue ? extQueue + '\n' : '#SBATCH -p ' + queueName + '\n'
+
+   def extNodes = checkCommand(preJobCommands, '#SBATCH -N')
+   def rmNodes = checkCommand(preJobCommands, 'RM #SBATCH -N')
+   preJobCommands = preJobCommands - extNodes
+   preJobCommands = preJobCommands - rmNodes
+   if (nodes != null && nodes != "" && rmNodes == null) out.print extNodes? extNodes + '\n' : '#SBATCH -N ' + nodes + '\n'
+
+   def extCpu = checkCommand(preJobCommands, '#SBATCH -n')
+   def rmCpu = checkCommand(preJobCommands, 'RM #SBATCH -n')
+   preJobCommands = preJobCommands - extCpu
+   preJobCommands = preJobCommands - rmCpu
+   if (cpuCount != null && cpuCount != "" && rmCpu == null) out.print extCpu? extCpu + '\n' : '#SBATCH -n ' + cpuCount + '\n'
+
+   def extMem = checkCommand(preJobCommands, '#SBATCH --mem=')
+   def rmMem = checkCommand(preJobCommands, 'RM #SBATCH --mem=')
+   preJobCommands = preJobCommands - extMem
+   preJobCommands = preJobCommands - rmMem
+   if (usedMem != null && usedMem != "" && rmMem == null) out.print extMem ? extMem + '\n': '#SBATCH --mem=' + usedMem + 'M\n'
+
    if (mailAddress != null && mailAddress != "") out.print '#SBATCH --mail-user=' + mailAddress + '\n'
    if (accountString != null && accountString != "" ) out.print '#SBATCH -A ' + accountString + '\n'
    if (maxWallTime != null && maxWallTime != "") out.print '#SBATCH -t ' + maxWallTime + '\n'