Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#DRAFT/WIP 20 allow custom submissions to slurm #21

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 53 additions & 9 deletions scripts/submit_csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,32 @@ shift
TARGET=${1:-2}
shift

# environment variable to indicate whether the job is running on condor or slurm
SYSTEM=${SYSTEM:-condor}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYSTEM may be a bit generic. How about SCHEDULER or something like that?


# process csv file into jobs
CSV_FILE=$($(dirname $0)/csv_to_chunks.sh ${FILE} ${TARGET})
if [ -n "${CSV_FILE:-}" ]; then
# allow to set custom csv file for job instead of fetching from web archive
CSV_FILE=$(realpath -e ${CSV_FILE})
else
CSV_FILE=$($(dirname $0)/csv_to_chunks.sh ${FILE} ${TARGET})
fi

# create command line
EXECUTABLE="./scripts/run.sh"
ARGUMENTS="${TYPE} EVGEN/\$(file).\$(ext) \$(nevents) \$(ichunk)"
EXECUTABLE="$PWD/scripts/run.sh"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should use something that determines the directory of the current script, e.g. SCRIPTDIR=$(dirname $0) or so. Then this script can be run from outside the directory, and the files it generates can be better organized.

if [ ${SYSTEM} = "condor" ]; then
ARGUMENTS="${TYPE} EVGEN/\$(file).\$(ext) \$(nevents) \$(ichunk)"
elif [ ${SYSTEM} = "slurm" ]; then
Comment on lines +44 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if elif else fi can be turned into case statement

ARGUMENTS="${TYPE}"
# FIXME: This is not ideal. It prevents from submitting multiple jobs with different JUG_XL_TAG simultaneously.
cd scripts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above for SCRIPTDIR which would be useful here.

Also pushd-popd for directory stacks then.

wget --output-document install.sh https://get.epic-eic.org
sed -i 's/nightly/${JUG_XL_TAG}/g' install.sh
bash install.sh
cd ..
else
echo "Enter a valid SYSTEM value (condor or slurm)"
fi

# construct environment file
ENVIRONMENT=environment-$(date --iso-8601=minutes).sh
Expand All @@ -54,8 +74,12 @@ REQUIREMENTS=""
# construct input files
INPUT_FILES=${ENVIRONMENT}

# calculate number of jobs being submitted
NJOBS=$( wc -l ${CSV_FILE} | awk '{print $1}' )

# construct submission file
SUBMIT_FILE=$(basename ${CSV_FILE} .csv).submit

sed "
s|%EXECUTABLE%|${EXECUTABLE}|g;
s|%ARGUMENTS%|${ARGUMENTS}|g;
Expand All @@ -65,14 +89,34 @@ sed "
s|%INPUT_FILES%|${INPUT_FILES}|g;
s|%REQUIREMENTS%|${REQUIREMENTS}|g;
s|%CSV_FILE%|${CSV_FILE}|g;
s|%ACCOUNT%|${ACCOUNT:?Define ACCOUNT with the slurm account}|g;
s|%CAMPAIGN_LOG%|${CAMPAIGN_LOG:-$PWD}|g;
s|%TARGET%|$TARGET|g;
s|%NJOBS%|${NJOBS}|g;
" templates/${TEMPLATE}.submit.in > ${SUBMIT_FILE}

# submit job
condor_submit -verbose -file ${SUBMIT_FILE}

# create log dir
if [ $? -eq 0 ] ; then
for i in `condor_q | grep ^${USER} | tail -n1 | awk '{print($NF)}' | cut -d. -f1` ; do
mkdir -p LOG/CONDOR/osg_$i/
done
echo "Submitting ${NJOBS} to a ${SYSTEM} system"

if [ ${SYSTEM} = "condor" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case.

condor_submit -verbose -file ${SUBMIT_FILE}

# create log dir
if [ $? -eq 0 ] ; then
for i in `condor_q | grep ^${USER} | tail -n1 | awk '{print($NF)}' | cut -d. -f1` ; do
mkdir -p ${CAMPAIGN_LOG:-$PWD}/LOG/CONDOR/osg_$i/
done
fi
elif [ ${SYSTEM} = "slurm" ]; then
sbatch ${SUBMIT_FILE}

# create log dir
if [ $? -eq 0 ] ; then
for i in `squeue -u ${USER} | tail -n1 | awk '{$1=$1; print}' | awk -F" |_" '{print($1)}' | cut -d. -f1` ; do
mkdir -p ${CAMPAIGN_LOG:-$PWD}/LOG/SLURM/slurm_$i/
done
fi
else
echo "Enter a valid SYSTEM value (condor or slurm)"
fi
8 changes: 8 additions & 0 deletions templates/narval_csv.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export S3_ACCESS_KEY=%S3_ACCESS_KEY%
export S3_SECRET_KEY=%S3_SECRET_KEY%
export S3RW_ACCESS_KEY=%S3RW_ACCESS_KEY%
export S3RW_SECRET_KEY=%S3RW_SECRET_KEY%
export DETECTOR_VERSION=%DETECTOR_VERSION%
export DETECTOR_CONFIG=%DETECTOR_CONFIG%
export EBEAM=%EBEAM%
export PBEAM=%PBEAM%
22 changes: 22 additions & 0 deletions templates/narval_csv.submit.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#SBATCH --account=%ACCOUNT%
#SBATCH --array=1-%NJOBS%
#SBATCH --ntasks=1 # number of MPI processes
#SBATCH --mem-per-cpu=3G # memory; default unit is megabytes
#SBATCH --time=0-%TARGET%:00 # time (DD-HH:MM)
#SBATCH --output=%CAMPAIGN_LOG%/LOG/SLURM/slurm_%A/slurm_%A_%a.out # standard output log
#SBATCH --error=%CAMPAIGN_LOG%/LOG/SLURM/slurm_%A/slurm_%A_%a.err # standard error log

input_string=$(sed "${SLURM_ARRAY_TASK_ID}q;d" %CSV_FILE%)
read -r file ext nevents ichunk <<< $(echo "$input_string" | awk -F',' '{print $1, $2, $3, $4}')

echo $file
echo $ext
echo $nevents
echo $ichunk

cat << EOF | $(dirname %EXECUTABLE%)/eic-shell

%EXECUTABLE% %ARGUMENTS% EVGEN/${file}.${ext} ${nevents} ${ichunk}

EOF