-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make rapids-configure-conda-channels idempotent (#104)
- Loading branch information
Showing
1 changed file
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |