diff --git a/bin/redirect b/bin/redirect index 33974ed..c7eda4b 100755 --- a/bin/redirect +++ b/bin/redirect @@ -1,12 +1,6 @@ #!/usr/bin/env bash -# This is a wrapper for spook python script -# It: -# - loads the appropriate conda environment -# - parses the variables directly to the python script -# - deactivate enrivonment - -SCRIPTNAME="$0" +SCRIPTNAME="$BASH_SOURCE" SCRIPTDIRNAME=$(readlink -f $(dirname "$SCRIPTNAME")) # add "bin" to PATH @@ -16,11 +10,46 @@ fi TOOLDIR=$(dirname "$SCRIPTDIRNAME") TOOLNAME=$(basename "$SCRIPTNAME") -# echo $TOOLNAME -# load appropriate conda env -. "/data/CCBR_Pipeliner/db/PipeDB/Conda/etc/profile.d/conda.sh" && conda activate py311 +# find out if you are running on biowulf or frce +nbiowulf=$(scontrol show config 2>/dev/null | grep -i -c biowulf) +if [[ "$nbiowulf" > 0 ]];then ISBIOWULF=true; else ISBIOWULF=false;fi +nfrce=$(scontrol show config 2>/dev/null | grep -i -c fsitgl) +if [[ "$nfrce" > 0 ]];then ISFRCE=true; else ISFRCE=false;fi +if [[ "$HOSTNAME" == "helix.nih.gov" ]];then ISBIOWULF=true; else ISBIOWULF=false;fi -${TOOLDIR}/${TOOLNAME} "$@" || true +# load conda +run=1 +if [[ $ISBIOWULF == true ]];then + . "/data/CCBR_Pipeliner/db/PipeDB/Conda/etc/profile.d/conda.sh" + conda activate py311 + run=0 +elif [[ $ISFRCE == true ]];then + . "/mnt/projects/CCBR-Pipelines/resources/miniconda3/etc/profile.d/conda.sh" + conda activate py311 + run=0 +else + echo "You are NOT running on BIOWULF or on FRCE" + version=$(python --version 2>/dev/null | awk '{print $NF}') + major=$(echo $version|awk -F"." '{print $1}') + minor=$(echo $version|awk -F"." '{print $2}') + if [[ "$major" -eq "3" ]]; then + if [[ "$minor" -ge "11" ]];then + echo "Satisfatory version of Python available: $version" + xxhashfound=$(python -c "import xxhash" 2> /dev/null; echo $?) + if [[ "$xxhashfound" -eq "0" ]];then + echo "xxhash python library present!" + run=0 + fi + fi + fi + if [[ "$run" != "0" ]];then + echo "Please make sure that:" + echo "Python version >= 3.11 with xxhash library is required!" + fi +fi -conda deactivate +if [[ "$run" == "0" ]]; then + ${TOOLDIR}/${TOOLNAME} "$@" || true + conda deactivate 2>/dev/null +fi