Skip to content

Commit

Permalink
fix: fix #91
Browse files Browse the repository at this point in the history
  • Loading branch information
kopardev committed Feb 28, 2024
1 parent e58fd18 commit fc1d2d1
Showing 1 changed file with 41 additions and 12 deletions.
53 changes: 41 additions & 12 deletions bin/redirect
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit fc1d2d1

Please sign in to comment.