Repository navigation
ci: nightly smoke tests for individual split packages #2194
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ramakrishnap-nv
wants to merge
9
commits into
NVIDIA:main
Choose a base branch
from
ramakrishnap-nv:split-package-smoke-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
477f21b
ci: nightly smoke tests for individual split packages
ramakrishnap-nv 64f5d0e
ci: simplify split-package smoke tests
ramakrishnap-nv ec567f6
ci: move split-package smoke test Python into a helper script
ramakrishnap-nv 4e528d4
ci: pass expected packages as arrays in split-package smoke tests
ramakrishnap-nv 7158a1a
Merge branch 'main' into split-package-smoke-tests
ramakrishnap-nv dd2b271
ci: run split-package smoke tests on one matrix entry
ramakrishnap-nv a9d7039
ci: stop split-package failures being masked, use bash arrays
ramakrishnap-nv 57b7599
ci: use the ERR trap exit-code pattern in split-package tests
ramakrishnap-nv 26b6bb4
ci: scope set +e in split-package smoke tests and add docstrings
ramakrishnap-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # cmake-format: off | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # cmake-format: on | ||
|
|
||
| cmake_minimum_required(VERSION 3.30) | ||
| project(cuopt_split_package_smoke LANGUAGES C CXX) | ||
|
|
||
| set(COMPONENT "" CACHE STRING "cuOpt component to link: client, mathopt or routing") | ||
| if(NOT COMPONENT MATCHES "^(client|mathopt|routing)$") | ||
| message(FATAL_ERROR "COMPONENT must be client, mathopt or routing, got '${COMPONENT}'") | ||
| endif() | ||
|
|
||
| # Wheels install into lib64, which CMake skips on Debian-derived distros. | ||
| set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) | ||
|
|
||
| find_package(cuopt REQUIRED) | ||
| if(NOT TARGET cuopt::${COMPONENT}) | ||
| message(FATAL_ERROR "cuopt::${COMPONENT} was not found in this installation") | ||
| endif() | ||
|
|
||
| if(COMPONENT STREQUAL "mathopt") | ||
| set(SMOKE_SOURCE ${CMAKE_CURRENT_LIST_DIR}/../../docs/cuopt/source/cuopt-c/convex/examples/simple_lp_example.c) | ||
| else() | ||
| set(SMOKE_SOURCE ${COMPONENT}.cpp) | ||
| endif() | ||
|
|
||
| add_executable(smoke_${COMPONENT} ${SMOKE_SOURCE}) | ||
| target_compile_features(smoke_${COMPONENT} PRIVATE cxx_std_20) | ||
| # Keep the component in the link even if the program uses none of it, so a library that cannot | ||
| # load fails at startup. | ||
| target_link_options(smoke_${COMPONENT} PRIVATE LINKER:--no-as-needed) | ||
| target_link_libraries(smoke_${COMPONENT} PRIVATE cuopt::${COMPONENT}) |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Usage: build_and_run.sh <client|mathopt|routing> <CMAKE_PREFIX_PATH> | ||
| # | ||
| # Builds the consumer for one component against whatever is on CMAKE_PREFIX_PATH, then runs it. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| component=$1 | ||
| prefix_path=$2 | ||
| src="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| build="$(mktemp -d)/${component}" | ||
|
|
||
| cmake -S "${src}" -B "${build}" -GNinja \ | ||
| -DCOMPONENT="${component}" \ | ||
| -DCMAKE_PREFIX_PATH="${prefix_path}" | ||
| cmake --build "${build}" | ||
|
|
||
| cd "${build}" | ||
| "./smoke_${component}" |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <cuopt/status_codes.h> | ||
|
|
||
| #include <cstdio> | ||
|
|
||
| // The client's installed headers expose almost nothing to call, so this checks that the library | ||
| // and every shared library it links resolve when the binary starts. | ||
| int main() | ||
| { | ||
| std::printf("CUOPT_SUCCESS=%d\n", CUOPT_SUCCESS); | ||
| return CUOPT_SUCCESS; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """ | ||
| Helpers for the split-package smoke tests, called from the ci/test_*_split_packages.sh scripts. | ||
|
|
||
| Commands: | ||
| conda-packages <env_prefix> <expected_name>... Fail unless exactly these cuOpt conda packages are installed | ||
| wheel-packages <expected_name>... Fail unless exactly these libcuopt wheels are installed | ||
| cmake-prefixes Print the CMAKE_PREFIX_PATH of the installed wheels | ||
| """ | ||
|
|
||
| import importlib | ||
| import importlib.metadata as metadata | ||
| import json | ||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def installed_conda_packages(prefix): | ||
| """Return the names of the cuOpt packages installed in the conda environment at prefix.""" | ||
| out = subprocess.run( | ||
| [ | ||
| os.environ.get("CONDA_EXE", "conda"), | ||
| "list", | ||
| "--prefix", | ||
| prefix, | ||
| "--json", | ||
| ], | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ).stdout | ||
| return { | ||
| p["name"] | ||
| for p in json.loads(out) | ||
| if p["name"].startswith(("libcuopt", "cuopt")) | ||
| } | ||
|
|
||
|
|
||
| def installed_wheels(): | ||
| """Return the names of the libcuopt wheels installed in the current environment.""" | ||
| names = ( | ||
| d.metadata["Name"].lower().replace("_", "-") | ||
| for d in metadata.distributions() | ||
| ) | ||
| return {n for n in names if n.startswith("libcuopt")} | ||
|
|
||
|
|
||
| def check(installed, expected): | ||
| """Exit with an error unless the installed package names are exactly the expected ones.""" | ||
| if installed != set(expected): | ||
| print( | ||
| f"installed: {sorted(installed)}, expected: {sorted(expected)}", | ||
| file=sys.stderr, | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def cmake_prefixes(): | ||
| """Return the CMake prefix paths of the installed wheels, joined with ";".""" | ||
| return ";".join( | ||
| os.path.dirname( | ||
| importlib.import_module(ep.value.split(":")[0]).__file__ | ||
| ) | ||
| for ep in metadata.entry_points(group="cmake.prefix") | ||
| ) | ||
|
|
||
|
|
||
| def main(): | ||
| """Run the command named in argv.""" | ||
| command, args = sys.argv[1], sys.argv[2:] | ||
| if command == "conda-packages": | ||
| check(installed_conda_packages(args[0]), args[1:]) | ||
| elif command == "wheel-packages": | ||
| check(installed_wheels(), args) | ||
| elif command == "cmake-prefixes": | ||
| print(cmake_prefixes()) | ||
| else: | ||
| sys.exit(__doc__) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <cuopt/routing/data_model_view.hpp> | ||
| #include <cuopt/routing/solve.hpp> | ||
|
|
||
| #include <raft/core/handle.hpp> | ||
| #include <rmm/device_uvector.hpp> | ||
|
|
||
| #include <cmath> | ||
| #include <cstdio> | ||
| #include <vector> | ||
|
|
||
| // Four locations on a line, one vehicle: the best tour costs 1 + 1 + 1 + 3. | ||
| int main() | ||
| { | ||
| raft::handle_t handle; | ||
| auto stream = handle.get_stream(); | ||
| std::vector<float> cost = {0, 1, 2, 3, 1, 0, 1, 2, 2, 1, 0, 1, 3, 2, 1, 0}; | ||
| rmm::device_uvector<float> d_cost(cost.size(), stream); | ||
| raft::update_device(d_cost.data(), cost.data(), cost.size(), stream); | ||
| handle.sync_stream(); | ||
|
|
||
| cuopt::routing::data_model_view_t<int, float> model(&handle, 4, 1); | ||
| model.add_cost_matrix(d_cost.data()); | ||
| cuopt::routing::solver_settings_t<int, float> settings; | ||
| settings.set_time_limit(1); | ||
|
|
||
| auto solution = cuopt::routing::solve(model, settings); | ||
| std::printf( | ||
| "%s objective=%f\n", solution.get_status_string().c_str(), solution.get_total_objective()); | ||
| return solution.get_status() == cuopt::routing::solution_status_t::SUCCESS && | ||
| std::fabs(solution.get_total_objective() - 6.0) < 1e-3 | ||
| ? 0 | ||
| : 1; | ||
| } |
This file contains hidden or 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 | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||||
| #!/bin/bash | ||||||||
|
|
||||||||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||||
|
|
||||||||
| # Installs each libcuopt-* conda package on its own, in a fresh environment, and builds and runs a | ||||||||
| # C++ binary against it, to catch a package that only works because another one happened to be | ||||||||
| # installed. | ||||||||
|
|
||||||||
| set -euo pipefail | ||||||||
|
|
||||||||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||||||||
| COMPONENTS=(client mathopt routing) | ||||||||
|
|
||||||||
| . "$(conda info --base)/etc/profile.d/conda.sh" | ||||||||
|
|
||||||||
| conda config --set channel_priority strict | ||||||||
| CPP_CHANNEL=$(rapids-download-from-github "$(rapids-artifact-name conda_cpp libcuopt cuopt --cuda "$RAPIDS_CUDA_VERSION")") | ||||||||
| RAPIDS_CHANNEL=rapidsai-nightly | ||||||||
| rapids-is-release-build && RAPIDS_CHANNEL=rapidsai | ||||||||
| CUDA_VERSION=${RAPIDS_CUDA_VERSION%.*} | ||||||||
|
|
||||||||
| EXITCODE=0 | ||||||||
| trap "EXITCODE=1" ERR | ||||||||
|
|
||||||||
| for component in "${COMPONENTS[@]}"; do | ||||||||
| echo "=== conda: libcuopt-${component} alone ===" | ||||||||
| package="libcuopt-${component}" | ||||||||
| expected=(libcuopt-client "${package}") | ||||||||
| if [[ "${component}" == "client" ]]; then | ||||||||
| expected=(libcuopt-client) | ||||||||
| fi | ||||||||
|
|
||||||||
| env_dir="$(mktemp -d)/env" | ||||||||
| set +e | ||||||||
| rapids-mamba-retry create --yes --prefix "${env_dir}" \ | ||||||||
| --channel "${CPP_CHANNEL}" --channel "${RAPIDS_CHANNEL}" --channel conda-forge --channel nvidia \ | ||||||||
| "${package}" "cuda-version=${CUDA_VERSION}" \ | ||||||||
| cmake ninja cxx-compiler cuda-nvcc cuda-cudart-dev | ||||||||
|
|
||||||||
| python "${REPO_ROOT}/ci/split_package_smoke/env_check.py" conda-packages "${env_dir}" "${expected[@]}" | ||||||||
|
|
||||||||
| set +u | ||||||||
| conda activate "${env_dir}" | ||||||||
| set -u | ||||||||
| bash "${REPO_ROOT}/ci/split_package_smoke/build_and_run.sh" "${component}" "${env_dir}" | ||||||||
| conda deactivate | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 26b6bb4 |
||||||||
| set -e | ||||||||
| done | ||||||||
|
|
||||||||
| rapids-logger "Test script exiting with value: ${EXITCODE}" | ||||||||
| exit "${EXITCODE}" | ||||||||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/bin/bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Installs each libcuopt-* wheel on its own, in a fresh venv, and builds and runs a C++ binary | ||
| # against it, to catch a wheel that only works because another one happened to be installed. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| COMPONENTS=(client mathopt routing) | ||
|
|
||
| source rapids-init-pip | ||
| bash "${REPO_ROOT}/ci/utils/install_openssl3_runtime.sh" | ||
|
|
||
| SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" | ||
| CLIENT_WHEELHOUSE=$(rapids-download-from-github "$(rapids-artifact-name wheel_cpp libcuopt_client cuopt)") | ||
| MATHOPT_WHEELHOUSE=$(rapids-download-from-github "$(rapids-artifact-name wheel_cpp libcuopt_mathopt cuopt --cuda "$RAPIDS_CUDA_VERSION")") | ||
| ROUTING_WHEELHOUSE=$(rapids-download-from-github "$(rapids-artifact-name wheel_cpp libcuopt_routing cuopt --cuda "$RAPIDS_CUDA_VERSION")") | ||
|
|
||
| cat > "${PIP_CONSTRAINT}" <<CONSTRAINTS | ||
| libcuopt-client @ file://$(echo "${CLIENT_WHEELHOUSE}"/libcuopt_client-*.whl) | ||
| libcuopt-mathopt-${SUFFIX} @ file://$(echo "${MATHOPT_WHEELHOUSE}"/libcuopt_mathopt_*.whl) | ||
| libcuopt-routing-${SUFFIX} @ file://$(echo "${ROUTING_WHEELHOUSE}"/libcuopt_routing_*.whl) | ||
| CONSTRAINTS | ||
|
|
||
| EXITCODE=0 | ||
| trap "EXITCODE=1" ERR | ||
|
|
||
| for component in "${COMPONENTS[@]}"; do | ||
| echo "=== wheel: libcuopt-${component} alone ===" | ||
|
|
||
| if [[ "${component}" == "client" ]]; then | ||
| package=libcuopt-client | ||
| expected=(libcuopt-client) | ||
| else | ||
| package="libcuopt-${component}-${SUFFIX}" | ||
| expected=(libcuopt-client "${package}") | ||
| fi | ||
|
|
||
| venv="$(mktemp -d)/venv" | ||
| set +e | ||
| python -m venv "${venv}" | ||
| . "${venv}/bin/activate" | ||
| pip install --upgrade pip cmake ninja | ||
| rapids-pip-retry install --prefer-binary --constraint "${PIP_CONSTRAINT}" "${package}" | ||
|
|
||
| python "${REPO_ROOT}/ci/split_package_smoke/env_check.py" wheel-packages "${expected[@]}" | ||
| prefixes=$(python "${REPO_ROOT}/ci/split_package_smoke/env_check.py" cmake-prefixes) | ||
| bash "${REPO_ROOT}/ci/split_package_smoke/build_and_run.sh" "${component}" "${prefixes}" | ||
| deactivate | ||
| set -e | ||
| done | ||
|
|
||
| rapids-logger "Test script exiting with value: ${EXITCODE}" | ||
| exit "${EXITCODE}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's scope the
set +e's to just the blocks that install the environment, check the packages, and run the smoke tests. Same in the other script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 26b6bb4