Skip to content

rapids-rattler-channel-string: add support for prepending channels - #176

Merged
jameslamb merged 2 commits into
mainfrom
gha-artifacts/rattler-prepend
May 14, 2025
Merged

rapids-rattler-channel-string: add support for prepending channels#176
jameslamb merged 2 commits into
mainfrom
gha-artifacts/rattler-prepend

Conversation

@jameslamb

@jameslamb jameslamb commented May 13, 2025

Copy link
Copy Markdown
Member

Contributes to https://github.com/rapidsai/build-infra/issues/237

Contributes to rapidsai/build-planning#14

Splitting this off from #/173

Overview

As of this PR, if a bash array RAPIDS_PREPENDED_CONDA_CHANNELS is detected whenever rapids-rattler-channel-string is sourced, it prepends each element of that array the channel list passed to rattler-build (RATTLER_CHANNELS).

Notes for Reviewers

Benefits of these changes

Helps with simplifying "use packages from one PR in another PR's CI" (related: rapidsai/docs#601).

With this, you could create a script like ci/use_conda_packages_from_prs.sh and source it at the top of every ci/build*.sh, without any other changes to ci/build*.sh scripts required:

# download CI artifacts
LIBRAFT_CHANNEL=$(rapids-get-pr-conda-artifact raft 789 python)
LIBRMM_CHANNEL=$(rapids-get-pr-conda-artifact rmm 1909 cpp)

# For `rattler` builds:
#
# Add these channels to the array checked by 'rapids-rattler-channel-string'.
RAPIDS_PREPENDED_CONDA_CHANNELS=(
    "${LIBRAFT_CHANNEL}"
    "${LIBRMM_CHANNEL}"
)
export RAPIDS_PREPENDED_CONDA_CHANNELS

# For tests and `conda-build` builds:
#
# Add these channels to the system-wide conda configuration.
for _channel in "${RAPIDS_PREPENDED_CONDA_CHANNELS[@]}"
do
   conda config --system --add channels "${_channel}"
done

More Details

rapids-rattler-channel-string (first added in #143) defines a bash array, RATTLER_CHANNELS, containing a list of conda channels to be used when building the build/host/test environments in rattler-build builds. Like this:

source rapids-rattler-channel-string
rattler-build build --recipe conda/recipes/cuml \
                    "${RATTLER_ARGS[@]}" \
                    "${RATTLER_CHANNELS[@]}"

(cuml code link)

The ordering in that channel list is important... for any projects using conda "strict" channel priority, those channels are searched in order for packages, and the first package found is used.

When testing something like "use packages from this cuvs PR in CI on this cuml PR", it's desirable to download the upstream PR's CI artifacts and tell rattler-build to use them. One useful mechanism for that is to put the "channels" (local directories) holding those downloaded files into the channel list. It's important that you be able to prepend them, so strict channel priority will result in the locally-downloaded packages being chosen.

This change makes that possible for rattler-build builds (see above and rapidsai/docs#601).

How I tested this

Tested this as part of #173, via NVIDIA/cudf#18747

Evidence that it worked: NVIDIA/cudf#18747 (comment)

@jameslamb jameslamb changed the title WIP: rapids-rattler-channel-string: add support for prepending channels rapids-rattler-channel-string: add support for prepending channels May 14, 2025
@jameslamb
jameslamb requested a review from gforsyth May 14, 2025 03:04
@jameslamb
jameslamb marked this pull request as ready for review May 14, 2025 03:04
@jameslamb
jameslamb requested a review from a team as a code owner May 14, 2025 03:04

@gforsyth gforsyth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One typo, but this looks great, approving so you can merge at your discretion!

Comment thread tools/rapids-rattler-channel-string Outdated
Comment on lines +3 to +35
# Populates shell variables expected to be used by build scripts invoking `ratther-build`.
#
# This is intended to be `source`'d, not invoked as an executable.
#
# Variables:
#
# * RATTLER_ARGS = Bash array of arguments to be passed to invocations of `rattler-build build`
# * RATTLER_CHANNELS = Bash array of conda channels, where each item is prefixed with '--channel '.
# If variable `RAPIDS_PREPENDED_CONDA_CHANNELS` is defined when this script is invoked,
# it is expected to hold a bash array with additional conda channels (omitting the '--channel ' prefix).
# Each of these is PREPENDED to the output in `RATTLER_CHANNELS`.
#
# Usage:
#
# # standard usage
# source rapids-rattler-channel-string
# rattler-build build \
# --recipe conda/recipes/librmm \
# --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \
# "${RATTLER_CHANNELS[@]}"
#
# # prepend custom channels
# LIBRMM_CHANNEL=$(rapids-get-pr-conda-artifact rmm 1909 cpp)
# RMM_CHANNEL=$(rapids-get-pr-conda-artifact rmm 1909 python)
# RAPIDS_PREPENDED_CONDA_CHANNELS=("${LIBRMM_CHANNEL}" "${RMM_CHANNEL}")
#
# source rapids-rattler-channel-string
# rattler-build build \
# --recipe conda/recipes/librmm \
# --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \
# "${RATTLER_CHANNELS[@]}"
#

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for documenting this!!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No prob, no prob 😊

Comment thread tools/rapids-rattler-channel-string Outdated
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
@jameslamb
jameslamb merged commit 6b139b6 into main May 14, 2025
@jameslamb
jameslamb deleted the gha-artifacts/rattler-prepend branch May 14, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants