Repository navigation
[Core] Refactor and cleanup core subpackage for 3.0 [13/N] - #8095
Conversation
|
There was a problem hiding this comment.
Isaac Lab Review Bot
The lifecycle cleanup generally centralizes debug-visualization teardown and preserves the reviewed public interfaces. One maintainability fix remains in SensorBase._clear_callbacks: its new string-based reflective handle loop conflicts with the repository rule against reflective assignment used merely to shorten code.
- Design and architecture: Moving repeated debug-visualization cleanup into
_clear_debug_vis_handleand removing pass-through constructors and no-op invalidation overrides appropriately centralizes lifecycle behavior within the asset and sensor base hierarchies. - API: The reviewed public signatures and input-handling surfaces remain unchanged, while the ray-caster camera
frameannotation is corrected totorch.Tensor. The proposed concern about theAssetdocumentation cross-reference is not sufficiently established by the supplied repository context. - Implementation: Camera tensor normalization, Haply force selection, marker device moves, path partitioning, and ray-caster simplifications are supported by the changed paths and context. However,
SensorBase._clear_callbacksnow iterates string attribute names withgetattrandsetattr; replace this with explicit missing-safe blocks for each callback handle, matchingAssetBaseand preserving static visibility of lifecycle fields.
Minor fixes needed. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
| self._prim_deletion_handle = None | ||
| # Clear debug visualization | ||
| """Clears the callbacks. Handles may be missing if ``__init__`` failed before registering them.""" | ||
| for name in ("_initialize_handle", "_invalidate_initialize_handle", "_prim_deletion_handle"): |
There was a problem hiding this comment.
🔵 Suggestion · Implementation — Reflective handle clearing conflicts with style rule
Clearing the three handles by iterating attribute-name strings with getattr/setattr is the reflective assignment purely for brevity that the repository style rules disallow, and it diverges from AssetBase._clear_callbacks, which keeps explicit per-handle blocks. String-named attributes also hide these lifecycle fields from renames and static analysis. Keep the missing-handle tolerance but write three explicit if getattr(self, ...) is not None blocks.
|
run-ci |
# Description Part 13 of the split of #7949. It cleans up the asset and sensor base classes, the ray casters and camera, and a few device, marker, UI, and visualizer helpers. It changes no public API. The deprecation-warning refactor from #7949 is not included. - **Asset / sensor base:** - `AssetBase` and `SensorBase` now clear their debug-vis callback through one `_clear_debug_vis_handle()` helper. It replaces three copies of the same code in each class. - `AssetBase.num_instances` and `AssetBase.data` now `raise NotImplementedError` instead of returning it. - Removed the pass-through `__init__` methods from the base cable, deformable, rigid object, frame transformer, IMU, joint wrench, and PVA classes. - Removed the no-op `_invalidate_initialize_callback` overrides from the contact sensor and frame transformer bases. This drops the stale TODO in the contact sensor override. - **Camera:** positions, orientations, eyes, and targets now go through one `_as_device_tensor()` helper. `env_ids` handling is unchanged. - **Ray casters:** - The multi-mesh ray caster finds the rigid-body ancestor with `sim_utils.get_first_matching_ancestor_prim`. - Inlined single-use kernel-argument locals. - Simplified the debug-vis code. - Removed an unreachable "No meshes found" check. The loop already raises for an invalid path, and only one mesh path is allowed. - Fixed the `frame` return annotation (`torch.Tensor`). - **Devices:** - Fixed the gamepad and keyboard `__init__` docstrings, which listed parameters that don't exist. - Simplified the Haply force clipping. - **Markers / UI / visualizers:** - Device moves are done in one expression. - Added a `_has_implementation` helper and fixed docstrings and a typo. - The env-camera regex is precompiled. - Simplified how the live-plot source list is built. - **`isaaclab/__init__.py`:** `pip_prebundle` is folded into the fragment tuple, and one partition helper is shared by `sys.path` and `PYTHONPATH`. Small behavior notes: - `SensorBase.__init__` now sets its callback and debug-vis handles to `None` before anything that can fail, so `__del__` no longer raises `AttributeError` when construction fails early (e.g. in `validate(cfg)`). - `Se2SpaceMouse` sets `_thread = None` first and `__del__` joins it only when it was started, so a failed construction (e.g. no device found) no longer raises in `__del__`. - The Haply WebSocket receive-loop error is reported with `logger.error` instead of `print`. ## Type of change - Refactor, plus small teardown robustness fixes (see the behavior notes) ## Verification - Equivalence scripts comparing develop and this branch, with seeded random inputs: - Prebundle path demotion (2000 `sys.path` / `PYTHONPATH` cases): identical. - Haply force selection and clipping (1000 cases, CPU and CUDA): identical. - Camera array-like conversion (numpy, lists, tensors; CPU and CUDA): bitwise identical, with the same dtype, device, and shape. - Tests, all passed: - Sensors: `test_sensor_base`, `test_sensor_destructors`, `test_ray_caster_patterns`, `test_ray_caster_kernels`, `test_ray_caster_sensor`, `test_ray_caster_camera`, `test_multi_mesh_ray_caster`, `test_multi_mesh_ray_caster_camera`, `test_camera_pose_write_across_backends`. - Devices: `test_device_constructors`. - Markers: `test_visualization_markers`, `test_vis_marker_registry`. - Visualizers: `test_visualizer`. - Assets: `test_articulation_iface`, `test_rigid_object_iface`, `test_rigid_object_collection_iface`. ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<package>/changelog.d/` for each changed package (see [Changelog](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html#changelog)) - [x] If this is a user-visible change, the fragment clearly describes it ## Release backport - [x] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` (cherry picked from commit 2d6ebcc)
|
Backported to |
Description
Part 13 of the split of #7949. It cleans up the asset and sensor base classes, the ray casters and camera, and a few device, marker, UI, and visualizer helpers. It changes no public API. The deprecation-warning refactor from #7949 is not included.
AssetBaseandSensorBasenow clear their debug-vis callback through one_clear_debug_vis_handle()helper. It replaces three copies of the same code in each class.AssetBase.num_instancesandAssetBase.datanowraise NotImplementedErrorinstead of returning it.__init__methods from the base cable, deformable, rigid object, frame transformer, IMU, joint wrench, and PVA classes._invalidate_initialize_callbackoverrides from the contact sensor and frame transformer bases. This drops the stale TODO in the contact sensor override._as_device_tensor()helper.env_idshandling is unchanged.sim_utils.get_first_matching_ancestor_prim.framereturn annotation (torch.Tensor).__init__docstrings, which listed parameters that don't exist._has_implementationhelper and fixed docstrings and a typo.isaaclab/__init__.py:pip_prebundleis folded into the fragment tuple, and one partition helper is shared bysys.pathandPYTHONPATH.Small behavior notes:
SensorBase.__init__now sets its callback and debug-vis handles toNonebefore anything that can fail, so__del__no longer raisesAttributeErrorwhen construction fails early (e.g. invalidate(cfg)).Se2SpaceMousesets_thread = Nonefirst and__del__joins it only when it was started, so a failed construction (e.g. no device found) no longer raises in__del__.logger.errorinstead ofprint.Type of change
Verification
sys.path/PYTHONPATHcases): identical.test_sensor_base,test_sensor_destructors,test_ray_caster_patterns,test_ray_caster_kernels,test_ray_caster_sensor,test_ray_caster_camera,test_multi_mesh_ray_caster,test_multi_mesh_ray_caster_camera,test_camera_pose_write_across_backends.test_device_constructors.test_visualization_markers,test_vis_marker_registry.test_visualizer.test_articulation_iface,test_rigid_object_iface,test_rigid_object_collection_iface.Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<package>/changelog.d/for each changed package (see Changelog)Release backport
develop