Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-34184: Add -C channel option and force conda-forge. #158

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion nominal.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $ bash Mambaforge-Darwin-x86_64.sh -b -p PWD/conda
$ rm -f Mambaforge-Darwin-x86_64.sh
$ setup conda/mamba shell functions
Selected rubin-env=latest
$ conda create -y -n lsst-scipipe-latest --strict-channel-priority rubin-env=latest
$ conda create -c conda-forge --strict-channel-priority -y -n lsst-scipipe-latest rubin-env=latest
$ conda activate lsst-scipipe-latest
$ echo https://eups.lsst.codes/stack/osx/10.9/conda-system/miniconda3-py38_4.9.2-latest|https://eups.lsst.codes/stack/src > $EUPS_PATH/pkgroot
$ cat > loadLSST.sh
Expand Down
31 changes: 23 additions & 8 deletions scripts/lsstinstall
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ update=false
eups_root=https://eups.lsst.codes/stack
use_tarball=true
use_source=true
# channels is in _reverse_ priority order
channels=

print_error () {
>&2 echo "$@"
Expand All @@ -28,7 +30,7 @@ usage () {
cat <<EOF
usage: lsstinstall [-n]
[-T EUPS_TAG | -X EUPS_TAG | -v RUBINENV_VERSION]
[-e ENV_NAME] [-u] [-p CONDA_PATH] [-P] [-E EUPS_URL]
[-e ENV_NAME] [-u] [-p CONDA_PATH] [-P] [-C CHANNEL] [-E EUPS_URL]
[-B] [-S] [-h]
Installs the Rubin software conda environment.
Enables the eups distrib install command for Science Pipelines packages.
Expand All @@ -50,6 +52,9 @@ usage: lsstinstall [-n]
If it does not exist, it will be created.
If a conda is activated, it will be used, ignoring this option.
-P -- DO NOT use an existing activated conda; always install a new one.
-C CHANNEL
-- Use the given conda channel before the conda-forge channel.
May be repeated; first has highest priority.
-E EUPS_URL
-- Select a different EUPS distribution server root URL
(default=https://eups.lsst.codes/stack).
Expand All @@ -63,7 +68,7 @@ EOF
exit 1
}

while getopts nBST:X:v:e:up:PE:bcth opt; do
while getopts nBST:X:v:e:up:PC:E:bcth opt; do
case "$opt" in
n)
dryrun="echo \$ "
Expand Down Expand Up @@ -105,6 +110,9 @@ while getopts nBST:X:v:e:up:PE:bcth opt; do
# Force conda installation by removing knowledge of current conda
unset CONDA_EXE
;;
C)
channels="$OPTARG $channels"
;;
E)
eups_root="$OPTARG"
;;
Expand All @@ -118,6 +126,7 @@ while getopts nBST:X:v:e:up:PE:bcth opt; do
;;
esac
done
channels="conda-forge $channels"

# Configure

Expand Down Expand Up @@ -201,6 +210,14 @@ fi

mamba=conda
command -v mamba >/dev/null && mamba=mamba && export MAMBA_NO_BANNER=1
run_mamba () {
subcmd=$1; shift
set -- --strict-channel-priority "$@"
for c in $channels; do
set -- -c "$c" "$@"
done
$dryrun $mamba "$subcmd" "$@"
}

# Determine rubin-env version

Expand Down Expand Up @@ -264,8 +281,7 @@ if [ "$use_existing" = true ]; then
echo "Using existing environment $rubinenv_name"
if [ "$update" = true ] && [ "$exact" != true ] && [ -z "$env_hash" ]; then
echo "Updating rubin-env=$rubinenv_version"
$dryrun $mamba update -y -n "$rubinenv_name" \
--strict-channel-priority "rubin-env=$rubinenv_version"
run_mamba update -y -n "$rubinenv_name" "rubin-env=$rubinenv_version"
fi
elif [ "$exact" = true ] || [ -n "$env_hash" ]; then
if [ -n "$env_hash" ]; then
Expand All @@ -281,15 +297,14 @@ elif [ "$exact" = true ] || [ -n "$env_hash" ]; then
fi
$dryrun run_curl -o "${eups_tag}.env" "$url" \
|| fail "Unable to download environment spec for tag $eups_tag"
$dryrun $mamba create -y -n "$rubinenv_name" --file "${eups_tag}.env"
run_mamba create -y -n "$rubinenv_name" --file "${eups_tag}.env"
$dryrun rm -f "${eups_tag}.env"
if [ -n "$env_hash" ]; then
# scipipe_conda_env did not have eups
$dryrun $mamba install -y -n "$rubinenv_name" --no-update-deps eups
run_mamba install -y -n "$rubinenv_name" --no-update-deps eups
fi
else
$dryrun $mamba create -y -n "$rubinenv_name" \
--strict-channel-priority "rubin-env=$rubinenv_version"
run_mamba create -y -n "$rubinenv_name" "rubin-env=$rubinenv_version"
fi

# Activate environment to set EUPS_PATH
Expand Down
8 changes: 6 additions & 2 deletions test-lsstinstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ diff <( ./scripts/lsstinstall -n ) <( ./scripts/lsstinstall -nc -b -t )
./scripts/lsstinstall -n -X w_2021_01 | grepf '\$ run_curl -o w_2021_01\.env https://raw\.githubusercontent\.com/lsst/scipipe_conda_env/cb4e2dc/etc/conda-.*\.lock'
# Hash environments are always exact.
./scripts/lsstinstall -n -X w_2021_01 | grepf '\$ conda activate lsst-scipipe-cb4e2dc$'
./scripts/lsstinstall -n -v 0.4.2 | grepf '\$ [cm][oa][nm][db]a create -y -n lsst-scipipe-0\.4\.2 --strict-channel-priority rubin-env=0\.4\.2'
./scripts/lsstinstall -n -v 0.4.2 | grepf '\$ [cm][oa][nm][db]a create -c conda-forge --strict-channel-priority -y -n lsst-scipipe-0\.4\.2 rubin-env=0\.4\.2'
./scripts/lsstinstall -n -v cb4e2dc | grepf '\$ run_curl -o cb4e2dc\.env https://raw\.githubusercontent\.com/lsst/scipipe_conda_env/cb4e2dc/etc/conda-.*\.lock'
./scripts/lsstinstall -n -v cb4e2dc | grepf '\$ [cm][oa][nm][db]a create -y -n lsst-scipipe-cb4e2dc --file cb4e2dc\.env'
./scripts/lsstinstall -n -v cb4e2dc | grepf '\$ [cm][oa][nm][db]a create -c conda-forge --strict-channel-priority -y -n lsst-scipipe-cb4e2dc --file cb4e2dc\.env'

# Check environment name handling.
./scripts/lsstinstall -n -e foo-lsst | grepf '\$ conda activate foo-lsst'
Expand Down Expand Up @@ -102,6 +102,10 @@ CONDA_EXE="somewhere/bin/conda" ./scripts/lsstinstall -n -P -p "$testdir" | grep
rm -rf "$testdir"
)

# Check channel handling
./scripts/lsstinstall -n -C mydev | grepf ' -c mydev -c conda-forge'
./scripts/lsstinstall -n -C mydev -C other | grepf ' -c mydev -c other -c conda-forge'

# Test for argument parsing failures
xfail ./scripts/lsstinstall -n -v cb4e2dc -T w_2021_11
xfail ./scripts/lsstinstall -n -v cb4e2dc -X w_2021_11
Expand Down