2017-08-23 17:04:33 +00:00
|
|
|
#!/usr/bin/bash
|
|
|
|
set -o nounset
|
2017-08-23 22:23:21 +00:00
|
|
|
set -o errexit
|
|
|
|
|
2017-09-20 10:37:57 +00:00
|
|
|
BASEDIR=$( cd $(dirname "$0"); cd ..; pwd -P )
|
|
|
|
|
2017-09-02 16:05:42 +00:00
|
|
|
NRJOBS=${NRJOBS:-256}
|
|
|
|
echo "Using $NRJOBS jobs"
|
|
|
|
|
2017-09-20 10:37:57 +00:00
|
|
|
JOBRANGE=${JOBRANGE:-1-$NRJOBS}
|
|
|
|
echo "Executing jobs $JOBRANGE"
|
|
|
|
|
2017-09-10 11:20:23 +00:00
|
|
|
ARCHIVE=${ARCHIVE:-$(ssh sharc.shef.ac.uk find /shared/brucker_research1/Shared/BrowserExtensions/archive/.snapshot -maxdepth 1 -name \"D*\" | sort -r | head -n1)}
|
2017-09-02 16:05:42 +00:00
|
|
|
echo "Using archive: $ARCHIVE"
|
|
|
|
|
|
|
|
TARGETDIR="${TARGETDIR:-/data/\$USER}/create-db-$(date +%Y%m%d-%H%M%S)"
|
|
|
|
echo "Using target dir: $TARGETDIR"
|
2017-08-23 17:04:33 +00:00
|
|
|
|
2017-09-20 10:37:57 +00:00
|
|
|
SING_IMG_SRC="${SING_IMG_SRC:-/shared/brucker_research1/Shared/BrowserExtensions/excrawl.img}"
|
|
|
|
SING_IMG="$TARGETDIR/excrawl.img"
|
|
|
|
if ! ssh sharc.shef.ac.uk [ -f "$SING_IMG_SRC" ]; then
|
|
|
|
echo -n "$SING_IMG_SRC does not exist! Generate new image and push? (yes/abort): "
|
|
|
|
read confirm
|
|
|
|
if [ "$confirm" != yes ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "Creating new image ..."
|
|
|
|
(cd "$BASEDIR/singularity"; ./build.sh)
|
|
|
|
echo "Pushing new image ..."
|
2017-10-04 22:17:06 +00:00
|
|
|
scp "$BASEDIR/singularity/ExtensionCrawler.img" sharc.shef.ac.uk:"$SING_IMG_SRC"
|
|
|
|
rm "$BASEDIR/singularity/ExtensionCrawler.img"
|
2017-09-20 10:37:57 +00:00
|
|
|
fi
|
2017-08-23 17:04:33 +00:00
|
|
|
echo "Creating dirs ..."
|
2017-08-23 22:23:21 +00:00
|
|
|
ssh sharc.shef.ac.uk mkdir -p $TARGETDIR/logs
|
2017-08-23 17:04:33 +00:00
|
|
|
|
2017-09-20 10:37:57 +00:00
|
|
|
echo "Copying $SING_IMG_SRC to $SING_IMG"
|
|
|
|
ssh sharc.shef.ac.uk cp "$SING_IMG_SRC" "$SING_IMG"
|
|
|
|
|
|
|
|
echo "Pushing sge script ..."
|
|
|
|
scp "$BASEDIR/sge/create-db.sge" sharc.shef.ac.uk:"$TARGETDIR/create-db.sge"
|
2017-08-23 17:04:33 +00:00
|
|
|
|
2017-09-21 19:09:00 +00:00
|
|
|
if ! [ -z "${EXTIDLISTFILE:-}" ]; then
|
|
|
|
echo "Pushing list with extension ids ..."
|
|
|
|
scp "$EXTIDLISTFILE" sharc.shef.ac.uk:"$TARGETDIR/ids"
|
|
|
|
fi
|
|
|
|
|
2017-08-23 17:04:33 +00:00
|
|
|
echo "Starting job ..."
|
2017-08-23 22:23:21 +00:00
|
|
|
ssh sharc.shef.ac.uk \
|
2017-09-20 10:58:56 +00:00
|
|
|
SING_IMG=\"$SING_IMG\" \
|
2017-08-23 22:23:21 +00:00
|
|
|
ARCHIVE=\"$ARCHIVE\" \
|
|
|
|
BASEDIR=\"$TARGETDIR\" \
|
2017-09-02 16:05:42 +00:00
|
|
|
MAX_SGE_TASK_ID=\"$NRJOBS\" \
|
2017-08-23 22:23:21 +00:00
|
|
|
qsub \
|
|
|
|
-V \
|
2017-09-15 20:32:12 +00:00
|
|
|
-m a \
|
2017-09-22 12:09:15 +00:00
|
|
|
-l rmem=8G \
|
2017-09-15 20:32:12 +00:00
|
|
|
-M "msherzberg1@sheffield.ac.uk" \
|
2017-09-20 10:37:57 +00:00
|
|
|
-t $JOBRANGE \
|
2017-08-23 17:04:33 +00:00
|
|
|
-j yes \
|
|
|
|
-o "$TARGETDIR/logs" \
|
2017-09-20 10:37:57 +00:00
|
|
|
"$TARGETDIR/create-db.sge" \
|
2017-09-02 16:50:16 +00:00
|
|
|
$*
|