Skip to content

Commit

Permalink
make rapids-configure-conda-channels idempotent (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed May 14, 2024
1 parent b86b530 commit 90067c5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tools/rapids-configure-conda-channels
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
#!/bin/bash
# A utility script that configures conda channels

set -euo pipefail

conda_channel_in_config() {
channel_id=${1:?err}
conda config --json --get channels \
| channel_id="${channel_id}" jq -r --exit-status '.get.channels | any(. == env.channel_id )'
}

# Only try to run 'conda config --remove' if the channel exists in the config.
# This is here to avoid errors if this script is invoked multiple times in the same environment.
remove_conda_channel() {
channel_id=${1:?err}
if conda_channel_in_config "${channel_id}" > /dev/null; then
conda config --system --remove channels "${channel_id}"
else
echo "[rapids-configure-conda-channels] channel '${channel_id}' not found via 'conda config --get channels'"
fi
}

# Remove nightly channels if build is a release build
if rapids-is-release-build; then
conda config --system --remove channels rapidsai-nightly
conda config --system --remove channels dask/label/dev
remove_conda_channel 'rapidsai-nightly'
remove_conda_channel 'dask/label/dev'
else
# exclude stable channel from all non-release builds.
conda config --system --remove channels rapidsai
remove_conda_channel 'rapidsai'
fi

0 comments on commit 90067c5

Please sign in to comment.