Skip to content

[Fix] Stop OvPhysX writing its collider cache into the Python interpreter directory - #6889

Merged
hujc7 merged 24 commits into
isaac-sim:developfrom
hujc7:jichuanh/ovphysx-derived-data-cache-dir
Aug 27, 2026
Merged

hujc7 merged 24 commits into
isaac-sim:developfrom
hujc7:jichuanh/ovphysx-derived-data-cache-dir

Conversation

@hujc7

@hujc7 hujc7 commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

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 Remove obsolete OVPhysX bootstrap hacks #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.

hujc7 added 2 commits August 4, 2026 01:41
The kitless OvPhysX runtime bundles its own Carbonite, which resolves
the UJITSO derived-data cache location from ${omni_cache}. That token
is registered by omni.kit.app, so a run that never starts Kit cannot
resolve it, and Carbonite falls back to the directory holding the
Python interpreter.

Where that directory is writable the cache is silently written inside
the Python installation, shared across every project using that
interpreter and discarded on an interpreter upgrade. Where it is not
writable, startup logs "Failed to acquire exclusive lock to data
store" followed by "Failed to create local file data store".

Pass the location Kit itself uses so the cache lands in the Omniverse
user cache directory on both runtime branches.
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Aug 4, 2026
@hujc7
hujc7 marked this pull request as ready for review August 4, 2026 09:17
@hujc7
hujc7 requested a review from a team August 4, 2026 09:17
@greptile-apps

greptile-apps Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR redirects kitless OvPhysX cooked-collider caches from the Python installation to the standard per-user Omniverse cache and updates the legacy-runtime fix so every supported constructor and device path receives an explicit cache configuration.

  • Adds platform-aware derivation of the Omniverse cache directory, including a temporary-directory fallback when no absolute home-based path can be resolved.
  • Uses the typed cache field for the current runtime and the compatible Carbonite override for legacy runtimes.
  • Adds regression coverage across current and legacy constructor variants on CPU and GPU.
  • Documents the corrected cache behavior in the changelog.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported legacy-path omission is resolved because the current code constructs and passes a cache-configured PhysXConfig for every supported legacy constructor and device combination, and no blocking failure remains.

Important Files Changed

Filename Overview
source/isaaclab_ovphysx/isaaclab_ovphysx/physics/ovphysx_manager.py Adds canonical cache-path resolution and passes it through version-appropriate configuration routes for every current and legacy runtime branch; the previously reported omission is fixed.
source/isaaclab_ovphysx/test/physics/test_ovphysx_scene_data_backend.py Adds regression coverage for both devices across current, legacy CUDA-list, and legacy GPU-index constructor variants.
source/isaaclab_ovphysx/changelog.d/jichuanh-ovphysx-derived-data-cache-dir.rst Accurately documents that the collider cache now uses the standard user cache and persists across runs.

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

Comment on lines 1029 to 1031
if "active_cuda_gpus" in physx_parameters and ovphysx_device == "gpu":
physx_kwargs["active_cuda_gpus"] = str(gpu_index)
physx_kwargs["config"] = ovphysx.PhysXConfig(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Legacy paths omit cache config

When the legacy runtime uses CPU physics or exposes the gpu_index constructor, this condition constructs PhysX without a PhysXConfig, leaving Carbonite's interpreter-relative cache fallback active and causing cache writes beside Python or omni.datastore errors when that directory is read-only.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 48e4935.

The legacy branch now builds PhysXConfig unconditionally, so legacy CPU runs and the gpu_index constructor both receive the cache setting. The GPU-only /physics/suppressReadback and /physics/suppressFabricUpdate keys stay conditional, since those are correctly GPU-gated.

One correction worth recording: on that path the typed field was not merely omitted, it was unsafe. The declared runtime's PhysXConfigpredatescooked_collider_cache_dir(verified against an olderovphysxwheel:carbonite_overridespresent, the typed field absent), socooked_collider_cache_dir=would have raisedTypeErroron legacy GPU startup. The declared runtime now goes through the generic/UJITSO/datastore/localCachePath` override instead, which it accepts and which 0.5.9 rejects as conflicting with its typed field. The two routes are mutually exclusive by wheel version.

Test coverage went from 2 to 6 combinations (two legacy constructors x two devices, plus the current runtime x two devices), and each stubbed PhysXConfig now mirrors its runtime's real signature, so a keyword the real runtime would reject fails the test instead of being absorbed by a permissive lambda **kwargs`.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: develop removed the legacy runtime in #6074, so the branch this thread is about no longer exists. _create_physx_instance has one path now — the pinned 0.5.9 runtime — taking the cache directory as an argument from OvPhysxCfg.cooked_collider_cache_dir. The legacy PhysXConfig and /UJITSO/datastore/localCachePath override from my earlier reply are gone with it.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

The PR correctly routes the OVPhysX cooked-collider cache through the typed PhysXConfig field and adds a changelog fragment and regression coverage, but the legacy runtime path still omits this configuration for CPU runs and constructors using gpu_index.

  • Design and architecture: Containing cache-path resolution within OvPhysxManager is appropriate, and the platform-specific user-cache mapping avoids writing beside the interpreter. However, the legacy-runtime integration applies the cache configuration only within one GPU-specific constructor branch rather than as a runtime-wide setting.
  • API: No public Isaac Lab API symbols are added, removed, or renamed. The private helper and internal construction changes do not require deprecation or documentation exports, and the package changelog fragment follows the repository format.
  • Implementation: The current runtime path always passes cooked_collider_cache_dir, but the legacy path constructs PhysXConfig only when active_cuda_gpus is exposed and GPU physics is selected. Legacy CPU runs and the gpu_index constructor variant therefore retain the interpreter-relative fallback. Construct the cache-bearing configuration unconditionally for the legacy path while keeping GPU selectors and GPU-only overrides conditional; extend the regression test to cover those paths.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

if "active_cuda_gpus" in physx_parameters and ovphysx_device == "gpu":
physx_kwargs["active_cuda_gpus"] = str(gpu_index)
physx_kwargs["config"] = ovphysx.PhysXConfig(
cooked_collider_cache_dir=OvPhysxManager._cooked_collider_cache_dir(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Suggestion · Implementation — Legacy runtime gets cache dir only on GPU

On the legacy runtime path, PhysXConfig is constructed only when the constructor exposes active_cuda_gpus and the device is "gpu". For legacy CPU runs, or constructors taking gpu_index, ovphysx.PhysX is created without any config, so Carbonite keeps its interpreter-relative cache fallback and the reported behavior persists. Build the cache-bearing config unconditionally in this branch and keep the GPU-specific overrides and selector conditional.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 48e4935, along the lines you suggested.

The cache-bearing config is now built unconditionally on the legacy path, with the GPU selectors (active_cuda_gpus / gpu_index) and the GPU-only /physics/suppress* overrides kept conditional:

legacy_overrides = {"/UJITSO/datastore/localCachePath": OvPhysxManager._cooked_collider_cache_dir()}
if "active_cuda_gpus" in physx_parameters and ovphysx_device == "gpu":
    physx_kwargs["active_cuda_gpus"] = str(gpu_index)
    legacy_overrides["/physics/suppressReadback"] = True
    legacy_overrides["/physics/suppressFabricUpdate"] = True
elif "gpu_index" in physx_parameters:
    physx_kwargs["gpu_index"] = gpu_index
physx_kwargs["config"] = ovphysx.PhysXConfig(carbonite_overrides=legacy_overrides)

One deviation from the suggestion: the declared runtime cannot take the typed field at all. Its PhysXConfig predates cooked_collider_cache_dir (verified against an older ovphysx wheel), so the typed keyword would raise TypeError there rather than merely being skipped. It therefore uses the generic /UJITSO/datastore/localCachePath override, while the current runtime keeps the typed field, which is the only route it accepts (0.5.9 rejects the generic key as conflicting with the typed field).

The regression test was extended as you asked, to two legacy constructors x two devices plus the current runtime x two devices, and its stubs now mimic each runtime's real PhysXConfig` signature so this class of mistake fails the test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: the legacy-path fix in my earlier reply was removed — not because the finding was wrong, but because develop deleted the legacy runtime in #6074. The CPU/gpu_index gap is moot: one construction path now, receiving the cache directory unconditionally.

hujc7 added 5 commits August 4, 2026 10:07
The declared runtime's PhysXConfig predates cooked_collider_cache_dir,
so passing that keyword raised TypeError there. The config was also
built only for GPU runs exposing active_cuda_gpus, leaving legacy CPU
runs and the gpu_index constructor on the interpreter-relative
fallback the previous commit set out to remove.

Route the declared runtime through the generic
/UJITSO/datastore/localCachePath override, which it accepts and the
current runtime rejects as conflicting with its typed field, and build
the config unconditionally so both devices and both constructors
receive it.

Fall back to the temporary directory when the home directory cannot be
resolved: expanduser leaves "~" unchanged, and a relative path would
put the cache under the working directory.

Give each stubbed PhysXConfig the signature of the runtime it stands
for, so a keyword the real runtime would reject fails the test instead
of being absorbed.
Both construction sites spelled out which keyword carries the cache
location, so the rule for choosing between the typed field and the
generic override lived in two places and had to be kept in step.

Move it into a single helper that inspects the runtime's PhysXConfig
signature and writes whichever keyword that signature accepts, merging
into any overrides the caller already set. Selecting on the config
signature rather than on which PhysX API is in use also covers a
runtime whose config predates the typed field while its PhysX class
does not, which the previous branch-based choice could not express.
Having the helper decorate a caller-supplied dict meant both call sites
had to name and hold that dict purely to hand it over and splat it
back, so each grew a variable describing nothing the reader needs.

Build and return the PhysXConfig instead. The construction sites become
expressions again and the two intermediate dicts go away, leaving only
the carbonite overrides the legacy branch genuinely assembles.
@hujc7
hujc7 marked this pull request as draft August 4, 2026 20:52
hujc7 added 2 commits August 4, 2026 15:31
The helper that chose between the typed field and the generic override
guarded a runtime whose PhysXConfig and PhysX class disagree about the
typed field. No published wheel does: in every version available, the
field and PhysX.set_cpu_mode appear together or not at all. The branch
already tells the two runtimes apart, so each can name the keyword its
own config accepts.

Drop the helper and construct PhysXConfig directly at both sites, and
name the path helper for what it returns rather than for what one of
its two callers does with it.
@hujc7
hujc7 marked this pull request as ready for review August 4, 2026 22:59
@hujc7

hujc7 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

Comment on lines +970 to +990
@staticmethod
def _derived_data_cache_dir() -> str:
"""Return the canonical Omniverse derived-data cache directory.

Mirrors the location Kit resolves from its ``${omni_cache}`` token. The kitless
OVPhysX runtime cannot resolve that token, and its Carbonite fallback resolves
relative to the Python interpreter binary, which is not writable on installs that
reuse a system interpreter.
"""
if sys.platform == "win32":
base = os.environ.get("LOCALAPPDATA") or os.path.join(os.path.expanduser("~"), "AppData", "Local")
cache_dir = os.path.join(base, "ov", "cache", "DerivedDataCache")
else:
base = os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache")
cache_dir = os.path.join(base, "ov", "DerivedDataCache")
if not os.path.isabs(cache_dir):
# ``expanduser`` leaves "~" unchanged when the home directory cannot be resolved
# (e.g. an arbitrary-UID container with no passwd entry); a relative path would
# put the cache under the working directory.
cache_dir = os.path.join(tempfile.gettempdir(), "ov", "DerivedDataCache")
return cache_dir

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use this, if IsaacSim is not installed does this even exists?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moot as of 703f20c — the code no longer targets an Omniverse-managed location at all. The directory is a config field defaulting under the system temp directory, so nothing depends on an Isaac Sim install having created anything.

On the underlying question: measured against the real 0.5.9 wheel, pointed at an empty temp root, _create_physx_instance created the whole cache tree from nothing.

# ``expanduser`` leaves "~" unchanged when the home directory cannot be resolved
# (e.g. an arbitrary-UID container with no passwd entry); a relative path would
# put the cache under the working directory.
cache_dir = os.path.join(tempfile.gettempdir(), "ov", "DerivedDataCache")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review: This fallback uses the same predictable <temp>/ov/DerivedDataCache directory for every user. On a shared Linux host, the first user to create /tmp/ov will normally own it, so another arbitrary-UID process may be unable to write the cache and hit the same datastore failure this branch is intended to avoid; another user can also pre-populate that cache. Could we use a securely created temporary directory (for example, tempfile.mkdtemp(...)) or another safely per-user location here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 703f20c. The path is now a public config field, OvPhysxCfg.cooked_collider_cache_dir, defaulting to <system temp>/ovphysx_derived_data_cache_<uid>.

Measured with the 0.5.9 wheel: the runtime creates the directory 0755 owned by whoever runs first, so a fixed shared name really does lock out the second UID — with the same omni.datastore error this PR removes. Windows has no getuid and its temp root is already per-user, so the suffix applies only where it exists.

Not mkdtemp: it returns a fresh directory per process, so the cache would never be reused and the directories would accumulate. Caveat worth stating — per-user is not securely created; the path is predictable. Sites needing a hardened or shared location set the config field.



@pytest.mark.skipif(sys.platform == "win32", reason="cache root is LOCALAPPDATA-derived on Windows")
def test_manager_passes_explicit_derived_data_cache_dir(monkeypatch, tmp_path):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review: The regression is worth covering: the neighboring runtime-API tests do not assert the cache setting, and a focused test would have caught the earlier legacy-CPU omission. The full 3 × 2 matrix seems larger than the distinct behavior, though, while the decorator skips the only platform-specific branch added by this PR. Could we fold strict PhysXConfig fakes and cache assertions into the existing current/legacy API tests, retain focused cases for legacy CPU and gpu_index, and make the expectation conditional on LOCALAPPDATA versus XDG_CACHE_HOME instead of skipping Windows? That preserves the useful regression coverage with less duplicated fixture code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 703f20c. The skip is gone because the platform branch is gone: the directory is injected into _create_physx_instance now, not derived from LOCALAPPDATA/XDG_CACHE_HOME.

The matrix collapsed further than proposed — develop removed the pre-0.5.9 runtime in #6074, so two of the three runtimes no longer exist. The cache assertion and a strict PhysXConfig fake fold into develop's test_manager_supports_pinned_runtime_api as you suggested, replacing its lambda **kwargs stub. Removing the keyword fails both parametrizations, verified.

Your point generalised: test_ovphysx_manager_lifecycle's fake had the opposite drift — it rejected a keyword the real wheel accepts — and now carries the field too.

hujc7 added 7 commits August 10, 2026 17:04
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
The fallback fires when no absolute home-based path resolves, and it used a
fixed <temp>/ov directory. On a shared POSIX host the temp root is
world-writable, so the first user to create it owns it and every other UID
either cannot write the cache or reads collider data that user placed there.
Windows already gives each user a private temp directory, so the UID suffix
is applied only where os.getuid exists.
Follow the pattern the sibling kitless runtime already uses: OVRTXRendererCfg
declares log_file_path with a temp-rooted default and threads it into
RendererConfig. The cache directory now lives on OvPhysxCfg the same way,
replacing the bespoke XDG_CACHE_HOME/LOCALAPPDATA resolution, which was the
only such code in source/.

The default is per-user (<temp>/ovphysx_derived_data_cache_<uid>) because the
POSIX temp root is shared: a fixed name is created 0755 by whoever runs first,
so a second user cannot write it and hits the omni.datastore failure this
branch removes. Windows has no getuid and already gives each user a private
temp root, so the suffix is applied only where it exists.

_create_physx_instance takes the directory as an argument, and the caller
falls back to the module default because the runtime is also constructed
outside a configured simulation. Both PhysXConfig fakes gain the field so they
mirror the real 0.5.9 signature instead of diverging from it.
Develop folded isaaclab_ovphysx into isaaclab_ov, which left this branch's
fragment as the only tracked file under the deleted package and pointed its
:attr: reference at a module that no longer exists.
The fragment adds OvPhysxCfg.cooked_collider_cache_dir, a new public API, which
contributing.rst requires to carry the .minor.rst tier. It started this branch
as a private helper, so the fragment was written before that was true and
compiled to a patch bump.
@hujc7
hujc7 requested a review from AntoineRichard August 13, 2026 17:50

@marcodiiga marcodiiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one blocking issue in the default cache location: on shared POSIX systems, the predictable path can be pre-created and redirect datastore writes before IsaacLab starts. The behavior is reproducible with both the runtime pinned by this branch and ovphysx 0.5.10. I also left focused comments on the config-to-runtime seam, the storage lifecycle contract, and the release note. Current develop now pins ovphysx 0.5.10, so please rebase and revalidate there after addressing the comments.

# POSIX temp roots are shared between users; Windows already gives each user a private one.
_CACHE_DIR_NAME = f"ovphysx_derived_data_cache_{os.getuid()}" if hasattr(os, "getuid") else "ovphysx_derived_data_cache"

DEFAULT_COOKED_COLLIDER_CACHE_DIR: str = os.path.join(tempfile.gettempdir(), _CACHE_DIR_NAME)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on the earlier shared-temp discussion: could we close the remaining pre-creation hole before making this the default? I verified with both the runtime pinned by this branch and ovphysx 0.5.10 that a pre-existing cache-file symlink under this predictable directory is followed and the linked file is modified during an otherwise successful cook. The UID suffix prevents accidental cross-user collisions, but it does not establish ownership of the path on a shared POSIX host. Please use a per-user cache root whose parent is not writable by other users, or atomically create and validate an owner-only, non-symlink directory (including ownership of an existing entry) before passing it to ovphysx.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ea4ab2. _prepare_default_cache_dir creates the default with os.makedirs(..., mode=0o700) and, if the path exists, os.lstat-rejects a symlink, a non-directory, or another uid's directory before ovphysx sees it.

Took your second option to keep the temp-rooted default consistent with OVRTXRendererCfg.log_file_path. A configured directory passes through untouched, so pointing the field at a site-provisioned shared cache still works.

Residual: a TOCTOU window between our lstat and ovphysx opening the path. Your home-rooted-parent option closes it structurally — say the word and I'll switch.

ovphysx.bootstrap()
cls._physx = cls._create_physx_instance(ovphysx, ovphysx_device, gpu_index)
# The runtime is also constructed outside a configured simulation, where no cfg exists.
cache_dir = getattr(PhysicsManager._cfg, "cooked_collider_cache_dir", DEFAULT_COOKED_COLLIDER_CACHE_DIR)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we pin this config-to-runtime seam in a test and avoid the string-based fallback? test_manager_supports_pinned_runtime_api passes cache_dir directly into _create_physx_instance, so it would stay green if _construct_physx stopped reading OvPhysxCfg.cooked_collider_cache_dir. A lifecycle test can set PhysicsManager._cfg to an OvPhysxCfg with a custom path, invoke _construct_physx, and assert that the fake PhysXConfig receives it; a no-config case can assert the fallback. Since _cfg is already OvPhysxCfg | None, direct access after an explicit None check would also make a field rename fail instead of silently substituting the default.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both done in 6ea4ab2. _construct_physx reads PhysicsManager._cfg through an explicit None check, so a rename raises instead of substituting the default.

test_construct_physx_passes_the_configured_cooked_collider_cache_dir asserts a configured path reaches the fake PhysXConfig, with a no-config fallback case. Verified it fails exactly as you predicted: hardcoding the default leaves the other ten green.

The gap existed because the fixture patches _cfg on OvPhysxManager while the code reads it on PhysicsManager.


class_type = "{DIR}.ovphysx_manager:OvPhysxManager"

cooked_collider_cache_dir: str = DEFAULT_COOKED_COLLIDER_CACHE_DIR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this docstring describe the reachable storage contract? The field is a non-optional str with a concrete default, so "Left unset" is not a state OvPhysxCfg can express. This also enables an on-disk cache by default; ovphysx does not evict entries automatically, and users reclaim space by deleting the directory. Please document that lifecycle. If disabling cross-run persistence is intended after rebasing onto ovphysx 0.5.10, the config type and construction path need to preserve None rather than describe it as an existing option.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ea4ab2 and c61f392. The fix is the type, not the wording: PhysXConfig has accepted str | None since the pinned 0.5.9, so the non-optional str removed a reachable option. Field and _create_physx_instance are now str | None, None is forwarded unchanged, and a test covers it.

Docstring now states the contract plus the lifecycle: ovphysx never evicts, the directory grows and is reclaimed by deletion, and a temp directory may be purged.


* Added :attr:`~isaaclab_ov.physics.OvPhysxCfg.cooked_collider_cache_dir` to select where OVPhysX
writes its cooked-collider cache. It defaults to a per-user directory under the system temporary
directory, and cooked colliders now persist across runs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The A0 result in this PR shows that the old behavior already wrote the cache under the interpreter when that location was writable, so it already persisted across runs. A system temp directory may also be purged. Could we describe the actual change instead, for example: "cooked colliders are now reusable from the configured cache directory while that directory is retained"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6ea4ab2 — A0 was my own evidence against that sentence. It now reads that cooked colliders are reusable from the configured directory for as long as it is retained, and mentions the None option.

hujc7 added 3 commits August 18, 2026 15:55
Marco Alesiani verified on 0.5.9 and 0.5.10 that a symlink planted at the
predictable default path is followed and the linked file written through. The
UID suffix stopped accidental collisions but never established ownership of a
path in the shared temporary directory.

- create the default directory 0o700, and refuse a pre-existing symlink,
  non-directory, or another user's directory before handing it to ovphysx. A
  configured directory is the caller's own choice and is passed through.
- read OvPhysxCfg.cooked_collider_cache_dir explicitly instead of through
  getattr, so a field rename fails instead of substituting the default, and
  cover the config-to-runtime seam that no test pinned.
- widen the field to str | None. PhysXConfig has always accepted None for
  OVPhysX's own resolution, so a non-optional str removed a reachable option.
- document that the cache grows unbounded and is reclaimed by deletion.
@hujc7
hujc7 requested a review from marcodiiga August 19, 2026 17:45
…-derived-data-cache-dir

# Conflicts:
#	source/isaaclab_ov/isaaclab_ov/physics/ovphysx_manager.py

@marcodiiga marcodiiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the current head against the IsaacLab ovphysx construction path and the pinned ovphysx 0.5.10 behavior. The previously blocking default-path issue is addressed: the default leaf is created owner-only, and a pre-existing symlink, non-directory, or foreign-owned directory is rejected before ovphysx receives it. The config-to-runtime seam and the optional None path now have focused coverage; the relevant backend tests pass.

No major P0 found, so approving. I left two non-blocking follow-ups on the public cache-lifecycle wording and Windows portability of the new POSIX-specific test. The backend overview also still says OvPhysxCfg exposes only GPU buffer sizes, so it should mention the new field. Required CI is still running, so this is not a merge-readiness claim.

executable -- for an embedded runtime that is the Python interpreter, whose directory the program does
not own.

OVPhysX never evicts entries, so the directory grows with every distinct cooked collider and is

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: two backend lifecycle details would make this public contract precise. The UJITSO datastore is constructed once, so the first ovphysx construction in a process fixes the cache path; later configs do not relocate it. The datastore also performs budget-driven disk garbage collection, so "never evicts" is inaccurate. Could we document the first-use/process scope, describe the bounded-cache behavior while retaining deletion as a manual reclamation option, and phrase None as "use the runtime default" so the wording does not depend on the current interpreter-directory fallback?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f6e649b. The docstring now states that the datastore is created once per process, so the first construction fixes the location and a later config does not relocate it; that the runtime garbage collects the cache against a disk budget, with deletion as immediate manual reclamation; and phrases None as "use the runtime default" rather than naming the interpreter-directory fallback.

You were right about eviction, and I had the evidence backwards — cachelru.dat is in the on-disk layout I had already measured, and an LRU index is exactly the mechanism I claimed did not exist. The same sentence had reached the changelog fragment and the PR description; both are corrected.

The branch has since merged develop, so it now runs against the ovphysx==0.5.10 pin. PhysXConfig's signature is unchanged there and the cache tree is still created from nothing at the configured path.

monkeypatch.setattr(manager_module, "DEFAULT_COOKED_COLLIDER_CACHE_DIR", str(target))
monkeypatch.setattr(_os, "getuid", lambda: _os.stat(target).st_uid + 1)

with pytest.raises(RuntimeError, match="owned"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking portability: os.getuid does not exist on Windows, so this monkeypatch raises before the assertion. Please make this test POSIX-only or patch with raising=False. The exact 0o700 mode assertion above is also POSIX-specific and should be guarded.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f6e649b — all three POSIX-specific tests now carry @pytest.mark.skipif(sys.platform == "win32", ...), covering both the os.getuid monkeypatch and the exact 0o700 mode assertion.

Two notes. This class cannot be caught here by CI: Installation Tests run ARM and x86, not Windows, so review is the only gate. And I had asserted the os.getuid availability rather than verified it; confirmed since against the CPython docs ("Availability: Unix") and locally via os.getuid is posix.getuid, which is why it has no nt counterpart.

hujc7 added 2 commits August 24, 2026 08:51
Marco Alesiani pointed out two inaccuracies in the public contract. The UJITSO
datastore is created once per process, so the first construction fixes the cache
location and a later config does not relocate it; and the runtime garbage
collects the cache against a disk budget, so "never evicts" was wrong. The
on-disk cachelru.dat was already evidence of that and was read backwards. The
same sentence had reached the changelog fragment and the PR description.

`None` is now described as "use the runtime default" rather than by naming the
current interpreter-directory fallback, which is a runtime detail.

The ownership and mode tests are POSIX-only: os.getuid does not exist on
Windows, so the monkeypatch raised before reaching the assertion.
@hujc7

hujc7 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

@AntoineRichard for review if there's additional things that should be fixed.

@hujc7
hujc7 enabled auto-merge (squash) August 26, 2026 06:08
@hujc7
hujc7 merged commit 5c34c42 into isaac-sim:develop Aug 27, 2026
47 of 48 checks passed
@kellyguo11

Copy link
Copy Markdown
Contributor

does this need to be cherry picked to release branch?

kellyguo11 added a commit that referenced this pull request Sep 4, 2026
# Description

Backports the following merged `develop` PRs to `release/3.0.0`:

- #7220 — prune unused Docker volumes on package-test runners
- #7169 — cache the resolved OVRTX Warp device
- #6889 — move the OVPhysX collider cache out of the Python interpreter
directory
- #7345 — document the registered XR camera PiP tasks
- #7050 — update and reorganize the LEAPP documentation
- #7473 — register external RSL-RL tasks before agent discovery
- #7467 — update the China storage profile to Isaac Sim 6.1
- #7385 — accept legal float scale values when seeding Fabric frame
views from USD
- #7517 — use lazy exports in `isaaclab_rl`

The duplicate #7517 in the original request is included once.

Seven source commits replayed cleanly. Two required release-specific
reconciliation:

- #7169 retains the release branch's mapped OVRTX write path, which was
removed separately on `develop`, while resolving and caching one Warp
device for render-product IDs, mappings, and CUDA streams.
- #7050 preserves the #7494 export-backend clarification that is already
present on the release branch while applying the broader LEAPP
documentation overhaul.

No new dependencies are added.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Performance improvement
- Documentation update
- CI/infrastructure update

## Release backport

- [ ] <!-- backport-active-release --> This PR already targets the
active release branch; do not backport it again.

## Validation

- `uv run --no-project --with pytest python -m pytest -q
.github/actions/run-package-tests/test_cleanup_docker_storage.py` — 10
passed
- Nine isolated `isaaclab_rl` namespace/lazy-import regression cases
passed
- Resolved-device OVRTX mapping behavior check passed with Warp 1.16.0
- `uv run --no-project python -m compileall -q` on all changed Python
modules and tests
- `uv run --no-project python tools/changelog/cli.py check` against the
exact `upstream/release/3.0.0` base
- `pre-commit==4.6.2 run --all-files` passed all available hooks
- `git diff --check upstream/release/3.0.0..HEAD`

The full project test environment and documentation build cannot resolve
on this macOS/arm64 host because the release lockfile supports Linux and
Windows only. The Git LFS hook was also unavailable because `git-lfs` is
not installed; none of the changed paths are LFS-tracked. Linux CI
remains authoritative for simulator, OVRTX, Fabric, and full
documentation validation.

## Checklist

- [x] I have read and understood the contribution guidelines
- [x] I have run the available formatting and static checks
- [x] I have included the corresponding documentation changes
- [x] Each touched source package includes its original changelog
fragment
- [x] Every backported commit records its source commit with `cherry
picked from commit`
- [x] The original contributors are preserved as commit authors

---------

Signed-off-by: Zeng Qingcheng <[email protected]>
Co-authored-by: myurasov-nv <[email protected]>
Co-authored-by: Peter Verswyvelen <[email protected]>
Co-authored-by: pv-nvidia <[email protected]>
Co-authored-by: hujc <[email protected]>
Co-authored-by: hougantc-nvda <[email protected]>
Co-authored-by: Frank Lai NV <[email protected]>
Co-authored-by: peterd-NV <[email protected]>
Co-authored-by: Sheikh Dawood <[email protected]>
Co-authored-by: Zeng Qingcheng <[email protected]>
Co-authored-by: Antoine RICHARD <[email protected]>
Co-authored-by: Mustafa H <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants