Repository navigation
Remove obsolete OVPhysX bootstrap hacks - #6074
kellyguo11 merged 12 commits into
Conversation
There was a problem hiding this comment.
Summary
This PR removes obsolete compatibility hacks from the OVPhysX integration that were necessary for ovphysx 0.4.x but are no longer needed with ovphysx 0.5's namespaced USD and static Carbonite lifecycle. The changes are well-structured and the test coverage for preventing regression of the removed behavior is thorough.
Positive Observations
-
Clean removal of workarounds: The
pxrmodule hiding during bootstrap, theatexit -> os._exit(0)process-exit workaround, and thephysx.reset()keeping-instance-alive pattern are all cleanly removed. -
Proper lifecycle management: The new
physx.release()call in_release_physx()is cleaner than the previous reset-and-hold pattern. -
Excellent guardrail tests: The new
test_ovphysx_manager_lifecycle.pyexplicitly tests that the old behaviors stay removed, which is great defensive programming. -
Consistent test file updates: All test files consistently update the kitless detection logic and documentation references from
./scripts/run_ovphysx.shto./isaaclab.sh -p -m pytest. -
Clear changelog entries: Both the
.skipand.minor.rstchangelog fragments clearly communicate what changed.
Questions and Suggestions
ovphysx_manager.py
-
Line ~609: The
_construct_physxmethod now unconditionally passesnum_threads=8inPhysXConfig. Was this value validated against ovphysx 0.5's recommended defaults? The old code set this viaset_config_int32orset_settingdynamically. -
Lines ~595-607: The
carbonite_overridesdictionary now includes/physics/physxDispatcher,/physics/updateToUsd, etc. unconditionally. Previously these were set conditionally viaset_setting(). Is there a reason these are now always set even for CPU mode, or is this intentional? -
Potential race condition consideration: With the removal of the
_atexit_registeredguard, if_construct_physxwere somehow called twice (shouldn't happen given the design, but defensively), there's no longer a sentinel preventing duplicate work. The existing_physx is Nonecheck in_warmup_and_loadguards this, but it might be worth adding a comment noting the single-construction guarantee.
test_ovphysx_manager_lifecycle.py
-
Line 82: The
_FakePhysX.release()method setsself.released = True, which is good. Consider adding an assertion thatrelease()wasn't called before (to catch double-release bugs), though this may be out of scope for this PR. -
The fake module fixture restores
_physxand_locked_devicebut not_warmup_done,_stage_path, or other class variables. If any future test accidentally modifies these, it could leak between tests. This is minor since the current tests don't touch them.
pyproject.toml
- Line 26: The version constraint
ovphysx>=0.5,<0.6is good practice. However, consider whether~=0.5(compatible release) would be more appropriate if ovphysx follows semver strictly, though the explicit range is clearer.
Test Interface Files
- The simplification of
_kitlessdetection from the complexLD_PRELOAD-based check to just"EXP_PATH" not in os.environis clean. Just confirming: are there any edge cases whereEXP_PATHmight be set but Kit is still not available? The original check seemed to guard against that.
Minor Nits
- In
contact_sensor.py, the updated error message now reads "The IsaacLab OVPhysX adapter has not wired detailed contact/friction reads" — this is clear but slightly verbose. Consider shortening to "The OVPhysX adapter does not yet support" for consistency with similar messages.
Overall this is a clean, well-tested PR that removes technical debt. The test plan is comprehensive and the changes align well with the ovphysx 0.5 API surface.
Greptile SummaryThe PR updates IsaacLab’s OVPhysX integration for the pinned 0.5 runtime.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant Sim as SimulationContext
participant Manager as OvPhysxManager
participant Views as OvPhysxView registry
participant Runtime as OVPhysX runtime
participant Stage as OVStage
Sim->>Manager: close()
Manager->>Manager: dispatch STOP callbacks
Manager->>Views: close all runtime-backed views
Views->>Views: destroy cached bindings
Manager->>Runtime: reset_stage() and wait_op()
Manager->>Runtime: release()
Manager->>Stage: destroy()
Reviews (2): Last reviewed commit: "Remove obsolete OVPhysX bootstrap hacks" | Re-trigger Greptile |
3ff747a to
d9056d5
Compare
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot — PR #6074
Verdict: Clean removal of technical debt with good guardrail coverage.
Summary
This PR removes OVPhysX 0.4.x compatibility workarounds (pxr-hiding during bootstrap, atexit → os._exit(0) shutdown hack, reset-and-hold instance pattern) and migrates to ovphysx 0.5's PhysXConfig/carbonite_overrides construction API. The changes are well-scoped, the new lifecycle test file prevents regression of the removed workarounds, and test documentation consistently updates references from the deprecated run_ovphysx.sh wrapper to ./isaaclab.sh -p -m pytest.
Findings
🟡 Warning: CI license-check and pre-commit are currently failing
The license-check and pre-commit jobs are failing on this SHA. These may be infrastructure issues, but worth verifying — in particular the new test_ovphysx_manager_lifecycle.py file should pass the license header check and any formatting lints.
🟡 Warning: No error handling around physx.release() in _release_physx
File: source/isaaclab_ovphysx/isaaclab_ovphysx/physics/ovphysx_manager.py
physx = cls._physx
cls._physx = None
physx.release()If physx.release() raises (e.g., the C++ layer encounters an error during teardown), the exception will propagate up through close(). The reference-clearing before release is good defensive practice, but a try/finally or logging around release() would make the failure mode more graceful — especially since this runs during cleanup paths where swallowing or logging errors is often preferable to propagating them.
🟡 Note: _warmup_and_load reuse path narrowed to within-session only
File: ovphysx_manager.py
The reuse path (else branch when cls._physx is not None) in _warmup_and_load calls cls._physx.reset(). Previously this was always reachable because _release_physx kept the instance alive. Now that close() → _release_physx() calls physx.release() and sets _physx = None, the reuse path is only exercised within a single SimulationContext lifetime (i.e., multiple reset() calls before close()). The docstring correctly states "On subsequent calls before close" — just flagging this behavioral narrowing for visibility.
🔵 Suggestion: Document why num_threads=8 is hardcoded
File: ovphysx_manager.py → _construct_physx
num_threads=8 is now a construction-time constant in PhysXConfig. Previously it was set via set_config_int32 or set_setting. If this value is an ovphysx 0.5 API constraint, a brief comment or exposing it as an OvPhysxCfg field would help future maintainers understand the choice and know whether it can be tuned.
🔵 Suggestion: Consider a lifecycle re-construction test
File: test_ovphysx_manager_lifecycle.py
A fourth test verifying _construct_physx succeeds after _release_physx (the close → reinitialize → construct flow) would confirm the new lifecycle's re-entrancy. Optional since real-backend tests cover it, but cheap to add as a guardrail test.
Positive Observations
- ✅ Guardrail tests explicitly verify the old hacks stay removed — excellent defensive testing pattern
- ✅
_kitlessdetection simplification ("EXP_PATH" not in os.environ) is correct and backwards-compatible - ✅ Moving
PhysxManagermock patching inside thetry/except ImportErrorblock in interface tests prevents mock leaks when the backend is not installed - ✅ Clear changelog fragments for both packages (
.skipfor isaaclab,.minor.rstfor isaaclab_ovphysx) - ✅ Version constraint
ovphysx>=0.5,<0.6is appropriately bounded - ✅ The
_release_physxclearing pattern (save ref → null field → release) prevents concurrent access during teardown
Reviewed at SHA: d9056d57
Update (48307eab): Incremental changes reviewed. ✅ Fixed: Test fixture in test_ovphysx_manager_lifecycle.py now properly saves/restores all class-level state fields via _MANAGER_STATE_FIELDS tuple (addressing the earlier inline comment about incomplete fixture state). No new issues introduced in this push — changes are docstring/comment refinements and the fixture improvement. LGTM.
d9056d5 to
48307ea
Compare
|
Stalling this PR for now and marking it as draft. The cleanup intentionally targets the next ovphysx line via We should mark this ready again only after a public Python ovphysx wheel satisfying |
48307ea to
a7a289d
Compare
Use the public OVPhysX 0.5.9 bootstrap and schema APIs. Replace forced process exit with deterministic binding and runtime cleanup so normal shutdown preserves real failures.
a7a289d to
89ee543
Compare
There was a problem hiding this comment.
Isaac Lab Review Bot
Summary
This PR strips the OVPhysX 0.5-era compatibility shims (pxr module hiding around bootstrap(), the os._exit(0) atexit workaround, runtime-API branching in _create_physx_instance/_step_physx/_reset_physx_stage) and replaces the "never release the runtime" policy with an explicit teardown chain: STOP dispatch -> destroy cached TensorBinding handles -> reset_stage() -> physx.release() -> destroy OVStage. OvPhysxView gains an idempotent close(), a closed-state guard, and a process-wide _live_views registry so raw bindings handed out via binding_for() can still be destroyed before the runtime goes away. The ordering itself is well reasoned and the new guardrail tests pin the happy path. The remaining concerns are all about guarantees the removed code used to provide implicitly: bootstrap() is no longer structurally once-per-process now that _physx is actually released, the deleted Kit physxSchema provider guard is not replaced, the new atexit handler runs arbitrary Python callbacks during interpreter shutdown, and error paths through close() can release the runtime while listeners still believe they hold live handles.
Architecture impact
Scoped to the optional isaaclab_ovphysx package plus a docstring-only change to PhysicsManager.close() that inverts the documented super()-call ordering for subclasses whose STOP listeners own backend handles. That contract flip is the only cross-package effect; no public API is removed. The new OvPhysxView._live_views class-level registry introduces process-global mutable state shared between the view module, the manager, and the test suites, which is the main new coupling worth watching.
Test coverage
Good breadth for the removed hacks: bootstrap no longer hides pxr, atexit receives close rather than os._exit, release ordering (views -> reset -> release -> stage destroy), view close() idempotency, and cross-runtime _close_all_for isolation are all covered, and the obsolete legacy-runtime/Kit-schema tests were removed in step. Gaps: the reuse branch of _warmup_and_load() is never exercised (only the _prepare_physx_for_stage_reuse helper is called directly), failure paths through close()/_release_physx are untested, the subprocess exit test cannot distinguish a raising atexit handler from a clean one, and the new _live_views teardown fixture in test_ovphysx_view.py is not scoped to views created by the test.
Implementation verdict
Significant concerns. Posted 8 actionable findings inline.
The PR exceeded the automated context budget, so some file content was truncated.
Automated comment-only review; human maintainers own approval decisions.
AntoineRichard
left a comment
There was a problem hiding this comment.
Requesting changes for three functional lifecycle/test issues and several targeted hygiene problems. The inline comments include concrete failure paths and focused remediations.
Verification at fda86746:
./isaaclab.sh -f: passed all hooks.- Focused 122-test lifecycle/view suite: 118 passed, 2 skipped, 2 failed. Both failures are the new process-exit tests, which reach a CUDA-dependent pinned allocation despite configuring CPU physics.
- Direct reproduction confirmed that a STOP callback routed through
safe_callback_invoke(..., physics_manager=<manager with store_callback_exception>)returns fromclose()normally with the exception merely stored.
The main code paths are close, but teardown must preserve failures consistently across backends and the regression coverage should be smaller, portable, and non-duplicative.
AntoineRichard
left a comment
There was a problem hiding this comment.
Follow-up on test scope: this new 414-line file mixes unrelated concerns and carries more fixture/process scaffolding than the lifecycle contract needs. Please compact it using these inline suggestions together with the previously requested redundant-test removals and minimal process fixture. The goal is focused coverage and less maintenance surface, not an arbitrary line limit.
Propagate backend-stored STOP callback failures while allowing every listener and context cleanup phase to run. Make OVPhysX exit coverage CPU-portable and consolidate lifecycle tests around their owning modules.
Drop both singleton and local context references before collecting garbage so native owners are destroyed inside the teardown boundary. Cover the ordering with a weak-reference regression test.
…hacks-c952c4 Signed-off-by: Kelly Guo <[email protected]>
|
let's look into why the rendering correctness tests are failing on this one |
Preserve current lazy-manager and renderer teardown behavior while keeping the cleanup on the public OVPhysX 0.5.9 API.
Develop removed the pre-0.5.9 OvPhysX compatibility code in 2404010 (Remove obsolete OVPhysX bootstrap hacks, isaac-sim#6074), so the legacy half of this branch no longer has a runtime to configure. Resolve in develop's favour and keep only the cooked-collider cache setting: - drop the legacy PhysX branch and its /UJITSO/datastore/localCachePath override; the pinned runtime takes the typed cooked_collider_cache_dir - restore the "import os" that the auto-merge dropped along with develop's removal of os._exit, since _derived_data_cache_dir still needs it - fold the cache assertion and a strict PhysXConfig fake into develop's parametrized test_manager_supports_pinned_runtime_api and delete the standalone runtime matrix, whose legacy stubs no longer match any code
…eter directory (#6889) ## 1. Summary - Kitless `physics=ovphysx` runs wrote their UJITSO derived-data cache into the **directory holding the Python interpreter**. The location is now a config field defaulting to a per-user directory under the system temp directory, created owner-only. - Fixes nvbug 6537980: where that directory is not writable (uv reusing a system `/usr/bin/python3.12`), every run logged two `[Error] [omni.datastore]` lines. - Where it *was* writable there was no error at all, and the cache was silently written inside the Python installation — shared by every project using that interpreter, and discarded on an interpreter upgrade. ## 2. Root cause The `ovphysx` wheel bundles its own Carbonite, which resolves the UJITSO cache from `realpath("/proc/self/exe")` + `/cache/DerivedDataCache` when no path is configured. That assumption — *the executable's directory belongs to me* — holds for Kit, whose `kit` binary lives in its own application package next to a `cache/` sibling. It breaks for every embedder, where the "executable" is a shared Python interpreter whose directory the program does not own. ## 3. Fix `OvPhysxCfg.cooked_collider_cache_dir` selects the directory and `_create_physx_instance` passes it to `ovphysx.PhysXConfig(cooked_collider_cache_dir=...)`, mirroring how the sibling kitless renderer threads `OVRTXRendererCfg.log_file_path` into `RendererConfig`. The field is `str | None`: `None` is forwarded unchanged so OVPhysX applies its own resolution, which `PhysXConfig` has accepted since the pinned 0.5.9. The default is `<temp>/ovphysx_derived_data_cache_<uid>`. Because that lives in a world-writable root, `_prepare_default_cache_dir` creates it with `os.makedirs(..., mode=0o700)` and, when the path already exists, `os.lstat`-rejects a symlink, a non-directory, or a directory owned by another user — a symlink planted there is otherwise followed and written through. A *configured* directory is passed through untouched, so a site can still point the field at a provisioned shared cache. ## 4. Validation ``` uv run isaaclab train --rl_library rsl_rl --task Isaac-Cartpole-Camera-Direct \ physics=ovphysx renderer=ovrtx presets=rgb --num_envs 32 --max_iterations 2 ``` Run three ways, varying only the fix and whether the interpreter directory is writable: | Arm | Fix | Interpreter dir | `omni.datastore` errors | Cache written to | |---|---|---|---|---| | A0 | reverted | writable | 0 | **interpreter's `bin/cache/DerivedDataCache`** | | A1 | reverted | read-only | **2** | not created | | B | applied | read-only | **0** | the configured directory | Arm A1 reproduces both reported lines verbatim. Arm A0 shows this is a wrong-location bug rather than a permissions bug: no error, cache still in the wrong place. All three arms exit 0 with training completing. ## 5. Test - `test_manager_supports_pinned_runtime_api` — the cache assertion and a strict `PhysXConfig` fake fold into the existing CPU/GPU parametrization; both fail when the keyword is removed. - `test_construct_physx_passes_the_configured_cooked_collider_cache_dir` — pins the config-to-runtime seam, with a no-config fallback case. Verified to fail when `_construct_physx` stops reading the config. - `test_construct_physx_forwards_an_unset_cooked_collider_cache_dir` — `None` reaches `PhysXConfig` unchanged. - `test_default_cache_dir_is_created_owner_only`, `..._rejects_a_planted_symlink`, `..._rejects_a_directory_owned_by_another_user`. ## 6. Notes - Earlier revisions also configured a pre-0.5.9 legacy runtime. Develop removed that code in #6074, so this branch targets the pinned runtime only. - The default path is per-user but predictable, so a TOCTOU window remains between the ownership check and OVPhysX opening the path. A home-rooted parent would close it structurally at the cost of the temp-rooted convention the ov packages already use. - The datastore is created once per process, so the first OVPhysX construction fixes the cache location. The runtime garbage collects the cache against a disk budget; deleting the directory reclaims it immediately.
Description
Removes obsolete OVPhysX bootstrap compatibility code for the pinned
ovphysx==0.5.9runtime and hardens normal lifecycle cleanup:pxrmodulesor probing private wheel layout;
atexitcleanup andexplicit runtime/view release;
idempotent bootstrap call;
Dependency:
ovphysx==0.5.9.Fixes N/A
Type of change
Screenshots
N/A
Test Plan
uv run --frozen isaaclab -fuv run --frozen python tools/changelog/cli.py check develop122 passedarticulation file hit intermittent assertions. An identical property-binding
failure reproduced on exact
developmerge-base5322a1bdcff(1/5 controlruns and 1/4 PR runs).
Checklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml- CI handles that)CONTRIBUTORS.mdor my name already exists thereThe OVPhysX backend tests still emit existing deprecation and runtime warnings
from surrounding test coverage.