Repository navigation
Accelerate and strengthen asset tests [1/13] - #8134
AntoineRichard wants to merge 7 commits into
Conversation
RigidObjectCollection.set_coms_index passed wp.transformf data to the PhysX tensor API, which raises a KeyError. It also marked the lazily filled body_com_pose_b cache as fresh after a partial write, so the unselected entries read back as zeros when the cache had not been read before. set_inertias_index flattened the (num_instances, num_bodies, 9) inertias with the 2D reshape, which the backend rejects. Pass the COM poses as float32, let the next read refresh the COM cache from the view as RigidObject does, and reshape the inertias with the 3D helper. A new test writes both properties to a non-sorted subset of (env, body) cells and checks the PhysX view and the data buffers.
Move the mocked cross-backend asset interface tests into a contract package with api, data, and write entry modules. An explicit capability table gives every backend a visible row: unavailable backends and unsupported branches collect as skips with their reason instead of silently dropping out. A kitless usdrt/carb stub and an availability guard keep PhysX articulations in the matrix, where they previously were skipped without notice. Factory manager patches are scoped to one test and restored afterwards. PhysX views apply TensorAPI writes so partial writers are checked against unselected backend rows, Newton joins the fixed-tendon contract, the deprecated command aliases are checked against the actuator collection, and one enforced inventory classifies the public base-class surface.
Take over what the removed OVPhysX real-backend joint-state test checked, on every backend: unsorted int64 environment and joint selectors on the fused writer, the finite-difference baseline it restarts for the written joints, skip_forward leaving body caches to the caller, and the deprecated combined writer producing the same state as the public writers.
|
| ), | ||
| BackendDeclaration( | ||
| name="newton", | ||
| required_modules=("isaaclab_newton",), |
There was a problem hiding this comment.
Newton import can stop collection If
isaaclab_newton is installed without the newton solver or pxr runtime, this check marks the backend available because it only checks for isaaclab_newton. The contract utilities then import Newton’s articulation module during collection, which raises before pytest can collect the other backends’ cases or show a reasoned Newton skip.
| request.applymarker( | ||
| pytest.mark.xfail( | ||
| raises=pytest.fail.Exception, | ||
| strict=True, | ||
| reason="Newton fixed-tendon mask setters accept data with extra environments", | ||
| ) |
There was a problem hiding this comment.
Xfail masks separate validation failures This xfail covers the whole Newton mask-writer test, not just its oversized-shape checks. If the earlier position-limit scalar rejection stops working, its
pytest.raises check produces the same pytest.fail.Exception and is reported as the known oversized-input bug. Narrowing the expected failure would keep that separate regression visible.
| if values_np.size == stored_np.size: | ||
| stored_np[rows] = values_np.reshape(stored_np.shape)[rows] | ||
| else: | ||
| stored_np[rows] = values_np.reshape(len(rows), *stored_np.shape[1:]) |
There was a problem hiding this comment.
Mock accepts invalid write layouts The recording setter accepts compact data for selected rows, even though the stated PhysX TensorAPI contract requires full-sized data with
indices selecting the rows to apply. A future writer could use the compact layout and pass these checks while sending an invalid layout to the real API.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Isaac Lab Review Bot
The shared asset-contract restructuring and PhysX RigidObjectCollection COM/inertia fixes are coherent, with no compatibility break identified. Before merge, simplify the copied public-surface manifest and redundant reverse-order test row, replace reason-string matching with the declared CUDA requirement, and complete the new helper annotations.
- Design and architecture: The capability declarations, per-test manager patch scope, and three focused contract entry modules improve isolation and backend visibility. However,
PUBLIC_SURFACE_CONTRACTSduplicates the complete public member inventory while its DATA/WRITE classifications are not connected to coverage, creating a maintenance burden without proving contract ownership. - API: The production changes retain the signatures, keywords, accepted shapes, dtypes,
full_databehavior, and mask delegation ofRigidObjectCollection.set_coms_indexandset_inertias_index. The changed conversions remain internal to the PhysX tensor-view boundary. - Compatibility and deprecation: Breaking changes: none identified. No public symbol, configuration key, registry ID, or CLI surface was removed or renamed; the COM and inertia paths correct previously invalid layouts while preserving their existing callable contracts.
- Implementation: The COM path now passes a flat
float32view to PhysX and invalidates dependent caches before refreshing from the view, while the inertia path uses the required three-dimensional body-major reshape. One maintainability issue remains intest_installed_backend_packages_run_the_contract: it recognizes the CUDA-only exclusion by matching the free-form reason text instead of usingBackendDeclaration.requires_cuda_runtime. - Style consistency: The added helpers generally follow adjacent naming and documentation patterns, but
_read_backend_cellslacks the-> torch.Tensorannotation used by its sibling readers. Inpublic_surface.py,_mappinglacks a return annotation andpublic_surface_mismatchesshould use the concretedict[str, list[str]]return type required by the repository typing guidance. - Test quality: The partial-write, deprecated-writer, tendon-family, backend-storage, and live PhysX regression cases protect concrete behavior. Two test-quality issues remain: the public-surface test relies on a copied member manifest whose classifications do not demonstrate coverage, and the
reversebackend iteration parameter repeats the same disjoint patch/restore paths without reaching a distinct branch.
Minor fixes needed. Posted 5 actionable findings inline.
Automated review; human maintainers own approval decisions.
| return {f"{class_name}.{member}": PublicMemberContract(kind, reason) for member in members.split()} | ||
|
|
||
|
|
||
| PUBLIC_SURFACE_CONTRACTS = { |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Copied public-member inventory proves no behavior
PUBLIC_SURFACE_CONTRACTS restates every public member of seven base classes, and the only consumer diffs those names against vars(cls). The ContractKind values are never asserted on (only the OUT_OF_SCOPE reason is), so classifying a member as DATA or WRITE proves no coverage while every public API addition, rename, or move forces a mirrored edit. The test-audit guidance rejects copied inventories and manifests; drop the manifest or derive ownership from the contract cases.
| } | ||
|
|
||
|
|
||
| def _read_backend_cells(backend: str, raw_backend, quantity: str, num_instances: int, num_bodies: int): |
There was a problem hiding this comment.
🔵 Suggestion · Style Consistency — Annotate backend reader return type
_read_backend_cells omits its return annotation, unlike the sibling _read_backend_rows helpers added in _rigid_object_contract_cases.py and _articulation_contract_cases.py, which both declare -> torch.Tensor. Add the same annotation so the shared contract helpers stay consistent with adjacent code and the signature-typing rule.
| } | ||
|
|
||
|
|
||
| def public_surface_mismatches(classes: tuple[type, ...], contracts: dict[str, PublicMemberContract]) -> dict[str, list]: |
There was a problem hiding this comment.
🔵 Suggestion · Style Consistency — Imprecise and missing return annotations
The guide requires concrete built-in collection annotations and return types in signatures. public_surface_mismatches returns sorted member-name lists, so the return type is dict[str, list[str]] rather than dict[str, list], and the _mapping helper at line 53 has no return annotation despite returning dict[str, PublicMemberContract]. Annotate both concretely.
| status.declaration.name: status.reason | ||
| for status in BACKEND_STATUSES | ||
| if not status.available | ||
| and status.reason != "CUDA runtime unavailable" |
There was a problem hiding this comment.
🔵 Suggestion · Implementation — Gate on declared flag, not reason text
This filter compares status.reason against the literal string built in capabilities._evaluate_backend. Rewording that message silently stops excluding CPU-only environments, so ovphysx re-enters unavailable and the test fails on every machine without CUDA. BackendDeclaration.requires_cuda_runtime already models the condition; check status.declaration.requires_cuda_runtime instead of matching free-form text.
| return bindings | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("reverse", [False, True], ids=["forward", "reverse"]) |
There was a problem hiding this comment.
🔵 Suggestion · Test Quality — Reverse parameter row reaches no distinct path
The reverse axis only changes backend iteration order, but each backend patches disjoint owners (PhysxManager, OvPhysxManager, the Newton data modules), so both rows record and restore exactly the same (owner, name) entries through the same code. The extra row doubles the mocked factory builds without selecting a distinct branch. Keep one ordering, or vary the asset-family creation order if cross-family interference is the intended regression.
Replace the static-method fixture helper with a module function, read backend storage through bound getters instead of getattr on known names, share one context for suppressing Newton model-change notifications, reuse the timestamped-cache helpers in the joint-state case, complete return annotations, and word comments by their current constraint.
…r/asset-tests-p01-contract
Run the index-resolution cases on OVPhysX, which implements the joint and body helpers, and drop the capability every backend now shares. Make the PhysX recording setters reject compact data instead of accepting it. Move the tendon shape negatives into their own case so the Newton mask xfail covers exactly the torch or warp oversized input it pins.
StafaH
left a comment
There was a problem hiding this comment.
Can we simplify this, I think we can remove the nested contract folder and just have a flat folder structure for assets/
Also this is largely overengineered. contract boot, mock backends, manager patch scope, we're building a large library inside this test file.
Also in an effort to clean up the tests we are adding new tests for the new helpers of test files.
| @@ -6,61 +6,57 @@ | |||
| # ignore private usage of variables warning | |||
There was a problem hiding this comment.
Here and elsewhere, let's avoid _ file names.
Description
Part 1/13 of the asset-test series (tracker: #7282). Scope: shared asset contract. Depends on #8131: the stronger collection writer checks here catch the PhysX
set_inertiaslayout bug that #8131 fixes, so this branch contains its commits until it merges.This PR moves the mocked
*_ifaceasset tests into a shared contract suite undersource/isaaclab/test/assets/contract/:capabilities.pydeclares what each backend supports. Unsupported paths show up as skips that give the reason.public_surface.pyclassifies every public member of the asset base classes. There is one enforced inventory, so adding a public member toAssetBasewithout classifying it fails.developthese patches are applied at module level and leak into other tests.test_asset_contract_{api,data,writes}.py.joint_acc/previous_joint_velbookkeeping after a partial write;write_joint_state_to_simwrites exactly what the public writers write.PhysX now actually runs in the kitless contract. On
develop, the articulation and ordering suites silently drop PhysX becausecarb/usdrtfail to import. The boot stubs those modules, andtest_installed_backend_packages_run_the_contractfails if an installed backend drops out. Removing thecarbstub turns that test red.Every test
developadded to these files keeps its assertions, now incontract/. This includes #8022 table tests, aliases, tendon contracts, deprecated friction writers, lazy dynamics buffers and external wrench frames.test_articulation_tendon_contractis split by property family, and Newton now runs the fixed-tendon rows.Product bugs pinned as strict xfails (not fixed here)
RigidObjectCollectionpartial body pose/velocity writes push whole environment rows from an unrefreshed buffer, so unselected bodies get stale or zero state (4 rows).Timing
Warm Warp cache, repository orchestrator, one process per file, RTX 5090.
developThis PR runs 79% more cases in about the same time and adds real PhysX coverage. The skips are declared Newton capability gaps (spatial tendons, extended fixed-tendon properties, tendon target scheduling, mocked task-space dynamics).
Notes
pyproject.tomlexcludes_*.pyfrom ruff, so the_*_contract_cases.py/_*_contract_utils.pymodules are not linted by pre-commit. The original*_ifacehelpers had the same gap.Type of change
Release backport
developChecklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request.pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists there