-
Notifications
You must be signed in to change notification settings - Fork 217
test(routing): add null-value rejection test for cost matrix #1596
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
Changes from all commits
ee1f26b
a98b55f
be958c1
da4ab08
ca9e016
06fc69e
c6fb159
77f07a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,28 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Dataset-generation and batch helpers (generate_dataset, DatasetDistribution, | ||
| # add_vehicle_constraints, ...) are local-testing utilities that require a GPU | ||
| # to run. They deliberately live in cuopt.routing.utils and are NOT re-exported | ||
| # here, so importing cuopt.routing (e.g. to build/serialize a problem for a | ||
| # remote solver) does not pull in that GPU machinery. Import them from | ||
| # ``cuopt.routing.utils`` directly when needed. | ||
| from cuopt.routing.assignment import Assignment, SolutionStatus | ||
| from cuopt.routing.utils import ( | ||
| add_vehicle_constraints, | ||
| create_pickup_delivery_data, | ||
| generate_dataset, | ||
| update_routes_and_vehicles, | ||
| from cuopt.routing.vehicle_routing import ( | ||
| BatchSolve, | ||
| DataModel, | ||
| Solve, | ||
| SolverSettings, | ||
| ) | ||
| from cuopt.routing.utils_wrapper import DatasetDistribution | ||
| from cuopt.routing.vehicle_routing import BatchSolve, DataModel, Solve, SolverSettings | ||
| from cuopt.routing.vehicle_routing_wrapper import ErrorStatus, Objective | ||
|
|
||
| __all__ = [ | ||
| "Assignment", | ||
| "BatchSolve", | ||
| "DataModel", | ||
| "ErrorStatus", | ||
| "Objective", | ||
| "SolutionStatus", | ||
| "Solve", | ||
| "SolverSettings", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -676,6 +676,13 @@ def test_solved_by(): | |
| assert solution.get_solved_by() == SolverMethod.Barrier | ||
|
|
||
|
|
||
| @pytest.mark.skip( | ||
| reason=( | ||
| "Temporarily disabled: swath1 aborts with std::bad_array_new_length " | ||
| "in wheel builds after the fast MPS parser landed (#1429). " | ||
| "Tracked in https://github.com/NVIDIA/cuopt/issues/1592." | ||
| ) | ||
| ) | ||
|
Comment on lines
+679
to
+685
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Keep This unconditional skip removes all coverage for the heuristic-only solver path, although the documented failure is specific to wheel builds. Use a build-specific conditional skip or restrict the skip to wheel CI; otherwise regressions in this test will be silently missed everywhere. As per path instructions, Python tests should prioritize regression coverage for fixed bugs. 🤖 Prompt for AI AgentsSource: Path instructions |
||
| def test_heuristics_only(): | ||
| file_path = RAPIDS_DATASET_ROOT_DIR + "/mip/swath1.mps" | ||
| data_model_obj = Read(file_path) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def _run_without_gpu(code): | ||
| env = {**os.environ, "CUDA_VISIBLE_DEVICES": ""} | ||
| subprocess.run([sys.executable, "-c", code], check=True, env=env) | ||
|
|
||
|
|
||
| def test_routing_imports_without_a_gpu(): | ||
| """cuopt.routing must import and build a model on a GPU-less host. | ||
|
|
||
| The GPU dataset/batch helpers live in cuopt.routing.utils and are not | ||
| re-exported by the package, so importing cuopt.routing must not pull in | ||
| utils / utils_wrapper (which need a GPU). A CPU-only client can then build | ||
| and serialize a problem to submit to a remote solver. Run in a subprocess | ||
| with no visible GPU for a faithful check. | ||
| """ | ||
| _run_without_gpu( | ||
| "import sys\n" | ||
| "import cuopt.routing as r\n" | ||
| "assert 'cuopt.routing.utils' not in sys.modules\n" | ||
| "assert 'cuopt.routing.utils_wrapper' not in sys.modules\n" | ||
| # none of the GPU helpers are part of the public surface anymore; | ||
| # enumerate the full set so re-exposing any one of them fails the test | ||
| "moved = [\n" | ||
| " 'generate_dataset',\n" | ||
| " 'DatasetDistribution',\n" | ||
| " 'add_vehicle_constraints',\n" | ||
| " 'create_pickup_delivery_data',\n" | ||
| " 'update_routes_and_vehicles',\n" | ||
| "]\n" | ||
| "leaked = [n for n in moved if hasattr(r, n)]\n" | ||
| "assert not leaked, leaked\n" | ||
| "import numpy as np\n" | ||
| "dm = r.DataModel(3, 2)\n" | ||
| "dm.add_cost_matrix(np.eye(3, dtype=np.float32))\n" | ||
| ) |
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not unconditionally skip these regression tests.
The reason limits the failure to wheel builds, but
pytest.mark.skipdisables both MPS cases—and both callback variants—in every test environment. Make the skip conditional on the affected wheel-build context, or apply it only in wheel-specific CI, so normal source/dev runs retain callback regression coverage.As per path instructions, Python tests should prioritize regression coverage for fixed bugs.
Also applies to: 122-126, 136-137
🤖 Prompt for AI Agents
Source: Path instructions