script<-commandArgs(trailingOnly=FALSE)[4]# recover script name, e.g., r_341_conf $check_lod_gael_conf. 1) .exe R path, 2) --slave, 3) --no-restore, 4) --file and 5) --args
args<-commandArgs(trailingOnly=TRUE)# recover arguments written after the call of the Rscript, ie after r_341_conf $check_lod_gael_conf
tempo.arg.names<-c("path.lib","path.in","path.out","path.function1","file.name1","ml.bootstrap.nb","project.name","label.size","optional.text","slurm.loop.nb","analysis.kind","cross.valid.ratio","random.seed")# objects names exactly in the same order as in the bash code and recovered in args
stop(paste0("\n\n============\n\nERROR: LOOP ",slurm.loop.nb," CANNOT FIND THE ",paste0(path.loop1,"loop",slurm.loop.nb,"_res_data.RData")," FILE\nDUE TO UNACTIVE BLOCKAGE OF THE LOOP 1 IN THE workflow.sh\n\n============\n\n"))
stop(paste0("\n\n============\n\nERROR: LOOP ",slurm.loop.nb," CANNOT FIND THE ",paste0(path.loop1,"loop1_discov_data.RData")," FILE\nDUE TO UNACTIVE BLOCKAGE OF THE LOOP 1 IN THE workflow.sh\n\n============\n\n"))
SUP_VAR="SCRIPT_USED=$SCRIPT_USED,CONFIG_FILE=$CONFIG_FILE,REMOVE_TMP=$REMOVE_TMP,OUTPUT_DIR_PATH_tempo=$OUTPUT_DIR_PATH_tempo"# all this must be injected into the TARS job
SUP_VAR="SCRIPT_USED=$SCRIPT_USED,JOB_ID=$JOB_ID,CONFIG_FILE=$CONFIG_FILE,REMOVE_TMP=$REMOVE_TMP,OUTPUT_DIR_PATH_tempo=$OUTPUT_DIR_PATH_tempo"# all this must be injected into the TARS job
LOCAL_USER_VAR+=" OUTPUT_DIR_PATH_tempo SUP_VAR"# do not forget the space before the variable name
COUNT=0
while[[$COUNT < $(($LOOP_NB_CONF+1))]];do
((COUNT=COUNT + 1))
COUNT=1
while[[$COUNT-lt$(($LOOP_NB_CONF+1))]];do# is less than
# next line cannot be put outside (which would have been convenient -> put into the SUP_VAR_tempo for display. But SUP_VAR_tempo for sbatch do not like spaces)
R_PROC2="${R_PROC} &> ${OUTPUT_DIR_PATH_tempo2}loop${COUNT}_r_console_messages.txt" # or "$R_PROC > ${OUTPUT_DIR_PATH_tempo2}loop${COUNT}_r_console_messages.txt 2>&1" # to add the estderror in the stdout
eval "$R_PROC2"
' | sbatch -p$DEDICATED_CONF--job-name=wait_loop1 --qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo--wait| tee-a${OUTPUT_DIR_PATH_tempo}/loop${COUNT}/loop${COUNT}_${PROJECT_NAME_CONF}_slurm_jobID.txt # write all th echo from the $PROC alaso into a log file
' | sbatch -p$DEDICATED_CONF--job-name=wait_loop1_${JOB_ID}--wait--qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo | tee-a${OUTPUT_DIR_PATH_tempo}/loop${COUNT}/loop${COUNT}_${PROJECT_NAME_CONF}_slurm_jobID.txt # write all th echo from the $PROC alaso into a log file
# tricky part of this sbatch because the SUP_VAR_tempo will be used in the script piped to sbatch
# next line cannot be put outside (which would have been convenient -> put into the SUP_VAR_tempo for display. But SUP_VAR_tempo for sbatch do not like spaces)
R_PROC2="${R_PROC} &> ${OUTPUT_DIR_PATH_tempo2}loop${SLURM_ARRAY_TASK_ID}_r_console_messages.txt" # or "$R_PROC > ${OUTPUT_DIR_PATH_tempo2}loop${SLURM_ARRAY_TASK_ID}_r_console_messages.txt 2>&1" # to add the estderror in the stdout
eval "$R_PROC2"
' | sbatch -p$DEDICATED_CONF--array=2-$LOOP_NB_CONF--job-name=wait_loop_all --qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo--wait| tee-a$(for((i = 2 ; i <=$LOOP_NB_CONF; i++));do echo${OUTPUT_DIR_PATH_tempo}/loop${i}/loop${i}_${PROJECT_NAME_CONF}_slurm_jobID.txt ;done)# tee is dispached in all the dir of the job array
' | sbatch -p$DEDICATED_CONF--array=2-$LOOP_NB_CONF--job-name=wait_loop_all_${JOB_ID}--wait--qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo | tee-a$(for((i = 2 ; i <=$LOOP_NB_CONF; i++));do echo${OUTPUT_DIR_PATH_tempo}/loop${i}/loop${i}_${PROJECT_NAME_CONF}_slurm_jobID.txt ;done)# tee is dispached in all the dir of the job array
# tricky part of this sbatch because the SUP_VAR_tempo will be used in the script piped to sbatch
# next line cannot be put outside (which would have been convenient -> put into the SUP_VAR_tempo for display. But SUP_VAR_tempo for sbatch do not like spaces)
R_PROC2="${R_PROC} &> ${OUTPUT_DIR_PATH_tempo2}loop${SLURM_ARRAY_TASK_ID}_r_console_messages.txt" # or "$R_PROC > ${OUTPUT_DIR_PATH_tempo2}loop${SLURM_ARRAY_TASK_ID}_r_console_messages.txt 2>&1" # to add the estderror in the stdout
eval "$R_PROC2"
' | sbatch -p$DEDICATED_CONF--array=1-$LOOP_NB_CONF--job-name=wait_loop_all --qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo--wait| tee-a$(for((i = 1 ; i <=$LOOP_NB_CONF; i++));do echo${OUTPUT_DIR_PATH_tempo}/loop${i}/loop${i}_${PROJECT_NAME_CONF}_slurm_jobID.txt ;done)# tee is dispached in all the dir of the job array
' | sbatch -p$DEDICATED_CONF--array=1-$LOOP_NB_CONF--job-name=wait_loop_all --wait--qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR_tempo | tee-a$(for((i = 1 ; i <=$LOOP_NB_CONF; i++));do echo${OUTPUT_DIR_PATH_tempo}/loop${i}/loop${i}_${PROJECT_NAME_CONF}_slurm_jobID.txt ;done)# tee is dispached in all the dir of the job array
# tricky part of this sbatch because the SUP_VAR_tempo will be used in the script piped to sbatch
# write the previous line exactly like this, with no comments, otherwise do not work
source $CONFIG_FILE # never forget this because another environment
# next line cannot be put outside (which would have been convenient -> put into the SUP_VAR_tempo for display. But SUP_VAR_tempo for sbatch do not like spaces)
R_PROC2="${R_PROC} &> ${OUTPUT_DIR_PATH_FINAL}/r_console_messages.txt" # or "$R_PROC > ${OUTPUT_DIR_PATH_FINAL}/r_console_messages.txt 2>&1" # to add the estderror in the stdout
eval "$R_PROC2"
' | sbatch -p$DEDICATED_CONF--job-name=compil --qos$QOS_CONF--time$MAX_RUNNING_TIME_CONF-c$NB_CPU_PER_TASK_CONF--mem-per-cpu$MEM_PER_CPU_CONF--mail-type END,FAIL --mail-user$MAIL_CONF--export$SUP_VAR | tee-a${OUTPUT_DIR_PATH_FINAL}/${PROJECT_NAME_CONF}_slurm_jobID.txt # write all th echo from the $PROC alaso into a log file
...
...
@@ -417,7 +424,7 @@ fi
################ LANDING
echo-e"\nALL CHECKS OK: PROCESS ENGAGED......................\n"
echo-e"\n\n......................ALL JOBS SUBMITTED\n\n"
STOPTIME=$(date)
LOCAL_USER_VAR+=" STOPTIME"# do not forget the space before the variable name