Unverified Commit 7c94a4e6 authored by matthewtrepte's avatar matthewtrepte Committed by GitHub

Adds periodic logging when checking USD path on Nucleus server (#3221)

# Description

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

Add periodic logs when checking if a USD path exists on a Nucleus
Server.

Improves user experience when the check takes a while, usually because
of no internet connection or the file doesn't exist.

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- New feature (non-breaking change which adds functionality)

## Screenshots

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

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

## Checklist

- [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 updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------
Signed-off-by: 's avatarmatthewtrepte <mtrepte@nvidia.com>
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 403daeab
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.45.6" version = "0.45.7"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.45.7 (2025-08-21)
~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added periodic logging when checking if a USD path exists on a Nucleus server
to improve user experience when the checks takes a while.
0.45.6 (2025-08-22) 0.45.6 (2025-08-22)
...@@ -12,7 +20,6 @@ Fixed ...@@ -12,7 +20,6 @@ Fixed
* Fixed :meth:`~isaaclab.envs.mdp.events.randomize_rigid_body_com` to broadcasts the environment ids. * Fixed :meth:`~isaaclab.envs.mdp.events.randomize_rigid_body_com` to broadcasts the environment ids.
0.45.5 (2025-08-21) 0.45.5 (2025-08-21)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
...@@ -34,8 +41,8 @@ Added ...@@ -34,8 +41,8 @@ Added
* Added unit tests for :class:`~isaaclab.sensor.sensor_base` * Added unit tests for :class:`~isaaclab.sensor.sensor_base`
0.45.3 (2025-08-20) 0.45.3 (2025-08-20)
~~~~~~~~~~~~~~~~~~~
Fixed Fixed
^^^^^ ^^^^^
......
...@@ -24,6 +24,7 @@ from isaaclab.sim import converters, schemas ...@@ -24,6 +24,7 @@ from isaaclab.sim import converters, schemas
from isaaclab.sim.utils import ( from isaaclab.sim.utils import (
bind_physics_material, bind_physics_material,
bind_visual_material, bind_visual_material,
check_usd_path_with_timeout,
clone, clone,
is_current_stage_in_memory, is_current_stage_in_memory,
select_usd_variants, select_usd_variants,
...@@ -256,18 +257,16 @@ def _spawn_from_usd_file( ...@@ -256,18 +257,16 @@ def _spawn_from_usd_file(
Raises: Raises:
FileNotFoundError: If the USD file does not exist at the given path. FileNotFoundError: If the USD file does not exist at the given path.
""" """
# get stage handle # check if usd path exists with periodic logging until timeout
stage = get_current_stage() if not check_usd_path_with_timeout(usd_path):
# check file path exists
if not stage.ResolveIdentifierToEditTarget(usd_path):
if "4.5" in usd_path: if "4.5" in usd_path:
usd_5_0_path = usd_path.replace("http", "https").replace("/4.5", "/5.0") usd_5_0_path = usd_path.replace("http", "https").replace("/4.5", "/5.0")
if not stage.ResolveIdentifierToEditTarget(usd_5_0_path): if not check_usd_path_with_timeout(usd_5_0_path):
raise FileNotFoundError(f"USD file not found at path at either: '{usd_path}' or '{usd_5_0_path}'.") raise FileNotFoundError(f"USD file not found at path at either: '{usd_path}' or '{usd_5_0_path}'.")
usd_path = usd_5_0_path usd_path = usd_5_0_path
else: else:
raise FileNotFoundError(f"USD file not found at path at: '{usd_path}'.") raise FileNotFoundError(f"USD file not found at path at: '{usd_path}'.")
# spawn asset if it doesn't exist. # spawn asset if it doesn't exist.
if not prim_utils.is_prim_path_valid(prim_path): if not prim_utils.is_prim_path_valid(prim_path):
# add prim as reference to stage # add prim as reference to stage
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
from __future__ import annotations from __future__ import annotations
import asyncio
import contextlib import contextlib
import functools import functools
import inspect import inspect
import re import re
import time
from collections.abc import Callable from collections.abc import Callable
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
...@@ -998,6 +1000,72 @@ def select_usd_variants(prim_path: str, variants: object | dict[str, str], stage ...@@ -998,6 +1000,72 @@ def select_usd_variants(prim_path: str, variants: object | dict[str, str], stage
) )
"""
Nucleus Connection
"""
async def _is_usd_path_available(usd_path: str, timeout: float) -> bool:
"""
Asynchronously checks whether the given USD path is available on the server.
Args:
usd_path: The remote or local USD file path to check.
timeout: Timeout in seconds for the async stat call.
Returns:
True if the server responds with OK, False otherwise.
"""
try:
result, _ = await asyncio.wait_for(omni.client.stat_async(usd_path), timeout=timeout)
return result == omni.client.Result.OK
except asyncio.TimeoutError:
omni.log.warn(f"Timed out after {timeout}s while checking for USD: {usd_path}")
return False
except Exception as ex:
omni.log.warn(f"Exception during USD file check: {type(ex).__name__}: {ex}")
return False
def check_usd_path_with_timeout(usd_path: str, timeout: float = 300, log_interval: float = 30) -> bool:
"""
Synchronously runs an asynchronous USD path availability check,
logging progress periodically until it completes.
This is useful for checking server responsiveness before attempting to load a remote asset.
It will block execution until the check completes or times out.
Args:
usd_path: The remote USD file path to check.
timeout: Maximum time (in seconds) to wait for the server check.
log_interval: Interval (in seconds) at which progress is logged.
Returns:
True if the file is available (HTTP 200 / OK), False otherwise.
"""
start_time = time.time()
loop = asyncio.get_event_loop()
coroutine = _is_usd_path_available(usd_path, timeout)
task = asyncio.ensure_future(coroutine)
next_log_time = start_time + log_interval
first_log = True
while not task.done():
now = time.time()
if now >= next_log_time:
elapsed = int(now - start_time)
if first_log:
omni.log.warn(f"Checking server availability for USD path: {usd_path} (timeout: {timeout}s)")
first_log = False
omni.log.warn(f"Waiting for server response... ({elapsed}s elapsed)")
next_log_time += log_interval
loop.run_until_complete(asyncio.sleep(0.1)) # Yield to allow async work
return task.result()
""" """
Isaac Sim stage utils wrappers to enable backwards compatibility to Isaac Sim 4.5 Isaac Sim stage utils wrappers to enable backwards compatibility to Isaac Sim 4.5
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment