From aa1de4ff7f066e81501d6d3cfd540c49fde5c30d Mon Sep 17 00:00:00 2001 From: Timothy Willard <9395586+TimothyWillard@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:21:51 -0400 Subject: [PATCH] Update conda env to use `~/.conda` Switch from using a conda environment specified by a path to a conda environment specified by a name assumed to be in `~/.conda`. Might work with an absolute path still, but requires testing. --- batch/hpc_init.sh | 6 +++--- build/hpc_install_or_update.sh | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/batch/hpc_init.sh b/batch/hpc_init.sh index cb04a4568..36a7a5c81 100644 --- a/batch/hpc_init.sh +++ b/batch/hpc_init.sh @@ -45,12 +45,11 @@ fi # Conda init if [ -z "${FLEPI_CONDA}" ]; then - echo -n "An explicit \$FLEPI_CONDA was not provided, please set one (or press enter to use '$USERDIR/flepimop-env'): " + echo -n "An explicit \$FLEPI_CONDA was not provided, please set one (or press enter to use 'flepimop-env'): " read FLEPI_CONDA if [ -z "${FLEPI_CONDA}" ]; then - export FLEPI_CONDA="$USERDIR/flepimop-env" + export FLEPI_CONDA="flepimop-env" fi - export FLEPI_CONDA=$( realpath "$FLEPI_CONDA" ) echo "Using '$FLEPI_CONDA' for \$FLEPI_CONDA." fi conda activate $FLEPI_CONDA @@ -116,6 +115,7 @@ Otherwise make sure this diagnostic info looks correct before continuing: * Cluster: $1 * User directory: $USERDIR * Work directory: $WORKDIR +* Flepi conda: $FLEPI_CONDA * Flepi path: $FLEPI_PATH * Project path: $PROJECT_PATH * Python: $WHICH_PYTHON diff --git a/build/hpc_install_or_update.sh b/build/hpc_install_or_update.sh index 3c343b6d6..9e74c7fda 100755 --- a/build/hpc_install_or_update.sh +++ b/build/hpc_install_or_update.sh @@ -68,24 +68,25 @@ fi # Setup the conda environment if [ -z "${FLEPI_CONDA}" ]; then - echo -n "An explicit \$FLEPI_CONDA was not provided, please set one (or press enter to use '$USERDIR/flepimop-env'): " + echo -n "An explicit \$FLEPI_CONDA was not provided, please set one (or press enter to use 'flepimop-env'): " read FLEPI_CONDA if [ -z "${FLEPI_CONDA}" ]; then - export FLEPI_CONDA="$USERDIR/flepimop-env" + export FLEPI_CONDA="flepimop-env" fi - export FLEPI_CONDA=$( realpath "$FLEPI_CONDA" ) echo "Using '$FLEPI_CONDA' for \$FLEPI_CONDA." fi -if [ ! -d $FLEPI_CONDA ]; then +FLEPI_CONDA_ENV_MATCHES=$( conda info --envs | awk '{print $1}' | grep -x "$FLEPI_CONDA" | wc -l ) +if [ "$FLEPI_CONDA_ENV_MATCHES" -eq 0 ]; then conda env create --prefix $FLEPI_CONDA --file $FLEPI_PATH/environment.yml -cat << EOF > $FLEPI_CONDA/conda-meta/pinned -r-arrow==17.0.0 -arrow==17.0.0 -EOF fi # Load the conda environment conda activate $FLEPI_CONDA +[ -e "$CONDA_PREFIX/conda-meta/pinned" ] && rm $CONDA_PREFIX/conda-meta/pinned +cat << EOF > $CONDA_PREFIX/conda-meta/pinned +r-arrow==17.0.0 +arrow==17.0.0 +EOF # Install the gempyor package from local pip install --editable --force-reinstall $FLEPI_PATH/flepimop/gempyor_pkg