Skip to content

Commit

Permalink
Update conda env to use ~/.conda
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TimothyWillard committed Oct 21, 2024
1 parent b73b5ab commit aa1de4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions batch/hpc_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions build/hpc_install_or_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa1de4f

Please sign in to comment.