Skip to content

Commit

Permalink
Conditional deactivate env, then activate new env
Browse files Browse the repository at this point in the history
This is to address a bug where a currently active env would cause the
hpc init script to load the flepimop env not cleanly. Determine the
currently active env if there is one and if it is not the flepimop env
deactivate it with message to the user.
  • Loading branch information
TimothyWillard committed Nov 7, 2024
1 parent 092069a commit 1c81583
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions batch/hpc_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ if [ -z "${FLEPI_CONDA}" ]; then
fi
echo "Using '$FLEPI_CONDA' for \$FLEPI_CONDA."
fi
CURRENT_CONDA_ENV=$( conda info | grep "active environment" | awk -F ':' '{print $2}' | xargs )
if [ "$CURRENT_CONDA_ENV" != "None" ] && [ "$CURRENT_CONDA_ENV" != "$FLEPI_CONDA" ]; then
echo "Detected an active conda environment '$CURRENT_CONDA_ENV'. This will be deactivated and the '$FLEPI_CONDA' environment will be activated."
conda deactivate
fi
conda activate $FLEPI_CONDA

# Check the conda environment is valid
Expand Down

0 comments on commit 1c81583

Please sign in to comment.