Skip to content

Commit f7a9846

Browse files
Rename lazy layer to deferred (_DeferredDataModel / _deferred.py)
Per review, "lazy" was too generic and "host" would be wrong (cuDF inputs pass through and stay on device). "Deferred" names the actual mechanism -- the device build is deferred to solve, for host and device inputs alike -- and avoids colliding with the Cython "wrapper". Pure rename: _lazy.py -> _deferred.py, _LazyDataModel -> _DeferredDataModel, test_lazy.py -> test_deferred.py. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
1 parent 3f2f257 commit f7a9846

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

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

4-
"""Store-then-build (lazy) layer for the routing DataModel.
4+
"""Store-then-build (deferred build) layer for the routing DataModel.
55
66
The public DataModel records its setter calls on the host and builds the device
77
(Cython) model only transiently -- at solve, or when a getter is queried -- by
@@ -19,7 +19,7 @@
1919
* **Zero-CUDA construction.** The setter/getter surface is declared explicitly
2020
below rather than introspected from the compiled wrapper, so constructing and
2121
serializing a problem imports no CUDA/cuDF -- the wrapper is imported lazily
22-
only when a device build actually happens. ``test_lazy`` fails if this
22+
only when a device build actually happens. ``test_deferred`` fails if this
2323
declared surface drifts from the wrapper.
2424
2525
Adding a new setter/getter to the DataModel:
@@ -30,7 +30,7 @@
3030
docstring -- forwarding to ``super()``.
3131
3. Add its name to ``_SETTERS`` (a mutator) or ``_GETTERS`` (a query) below.
3232
33-
``test_lazy`` cross-checks these names against the wrapper's surface, so a
33+
``test_deferred`` cross-checks these names against the wrapper's surface, so a
3434
missing entry fails CI rather than silently dropping the call's data.
3535
"""
3636

@@ -136,7 +136,7 @@ def _normalize(x):
136136
return x
137137

138138

139-
class _LazyDataModel:
139+
class _DeferredDataModel:
140140
"""Records DataModel setter calls; builds the device model transiently."""
141141

142142
def __init__(self, num_locations, fleet_size, n_orders=-1):
@@ -207,11 +207,11 @@ def _install_methods():
207207
if _methods_installed:
208208
return
209209
for name in _SETTERS:
210-
if name not in _LazyDataModel.__dict__:
211-
setattr(_LazyDataModel, name, _make_setter(name))
210+
if name not in _DeferredDataModel.__dict__:
211+
setattr(_DeferredDataModel, name, _make_setter(name))
212212
for name in _GETTERS:
213-
if name not in _LazyDataModel.__dict__:
214-
setattr(_LazyDataModel, name, _make_getter(name))
213+
if name not in _DeferredDataModel.__dict__:
214+
setattr(_DeferredDataModel, name, _make_getter(name))
215215
_methods_installed = True
216216

217217

python/cuopt/cuopt/routing/vehicle_routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from cuopt import routing
99
from cuopt.routing import vehicle_routing_wrapper
10-
from cuopt.routing._lazy import _LazyDataModel
10+
from cuopt.routing._deferred import _DeferredDataModel
1111
from cuopt.utilities import catch_cuopt_exception
1212

1313
from .validation import (
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
class DataModel(_LazyDataModel):
23+
class DataModel(_DeferredDataModel):
2424
"""
2525
2626
DataModel(n_locations, n_fleet, n_orders: int = -1)

python/cuopt/cuopt/tests/routing/test_lazy.py renamed to python/cuopt/cuopt/tests/routing/test_deferred.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from cuopt import routing
77
from cuopt.routing import vehicle_routing_wrapper
8-
from cuopt.routing._lazy import _SKIP_GETTERS
8+
from cuopt.routing._deferred import _SKIP_GETTERS
99

1010

11-
def test_lazy_covers_wrapper_surface():
11+
def test_deferred_covers_wrapper_surface():
1212
"""Every public wrapper DataModel method must be handled by the recording
1313
layer (installed as a recorder/getter or an explicit override). This fails
1414
loudly if a new wrapper method -- e.g. a mutator not named set_*/add_* --
@@ -24,7 +24,7 @@ def test_lazy_covers_wrapper_surface():
2424
and name not in handled
2525
]
2626
assert not missing, (
27-
f"lazy build layer does not handle wrapper methods {missing}; "
27+
f"deferred-build layer does not handle wrapper methods {missing}; "
2828
"add a recorder/getter or list them in _SKIP_GETTERS"
2929
)
3030

0 commit comments

Comments
 (0)