Skip to content

Manage localized asset lifetimes with OVStorage leases - #9358

Open
pbarejko wants to merge 1 commit into
isaac-sim:mainfrom
pbarejko:fix/lease-localized-usd
Open

pbarejko wants to merge 1 commit into
isaac-sim:mainfrom
pbarejko:fix/lease-localized-usd

Conversation

@pbarejko

@pbarejko pbarejko commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Release backport

  • Backport this pull request to the active release branch after it merges into main

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request, or run-ci ovstage to include kitless OVStage rendering tests for that run.
Subsequent pushes and plain run-ci comments do not run OVStage tests unless you comment run-ci ovstage again.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@pbarejko
pbarejko requested a review from a team December 2, 2026 22:14
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Dec 2, 2026

@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

Needs attention: Scope and over-engineering (1), Compatibility and deprecation (4), Implementation (1), Style consistency (6), Test quality (2). Other reviewed categories look good.

  • PR description: The title matches; replace template prompts with problem, behavior, and validation, and supply reproducible baseline/candidate hashing-and-copy measurements naming revisions, command, hardware, backend, environment count, warmup, latency, and peak memory.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: Minimal implementation: extend assets.py localization and the existing prims.py and BaseUsdExporter stage owners; keep _asset_cache.py for delegate and filesystem-view lifecycles, but delete its synthetic content origin, publication stack, and associated hashing and locking, writing lease-owned bytes directly. Retain remote caching, dependency localization, stage-held leases, and caller-owned downloads. Scope is cohesive; no split recommended.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: retrieved and published checkpoint paths expire, legacy mirrors lose offline reuse, and saved paths lose refresh behavior; preserve these contracts through functional bridges, targeted warnings, migration/removal guidance, and transition coverage.
  • Implementation: Remote dependency localization now propagates OVStorage errors that previously left unavailable references anchored, aborting even unselected dependencies; restore the availability-based fallback.
  • Style consistency: Replacement public docstrings omit argument, return, failure, and loader constraints required by the documentation guide; restore concise Google-style contracts.
  • Test quality: The cache glob checks the wrong directory and the nested checkpoint assertion repeats an unchanged branch; correct or remove these assertions while retaining distinct lifetime, revision, eviction, packaging, and deferred-payload coverage.

Needs rework. Posted 14 inline findings.

Automated review; human maintainers own approval decisions.

)


class _CacheReads(ovstorage.LayerBase):

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.

🟡 Warning · Style Consistency — Group public definitions first

Private classes and functions precede public functions in the new module, contrary to the contribution guide's module order. Group constants, public functions, private functions, then private classes.


payload: bytes

async def stat(self, address: str, **kwargs):

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.

🟡 Warning · Style Consistency — Annotate new helper returns

_PublishedContent.stat and read, _recover_views, and AssetLease.init omit return annotations required by the typing guide. Add concrete results and -> None where appropriate.

self.active = True
path.parent.mkdir(exist_ok=True, parents=True)

def _remove_view(self, marker: BinaryIO) -> None:

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.

🟡 Warning · Style Consistency — Move private cleanup below public methods

_remove_view interrupts AssetLease's public lifecycle methods, contrary to the prescribed class order. Place it after close.

if isinstance(content, ovstorage.LocalDelegate):
delegate = self.enter_context(content)
else:
address = "isaaclab-content:///" + hashlib.sha256(content).hexdigest()

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.

🟡 Warning · Scope Complexity — Remove synthetic rewritten-byte caching

Rewritten layer bytes already have a lease-owned tree. The synthetic origin adds another stack, hash, lock, and materialization before writing that tree. Write the bytes directly and remove that origin.

"""Guards the lazily built OVStorage stacks."""

_OVSTORAGE_STACKS: dict[str, ovstorage.LayerBase] = {}
_OVSTORAGE_STACKS: dict[tuple[str, Path | None], ovstorage.LayerBase] = {}

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.

🟡 Warning · Style Consistency — Correct the stack-key description

The adjacent docstring says stacks are keyed only by URL origin, but the new key also includes cache mode and directory. Describe the actual key.

elif _is_remote_path(dependency):
# An offline byte-cache hit can compose even when the provider cannot stat it.
try:
resolved = localize(dependency)

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.

🟡 Warning · Implementation — Preserve unavailable reference anchors

Remote dependencies are now downloaded during rewriting, but only two failure types preserve their anchors. Other OVStorage errors abort even an unselected reference. Restore the availability-based fallback.

del stage
assert not Path(path).exists()
assert assets_utils.read_file(f"{root}/actuator.pt").read() == b"network weights"
assert not list(asset_cache.glob("http/**/actuator.pt"))

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.

🟡 Warning · Test Quality — Remove ineffective cache assertion

The fixture sets XDG_CACHE_HOME to tmp_path/cache, but this glob searches tmp_path/http. It passes even if read_file writes the file being checked. Assert the actual cache location or remove it.

"""


def checkpoint_log_dir(checkpoint_path: str, log_root: str, *, nested: bool = False) -> str:

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.

🟡 Warning · Style Consistency — Document checkpoint directory selection

This shared helper does not define nested or its return value in Google-style sections. Document which directory each mode selects.

print(f"Fetching pre-trained checkpoint : {ov_path}")
try:
resume_path = retrieve_file_path(ov_path, download_dir)
resume_path = retrieve_file_path(ov_path)

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.

🟡 Warning · Compatibility — Keep published checkpoint paths persistent

Fresh downloads now return an expiring cache path rather than the established .pretrained_checkpoints path. Retained paths and output locations change. Keep the persistent download and existing defaults through a complete deprecation transition.


output_dir = str(tmp_path / "logs")
assert checkpoint_log_dir(path, output_dir) == output_dir
assert checkpoint_log_dir(path, output_dir, nested=True) == output_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.

🟡 Warning · Test Quality — Remove redundant nested assertion

For a leased checkpoint, checkpoint_log_dir returns before reading nested. This second call exercises the same branch and contract as the preceding assertion. Keep one.

@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[High impact] The PR changes shared asset retrieval used across simulation, training, and task workflows.

The PR appears safe to merge, with non-blocking improvements needed for large downloads and shared-file write protection.

Findings

  1. P2 Downloads fill worker memory ▶
  2. P2 Writes can change shared assets ▶

Summary

Replaces the temporary asset mirror with OVStorage caching and scoped file leases.

  • Remote asset paths now stay available for the lifetime their consumers need.
  • USD stages keep referenced assets available for as long as they need them.
  • Published checkpoints use cached paths, and playback outputs go to experiment logs.
  • Selected sensors and tasks release asset files after loading their contents.
  • Distributed USD spawns no longer wait on one shared file lock.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Asset request] --> B[OVStorage cache]
    B --> C[Leased local filenames]
    C --> D[USD stage or file reader]
    D --> E[Consumer finishes]
    E --> F[Release lease and remove filenames]
    C --> G[Explicit download directory]
    G --> H[Persistent caller-owned copy]
Loading

Reviews (1) · Last reviewed commit: "Manage localized asset lifetimes with OV..." · Reviewed by Greptile

delegate = _asset_cache.cached_delegate(stack, url)
if delegate is not None:
return delegate
data, info = _asset_cache.run(stack.read_bytes(url))

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.

P2 Downloads fill worker memory

On a cache miss, read_bytes puts the entire asset in Python memory before returning a local path. This includes files larger than the cache budget. Previously, _materialize copied from a local file without reading it all into Python memory. Large checkpoints and USD assets can now cause memory spikes or kill a worker. Keep a download-to-file path for callers that request a lease.

Comment on lines +205 to +206
try:
os.link(delegate.path, path)

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.

P2 Writes can change shared assets

publish exposes the shared cache file through a hard link without enforcing the promised read-only access. If a consumer writes in place through the returned path, it changes the cached bytes and every other hard-linked lease. One consumer's mistake can then give other readers bad data. Enforce read-only access before exposing the path, or use a separate copy when writes cannot be blocked.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant