#!/bin/bash

## this script can be used to build the bio_db data repo on a SLURM cluster
## simple run: sbatch build_bio_db_repo_slurm
## check queue with squeue
##
## this script builds bio_db_repo at $HOME/.local/share/swi-prolog/pack/Downloads/<repo>
## complex output run: sbatch --output="${CLUST_OUTS}/%x-%j-outs-`fstamp`.txt" build_bio_db_repo_slurm

## Resource Request
#SBATCH --job-name=build_bio_db_repo_slurm
## %j is job number, %x is the job name above
#SBATCH --output=/mnt/lustre/RDS-live/angelopoulos/aurochs/clust/outs/%x-%j-outs.txt
## 6 hours
#SBATCH --time=1-6:00:00
#SBATCH --ntasks=1
## fixme: test against 1
#SBATCH --cpus-per-task=8
## why not :) :
#SBATCH --mem-per-cpu=128G

#customise these: make sure upsh is in your path
export PATH=/mnt/lustre/RDS-live/angelopoulos/local/compute_nodes/bin:/cm/shared/apps/slurm/current/sbin:/cm/shared/apps/slurm/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/cm/shared/apps/common
# likely you don't need to change LD_LIBRARY_PATH, uncomment and customise this if you do:
# export LD_LIBRARY_PATH=/mnt/lustre/RDS-live/angelopoulos/local/compute_nodes/lib:/lib64/:/usr/lib64/:/lib/:/usr/lib/

PACKS_DIR=/mnt/lustre/RDS-ephemeral/angelopoulos/local.home/src/packs/

## Job Steps
echo "Starting: in sbatch we asked for 8 threads and 128G mem"
echo `date`
echo $PATH
cd ${PACKS_DIR}/bio_db
git pull
cd auxil/build_repo/species

## run everything
srun upsh std_repo iactive=false in_subs=true

## only run human:
## cd human
## srun upsh std_human iactive=false in_subs=true

echo `date`
sleep 10
echo "The End"
# change urls to new central location
