Skip to content

Commit

Permalink
Create and solve envs using mamba (nebari-dev#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
iameskild authored Nov 12, 2021
1 parent b86e32c commit 47a42b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -xe
ENV_FILE="${1}"; shift # path to environment yaml or lock file
ENV_FILE="${1}"; shift # path to environment yaml or lock file
NEW_ENV="${1}"; shift # true or false indicating whether env update should occur

# Capture last optional arg or set a ENV_NAME. This can be changed but be
Expand All @@ -24,13 +24,13 @@ if ! ${NEW_ENV};then
exit 1
fi
echo Installing into current conda environment
conda env update -f "${ENV_FILE}"
mamba env update -f "${ENV_FILE}"

# Env not being updated... create one now:
elif [[ "${SKIP_CONDA_SOLVE}" == "no" ]];then
conda env create --prefix=/opt/conda/envs/${ENV_NAME} -f "${ENV_FILE}"
mamba env create --prefix=/opt/conda/envs/${ENV_NAME} -f "${ENV_FILE}"
elif [[ "${SKIP_CONDA_SOLVE}" == "yes" ]];then
conda create --prefix=/opt/conda/envs/${ENV_NAME} --file "${ENV_FILE}"
mamba create --prefix=/opt/conda/envs/${ENV_NAME} --file "${ENV_FILE}"

# This needs to be set using the ENV directive in the docker file
PATH="/opt/conda/envs/${ENV_NAME}/bin:${PATH}"
Expand All @@ -46,10 +46,10 @@ fi
/opt/conda/bin/conda list

# ========== cleanup conda ===========
/opt/conda/bin/conda clean -afy
/opt/conda/bin/mamba clean -afy
# remove unnecissary files (statis, js.maps)
find /opt/conda/ -follow -type f -name '*.a' -delete
find /opt/conda/ -follow -type f -name '*.js.map' -delete

# Fix permissions
# Fix permissions
fix-permissions "/opt/conda/envs/${ENV_NAME}" || fix-permissions /opt/conda/bin
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ mv Miniconda3-$CONDA_VERSION-Linux-x86_64.sh miniconda.sh
sh ./miniconda.sh -b -p /opt/conda
rm miniconda.sh miniconda.checksum

# install mamba and clean up
conda install -y -c conda-forge mamba
mamba clean -afy
find /opt/conda/ -follow -type f -name '*.a' -delete
find /opt/conda/ -follow -type f -name '*.js.map' -delete

ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh

mkdir -p /etc/conda
Expand Down

0 comments on commit 47a42b8

Please sign in to comment.