Skip to content

Commit b7e628e

Browse files
author
Igor Motov
committed
Update cuvs-lucene build scripts
1 parent 2d2af27 commit b7e628e

89 files changed

Lines changed: 381 additions & 1492 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yaml‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,32 @@ jobs:
189189
artifact-name: "cuvs-java-cuda${{ matrix.CUDA_VER }}"
190190
file_to_upload: "java/cuvs-java/target/"
191191
sha: ${{ inputs.sha }}
192+
lucene-build:
193+
# Depends on the Java job for the cuvs-java artifact that cuvs-lucene builds against.
194+
needs: [java-build-matrix, java-build]
195+
permissions:
196+
actions: read
197+
contents: read
198+
id-token: write
199+
packages: read
200+
pull-requests: read
201+
secrets: inherit # zizmor: ignore[secrets-inherit]
202+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
203+
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
204+
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
205+
strategy:
206+
fail-fast: false
207+
matrix: ${{ fromJSON(needs.java-build-matrix.outputs.matrix) }}
208+
with:
209+
build_type: ${{ inputs.build_type || 'branch' }}
210+
branch: ${{ inputs.branch }}
211+
arch: "amd64"
212+
date: ${{ inputs.date }}
213+
container_image: "rapidsai/ci-conda:26.10-cuda${{ matrix.CUDA_VER }}-${{ matrix.LINUX_VER }}-py${{ matrix.PY_VER }}"
214+
script: "ci/build_lucene.sh cuvs-java-cuda${{ matrix.CUDA_VER }}"
215+
artifact-name: "cuvs-lucene-cuda${{ matrix.CUDA_VER }}"
216+
file_to_upload: "java/cuvs-lucene/target/"
217+
sha: ${{ inputs.sha }}
192218
python-build:
193219
needs: [build-details, cpp-build]
194220
permissions:

‎.github/workflows/pr.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- rocky8-clib-tests
2727
- conda-java-build-and-tests-matrix
2828
- conda-java-build-and-tests
29+
- conda-lucene-build-and-tests
2930
- rust-build-matrix
3031
- rust-build
3132
- go-build-matrix
@@ -143,12 +144,17 @@ jobs:
143144
- '!README.md'
144145
- '!SECURITY.md'
145146
- '!ci/build_docs.sh'
147+
- '!ci/build_go.sh'
148+
- '!ci/build_java.sh'
149+
- '!ci/build_lucene.sh'
146150
- '!ci/build_python.sh'
151+
- '!ci/build_rust.sh'
147152
- '!ci/build_wheel*.sh'
148153
- '!ci/check_style.sh'
149154
- '!ci/release/update-version.sh'
150155
- '!ci/run_cuvs_pytests.sh'
151156
- '!ci/test_java.sh'
157+
- '!ci/test_lucene.sh'
152158
- '!ci/test_python.sh'
153159
- '!ci/test_wheel_cuvs.sh'
154160
- '!ci/validate_wheel.sh'
@@ -238,12 +244,14 @@ jobs:
238244
- '!.yamllint.yaml'
239245
- '!ci/build_go.sh'
240246
- '!ci/build_java.sh'
247+
- '!ci/build_lucene.sh'
241248
- '!ci/build_rust.sh'
242249
- '!ci/check_style.sh'
243250
- '!ci/release/update-version.sh'
244251
- '!ci/run_ctests.sh'
245252
- '!ci/test_cpp.sh'
246253
- '!ci/test_java.sh'
254+
- '!ci/test_lucene.sh'
247255
- '!ci/test_standalone_c.sh'
248256
- '!ci/test_wheel_cuvs.sh'
249257
- '!ci/validate_wheel.sh'
@@ -289,6 +297,7 @@ jobs:
289297
- '!ci/build_docs.sh'
290298
- '!ci/build_go.sh'
291299
- '!ci/build_java.sh'
300+
- '!ci/build_lucene.sh'
292301
- '!ci/build_python.sh'
293302
- '!ci/build_rust.sh'
294303
- '!ci/build_standalone_c.sh'
@@ -297,6 +306,7 @@ jobs:
297306
- '!ci/run_ctests.sh'
298307
- '!ci/test_cpp.sh'
299308
- '!ci/test_java.sh'
309+
- '!ci/test_lucene.sh'
300310
- '!ci/test_python.sh'
301311
- '!ci/test_standalone_c.sh'
302312
- '!ci/validate_wheel.sh'
@@ -346,6 +356,7 @@ jobs:
346356
- '!ci/build_docs.sh'
347357
- '!ci/build_go.sh'
348358
- '!ci/build_java.sh'
359+
- '!ci/build_lucene.sh'
349360
- '!ci/build_python.sh'
350361
- '!ci/build_wheel*.sh'
351362
- '!ci/check_style.sh'
@@ -354,6 +365,7 @@ jobs:
354365
- '!ci/run_cuvs_pytests.sh'
355366
- '!ci/test_cpp.sh'
356367
- '!ci/test_java.sh'
368+
- '!ci/test_lucene.sh'
357369
- '!ci/test_python.sh'
358370
- '!ci/test_wheel_cuvs.sh'
359371
- '!ci/validate_wheel.sh'
@@ -394,6 +406,7 @@ jobs:
394406
- '!SECURITY.md'
395407
- '!ci/build_docs.sh'
396408
- '!ci/build_java.sh'
409+
- '!ci/build_lucene.sh'
397410
- '!ci/build_python.sh'
398411
- '!ci/build_rust.sh'
399412
- '!ci/build_wheel*.sh'
@@ -403,6 +416,7 @@ jobs:
403416
- '!ci/run_cuvs_pytests.sh'
404417
- '!ci/test_cpp.sh'
405418
- '!ci/test_java.sh'
419+
- '!ci/test_lucene.sh'
406420
- '!ci/test_python.sh'
407421
- '!ci/test_standalone_c.sh'
408422
- '!ci/test_wheel_cuvs.sh'
@@ -599,6 +613,31 @@ jobs:
599613
script: "ci/test_java.sh"
600614
artifact-name: "cuvs-java-cuda${{ matrix.CUDA_VER }}"
601615
file_to_upload: "java/cuvs-java/target/"
616+
conda-lucene-build-and-tests:
617+
# Depends on the Java job for the cuvs-java artifact that cuvs-lucene builds against, and
618+
# reuses its matrix so the two always agree on the set of CUDA versions.
619+
needs: [conda-java-build-and-tests-matrix, conda-java-build-and-tests]
620+
permissions:
621+
actions: read
622+
contents: read
623+
id-token: write
624+
packages: read
625+
pull-requests: read
626+
secrets: inherit # zizmor: ignore[secrets-inherit]
627+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
628+
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
629+
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
630+
strategy:
631+
fail-fast: false
632+
matrix: ${{ fromJSON(needs.conda-java-build-and-tests-matrix.outputs.matrix) }}
633+
with:
634+
build_type: pull-request
635+
node_type: "gpu-l4-latest-1"
636+
arch: "amd64"
637+
container_image: "rapidsai/ci-conda:26.10-cuda${{ matrix.CUDA_VER }}-${{ matrix.LINUX_VER }}-py${{ matrix.PY_VER }}"
638+
script: "ci/test_lucene.sh cuvs-java-cuda${{ matrix.CUDA_VER }}"
639+
artifact-name: "cuvs-lucene-cuda${{ matrix.CUDA_VER }}"
640+
file_to_upload: "java/cuvs-lucene/target/"
602641
rust-build-matrix:
603642
needs: [conda-cpp-build, changed-files]
604643
permissions:

‎.github/workflows/test.yaml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,34 @@ jobs:
104104
script: "ci/test_java.sh"
105105
artifact-name: "cuvs-java-cuda${{ matrix.CUDA_VER }}"
106106
file_to_upload: "java/cuvs-java/target/"
107+
conda-lucene-build-and-tests:
108+
# Depends on the Java job for the cuvs-java artifact that cuvs-lucene builds against, and
109+
# reuses its matrix so the two always agree on the set of CUDA versions.
110+
needs: [conda-java-build-and-tests-matrix, conda-java-build-and-tests]
111+
permissions:
112+
actions: read
113+
contents: read
114+
id-token: write
115+
packages: read
116+
pull-requests: read
117+
secrets: inherit # zizmor: ignore[secrets-inherit]
118+
uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@main
119+
# Artifacts are not published from these jobs, so it's safe to run for multiple CUDA versions.
120+
# If these jobs start producing artifacts, the names will have to differentiate between CUDA versions.
121+
strategy:
122+
fail-fast: false
123+
matrix: ${{ fromJSON(needs.conda-java-build-and-tests-matrix.outputs.matrix) }}
124+
with:
125+
build_type: ${{ inputs.build_type }}
126+
branch: ${{ inputs.branch }}
127+
date: ${{ inputs.date }}
128+
sha: ${{ inputs.sha }}
129+
node_type: "gpu-l4-latest-1"
130+
arch: "amd64"
131+
container_image: "rapidsai/ci-conda:26.10-cuda${{ matrix.CUDA_VER }}-${{ matrix.LINUX_VER }}-py${{ matrix.PY_VER }}"
132+
script: "ci/test_lucene.sh cuvs-java-cuda${{ matrix.CUDA_VER }}"
133+
artifact-name: "cuvs-lucene-cuda${{ matrix.CUDA_VER }}"
134+
file_to_upload: "java/cuvs-lucene/target/"
107135
wheel-tests-cuvs:
108136
permissions:
109137
actions: read

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ repos:
9797
name: spotless-fmt
9898
entry: ci/checks/run_spotless.sh
9999
pass_filenames: false
100-
files: ^java/cuvs-java/src/.*\.java$
100+
files: ^java/(cuvs-java|cuvs-lucene)/([^/]+/)?src/.*\.java$
101101
exclude: .*/panama/.*
102102
language: script
103103
- id: clang-format-with-cmake-placeholders

‎build.sh‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ARGS=$*
1919
# scripts, and that this script resides in the repo dir!
2020
REPODIR=$(cd "$(dirname "$0")"; pwd)
2121

22-
VALIDARGS="clean libcuvs python rust go java docs tests bench-ann examples --uninstall -v -g -n --allgpuarch --no-mg --mnmg-tests --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h --run-java-tests"
22+
VALIDARGS="clean libcuvs python rust go java lucene docs tests bench-ann examples --uninstall -v -g -n --allgpuarch --no-mg --mnmg-tests --no-cpu --cpu-only --no-shared-libs --no-nvtx --show_depr_warn --incl-cache-stats --time -h --run-java-tests"
2323
HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<tool>] [--limit-tests=<targets>] [--limit-bench-ann=<targets>] [--build-metrics=<filename>]
2424
where <target> is:
2525
clean - remove all existing build artifacts and configuration (start over)
@@ -29,6 +29,7 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
2929
rust - build the cuvs Rust bindings
3030
go - build the cuvs Go bindings
3131
java - build the cuvs Java bindings
32+
lucene - build the cuvs-lucene Apache Lucene codecs (requires the Java bindings)
3233
docs - build the documentation
3334
tests - build the tests
3435
bench-ann - build end-to-end ann benchmarks
@@ -74,7 +75,8 @@ FERN_DOCS_DIR=${REPODIR}/fern
7475
PYTHON_BUILD_DIR=${REPODIR}/python/cuvs/_skbuild
7576
RUST_BUILD_DIR=${REPODIR}/rust/target
7677
JAVA_BUILD_DIR=${REPODIR}/java/cuvs-java/target
77-
BUILD_DIRS="${LIBCUVS_BUILD_DIR} ${PYTHON_BUILD_DIR} ${RUST_BUILD_DIR} ${JAVA_BUILD_DIR}"
78+
LUCENE_BUILD_DIR=${REPODIR}/java/cuvs-lucene/target
79+
BUILD_DIRS="${LIBCUVS_BUILD_DIR} ${PYTHON_BUILD_DIR} ${RUST_BUILD_DIR} ${JAVA_BUILD_DIR} ${LUCENE_BUILD_DIR}"
7880

7981
# Set defaults for vars modified by flags to this script
8082
CMAKE_LOG_LEVEL=""
@@ -555,6 +557,19 @@ if (( NUMARGS == 0 )) || hasArg java; then
555557
fi
556558
fi
557559

560+
# Build the cuvs-lucene codecs
561+
if (( NUMARGS == 0 )) || hasArg lucene; then
562+
if ! hasArg java; then
563+
echo "Please add 'java' to this script's arguments (ex. './build.sh libcuvs java lucene') if the cuvs Java bindings are not already built"
564+
fi
565+
cd "${REPODIR}"/java/cuvs-lucene
566+
if hasArg --run-java-tests; then
567+
./build.sh --run-java-tests
568+
else
569+
./build.sh
570+
fi
571+
fi
572+
558573
RAPIDS_VERSION="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2.\3/' "${REPODIR}/VERSION")"
559574
export RAPIDS_VERSION
560575
RAPIDS_VERSION_MAJOR_MINOR="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2/' "${REPODIR}/VERSION")"

‎ci/build_lucene.sh‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -euo pipefail
6+
7+
# Takes the name of the cuvs-java artifact uploaded by the Java job, plus an optional
8+
# --run-java-tests flag.
9+
# TODO: Remove the flag handling when build and test workflows are separated,
10+
# and test_lucene.sh no longer calls build_lucene.sh
11+
# ref: https://github.com/rapidsai/cuvs/issues/868
12+
EXTRA_BUILD_ARGS=()
13+
CUVS_JAVA_ARTIFACT=""
14+
for arg in "$@"; do
15+
case "${arg}" in
16+
--run-java-tests) EXTRA_BUILD_ARGS+=("${arg}") ;;
17+
*) CUVS_JAVA_ARTIFACT="${arg}" ;;
18+
esac
19+
done
20+
21+
if [ -z "${CUVS_JAVA_ARTIFACT}" ]; then
22+
echo "Error: name of the cuvs-java artifact is missing" >&2
23+
exit 1
24+
fi
25+
26+
if [ -e "/opt/conda/etc/profile.d/conda.sh" ]; then
27+
. /opt/conda/etc/profile.d/conda.sh
28+
fi
29+
30+
rapids-logger "Configuring conda strict channel priority"
31+
conda config --set channel_priority strict
32+
33+
rapids-logger "Downloading artifacts from previous jobs"
34+
CPP_CHANNEL=$(rapids-download-from-github "$(rapids-artifact-name conda_cpp libcuvs cuvs --cuda "$RAPIDS_CUDA_VERSION")")
35+
CUVS_JAVA_DIR=$(rapids-download-from-github "${CUVS_JAVA_ARTIFACT}")
36+
37+
rapids-logger "Generate Java testing dependencies"
38+
39+
ENV_YAML_DIR="$(mktemp -d)"
40+
41+
rapids-dependency-file-generator \
42+
--output conda \
43+
--file-key java \
44+
--prepend-channel "${CPP_CHANNEL}" \
45+
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee "${ENV_YAML_DIR}/env.yaml"
46+
47+
rapids-mamba-retry env create --yes -f "${ENV_YAML_DIR}/env.yaml" -n java
48+
49+
# Temporarily allow unbound variables for conda activation.
50+
set +u
51+
conda activate java
52+
set -u
53+
54+
rapids-print-env
55+
56+
# libcuvs comes from the conda environment here. cuvs-lucene depends on the plain cuvs-java jar,
57+
# which bundles no native libraries, so the JVM resolves libcuvs_c.so through the dynamic loader
58+
# and the environment's lib directory has to be on LD_LIBRARY_PATH.
59+
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
60+
61+
rapids-logger "Install the cuvs-java artifact into the local Maven repository"
62+
63+
# cuvs-lucene resolves cuvs-java from the local Maven repository. Rather than rebuilding the Java
64+
# bindings here, install the jar built by the Java job. Its pom.xml travels with the artifact and
65+
# supplies the coordinates, so no version needs to be hardcoded.
66+
CUVS_JAVA_POM="${CUVS_JAVA_DIR}/pom.xml"
67+
if [ ! -f "${CUVS_JAVA_POM}" ]; then
68+
echo "Could not find pom.xml in the cuvs-java artifact at ${CUVS_JAVA_DIR}" >&2
69+
exit 1
70+
fi
71+
72+
# The artifact also carries the per-architecture native jar and the sources/javadoc/test jars;
73+
# cuvs-lucene depends on the plain one.
74+
mapfile -t CUVS_JAVA_JARS < <(find "${CUVS_JAVA_DIR}" -maxdepth 1 -name 'cuvs-java-*.jar' \
75+
! -name '*-sources.jar' ! -name '*-javadoc.jar' ! -name '*-tests.jar' ! -name '*-cuda*.jar')
76+
if [ "${#CUVS_JAVA_JARS[@]}" -ne 1 ]; then
77+
echo "Expected exactly one cuvs-java jar in ${CUVS_JAVA_DIR}, found: ${CUVS_JAVA_JARS[*]:-none}" >&2
78+
exit 1
79+
fi
80+
81+
# Install cuvs jar into .m2, cd is needed to pick up pom.xml in order to avoid rate limit of main maven repo
82+
pushd java/cuvs-lucene
83+
mvn --batch-mode install:install-file -Dfile="${CUVS_JAVA_JARS[0]}" -DpomFile="${CUVS_JAVA_POM}"
84+
popd
85+
86+
EXITCODE=0
87+
trap "EXITCODE=1" ERR
88+
set +e
89+
90+
rapids-logger "Run cuvs-lucene build"
91+
92+
RAPIDS_CUDA_MAJOR="${RAPIDS_CUDA_VERSION%%.*}"
93+
export RAPIDS_CUDA_MAJOR
94+
95+
bash ./build.sh lucene "${EXTRA_BUILD_ARGS[@]}"
96+
97+
rapids-logger "Test script exiting with value: $EXITCODE"
98+
exit ${EXITCODE}

‎ci/checks/run_spotless.sh‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44

5-
# pre-commit hook wrapper that runs 'spotless:apply' to format the Java client sources.
5+
# pre-commit hook wrapper that runs 'spotless:apply' to format the Java sources of every Maven
6+
# project under java/.
67
#
78
# Most cuvs contributors do not work on the Java client and do not have Maven installed. For them
89
# (running outside CI without Maven) this skips gracefully, so that 'pre-commit run --all-files'
@@ -20,4 +21,13 @@ if ! command -v mvn >/dev/null 2>&1; then
2021
exit 0
2122
fi
2223

23-
exec mvn --batch-mode --quiet -f java/cuvs-java/pom.xml spotless:apply
24+
POMS=(
25+
java/cuvs-java/pom.xml
26+
java/cuvs-lucene/pom.xml
27+
java/cuvs-lucene/bench/pom.xml
28+
java/cuvs-lucene/examples/pom.xml
29+
)
30+
31+
for pom in "${POMS[@]}"; do
32+
mvn --batch-mode --quiet -f "${pom}" spotless:apply
33+
done

‎ci/release/update-version.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,17 @@ done
169169
# Update Java API version
170170
NEXT_FULL_JAVA_TAG="${NEXT_SHORT_TAG}.${PATCH_PEP440}"
171171
sed_runner "s/VERSION=\".*\"/VERSION=\"${NEXT_FULL_JAVA_TAG}\"/g" java/build.sh
172-
for FILE in java/*/pom.xml; do
172+
sed_runner "s/VERSION=\".*\"/VERSION=\"${NEXT_FULL_JAVA_TAG}\"/g" java/cuvs-lucene/build.sh
173+
for FILE in java/*/pom.xml java/cuvs-lucene/bench/pom.xml java/cuvs-lucene/examples/pom.xml; do
173174
sed_runner "/<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START-->.*<!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->/s//<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>${NEXT_FULL_JAVA_TAG}<\/version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->/g" "${FILE}"
174175
done
175176

176177
sed_runner "s| CuVS [[:digit:]]\{2\}\.[[:digit:]]\{2\} | CuVS ${NEXT_SHORT_TAG} |g" java/README.md
177178
sed_runner "s|-[[:digit:]]\{2\}\.[[:digit:]]\{2\}\.[[:digit:]]\{1,2\}\.jar|-${NEXT_FULL_JAVA_TAG}\.jar|g" java/examples/README.md
178179
sed_runner "s|/[[:digit:]]\{2\}\.[[:digit:]]\{2\}\.[[:digit:]]\{1,2\}/|/${NEXT_FULL_JAVA_TAG}/|g" java/examples/README.md
180+
181+
# This pattern is deliberately narrow: java/cuvs-lucene/README.md also links to a blog post whose
182+
# title contains a release number, and that reference must not be rewritten.
183+
sed_runner "s|<version>[[:digit:]]\{2\}\.[[:digit:]]\{2\}\.[[:digit:]]\{1,2\}</version>|<version>${NEXT_FULL_JAVA_TAG}</version>|g" java/cuvs-lucene/README.md
184+
185+
sed_runner "s|target/examples-[\.0-9]*-jar|target/examples-${NEXT_FULL_JAVA_TAG}-jar|g" java/cuvs-lucene/examples/README.md

0 commit comments

Comments
 (0)