Skip to content

Commit f5fccce

Browse files
Address review: document deferred validation; test unknown-method behavior
- DataModel docstring: note that solver-side (C++) validation and dtype-cast warnings surface at Solve (lazy build), while structural checks stay eager at the setter (coderabbitai). - test_lazy: lock that an unknown/typo'd method call (dm.random_func_call(...)) raises AttributeError and is never recorded -- the recording layer installs only declared setters/getters, with no __getattr__ catch-all (Iroy30). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
1 parent d396b9e commit f5fccce

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

python/cuopt/cuopt/routing/vehicle_routing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class DataModel(_LazyDataModel):
5151
host (numpy/pandas) inputs are copied to the device for the local
5252
solve. Python lists and tuples are not supported.
5353
54+
- Inputs are recorded and the device model is built lazily, so
55+
solver-side (C++) validation and dtype-cast warnings surface when the
56+
model is built -- at ``Solve`` -- rather than at the individual setter
57+
call. Structural checks (matrix shape, array sizes, value ranges) are
58+
still validated eagerly at the setter.
59+
5460
Examples
5561
--------
5662
>>> from cuopt import routing

python/cuopt/cuopt/tests/routing/test_lazy.py

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

4+
import pytest
5+
46
from cuopt import routing
57
from cuopt.routing import vehicle_routing_wrapper
68
from cuopt.routing._lazy import _SKIP_GETTERS
@@ -25,3 +27,15 @@ def test_lazy_covers_wrapper_surface():
2527
f"lazy build layer does not handle wrapper methods {missing}; "
2628
"add a recorder/getter or list them in _SKIP_GETTERS"
2729
)
30+
31+
32+
def test_unknown_method_is_not_recorded():
33+
"""A call to a method that is not part of the DataModel surface raises
34+
AttributeError rather than being silently recorded. The recording layer
35+
installs only the declared setters/getters (no ``__getattr__`` catch-all),
36+
so a typo'd or unknown call fails loudly and never enters the IR.
37+
"""
38+
dm = routing.DataModel(3, 1)
39+
with pytest.raises(AttributeError):
40+
dm.random_func_call(1, 2, 3)
41+
assert dm._calls == []

0 commit comments

Comments
 (0)