diff --git a/video_prediction_savp/env_setup/generate_workflow_scripts b/video_prediction_savp/env_setup/generate_workflow_scripts new file mode 100644 index 0000000000000000000000000000000000000000..c3bd20cfcab4b18ab4a544cf5058a8f519184d28 --- /dev/null +++ b/video_prediction_savp/env_setup/generate_workflow_scripts @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# **************** Description **************** +# Converts given template workflow script (path has to be passed as first argument) to +# an executable workflow (Batch) script. +# Note, that this first argument has to be passed with "_template.sh" omitted! +# A second argument can be passed to set the e-mail address. +# On HDF-ML and Juwels, where jutil is available, this is done automatically, +# i.e. no second argument is required. +# Example: +# ./generate_workflow_scripts.sh ../HPC_scripts/generate m.mustermann@fz-juelich.de +# **************** Description **************** +# +#sanity checks +if ! [ $# -eq 1]; then + echo "ERROR: Pass path to workflow script to be generated..." +else + curr_script = $1 +fi + +if ! [[ -f ${curr_script}_template.sh ]]; then + echo "WARNING: Could not find expected Batch script '${curr_script}_template.sh'." + echo "Thus, no corresponding executable script is created!" + exit 0 # still ok, i.e. only a WARNING is raised +fi +# create copy of template which is modified subsequenty +cp ${curr_script}_template.sh ${curr_script}_op.sh +# remove template identifiers +num_lines=`awk '/Template identifiers/{ print NR }' +line_s=`echo ${num_lines} | cut -d' ' -f 1` +line_e=`echo ${num_lines} | cut -d' ' -f 2` +if [[ ${line_s} == "" || ${line_e} == "" ]]; then + echo "ERROR: ${curr_script}_template.sh exists, but does not seem to be a valid template script." + exit 1 +else + sed -e '${line_s},${line_e}d' ${curr_script}_op.sh +fi + +# set correct e-mail address if possible, otherwise remove +if ! [ -z "$2" ]; then + USER_EMAIL=$2 +else + if [ command -v jutil ]; then + USER_EMAIL=$(jutil user show -o json | grep email | cut -f2 -d':' | cut -f1 -d',' | cut -f2 -d'"') + else + USER_MAIL="" + fi +fi +sed -i "s/--mail-user=.*/--mail-user=$USER_EMAIL/g" ${curr_script}_op.sh +