From 7150fbae5d3132f8d5b927123f6e267492d8378c Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Mon, 27 Jul 2026 12:30:47 -1000 Subject: [PATCH] Use a proper libcuvs library when RAPIDS_VERSION points to a PR branch (#181) Many `cuvs-lucene` PRs depend on `cuvs` PRs that have not yet been merged. There is a way to test such `cuvs-lucene` PRs in CI by temporary pointing `RAPIDS_VERSION` to the `cuvs` PR branch. Unfortunately, this approach only works when the C portion of `cuvs` has not changed, because it relies on a conda's `libcuvs` rather than building it from source. This PR works around this by downloading the pre-built libcuvs conda artifact from the cuVS PR's own CI run via gh run download. The artifact is extracted with rapids-extract-conda-files and prepended to LD_LIBRARY_PATH, so the Java bindings are built and tested against the correct library. Authors: - Igor Motov (https://github.com/imotov) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) - Corey J. Nolet (https://github.com/cjnolet) URL: https://github.com/NVIDIA/cuvs-lucene/pull/181 --- build.sh | 23 ++++++++++++++++++++--- ci/build_java.sh | 7 ++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 4ec8c087..39322568 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 set -e -u -o pipefail @@ -15,21 +15,38 @@ function hasArg { (( NUMARGS != 0 )) && (echo " ${ARGS} " | grep -q " $1 ") } + if hasArg --build-cuvs-java; then CUVS_WORKDIR="cuvs-workdir" CUVS_GIT_REPO="https://github.com/rapidsai/cuvs.git" + BRANCH=$(cat "RAPIDS_BRANCH") if [[ -d "$CUVS_WORKDIR" && -n "$(ls -A "$CUVS_WORKDIR")" ]]; then echo "Directory '$CUVS_WORKDIR' exists and is not empty." pushd $CUVS_WORKDIR git pull else - BRANCH=$(cat "RAPIDS_BRANCH") echo "Directory '$CUVS_WORKDIR' does not exist or is empty. Cloning the cuvs's '$BRANCH' branch." # Correct branch selection is crucial to avoid version mismatch issues when testing. git clone --branch "$BRANCH" $CUVS_GIT_REPO $CUVS_WORKDIR pushd $CUVS_WORKDIR fi - ./build.sh java + + # libcuvs comes from the conda packages, so normally only the java bindings have + # to be built. For a pull request, the conda packages do not contain the PR's + # changes, so CI downloads the pre-built libcuvs artifact from the PR's own CI run. + CUVS_BUILD_TARGETS=("java") + if hasArg --use-pr-libcuvs && [[ "$BRANCH" == pull-request/* ]]; then + PR_NUM="${BRANCH#pull-request/}" + echo "Downloading libcuvs conda artifact from cuvs PR #${PR_NUM}..." + LIBCUVS_CONDA_DIR=$(rapids-get-pr-artifact NVIDIA/cuvs "$PR_NUM" cpp conda) + LIBCUVS_DIR=$(rapids-extract-conda-files "$LIBCUVS_CONDA_DIR") + # The downloaded library has to take precedence over the one provided by the + # conda packages, both here and while running the java tests. + LD_LIBRARY_PATH="$LIBCUVS_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + export LD_LIBRARY_PATH + echo "LD_LIBRARY_PATH is: $LD_LIBRARY_PATH" + fi + ./build.sh "${CUVS_BUILD_TARGETS[@]}" popd fi diff --git a/ci/build_java.sh b/ci/build_java.sh index 173ca55c..f9e3c1af 100755 --- a/ci/build_java.sh +++ b/ci/build_java.sh @@ -1,6 +1,6 @@ #!/bin/bash -# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. +# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 set -euo pipefail @@ -16,6 +16,11 @@ fi # Always build cuvs-java when running the pipeline EXTRA_BUILD_ARGS+=("--build-cuvs-java") +# When RAPIDS_BRANCH points at a cuvs pull request, the libcuvs from the conda +# packages does not contain the PR's changes, so download the pre-built artifact +# from the PR's CI run instead. Only done in CI, local builds use the conda packages. +EXTRA_BUILD_ARGS+=("--use-pr-libcuvs") + # shellcheck disable=SC1091 . /opt/conda/etc/profile.d/conda.sh