Unverified Commit c32db68e authored by Pascal Roth's avatar Pascal Roth Committed by GitHub

Replaces `nucleus_utils` with reimplementation as part of `IsaacLab` (#3921)

# Description

Replaces import of 

```
try:
    import isaacsim.storage.native as nucleus_utils
except ModuleNotFoundError:
    import isaacsim.core.utils.nucleus as nucleus_utils
```

with own utils implemented inside the sim  utils folder.

```
import isaaclab.sim.utils.nucleus as nucleus_utils
```


## Type of change

- Dependency removal

## Checklist

- [ ] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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

---------
Co-authored-by: 's avatarOcti Zhang <zhengyuz@nvidia.com>
parent 7cfd67cb
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
from .utils import * # noqa: F401, F403
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
import logging
import carb
import omni.client
from omni.client import Result
logger = logging.getLogger(__name__)
DEFAULT_ASSET_ROOT_PATH_SETTING = "/persistent/isaac/asset_root/default"
DEFAULT_ASSET_ROOT_TIMEOUT_SETTING = "/persistent/isaac/asset_root/timeout"
def check_server(server: str, path: str, timeout: float = 10.0) -> bool:
"""Check a specific server for a path
Args:
server (str): Name of Nucleus server
path (str): Path to search
timeout (float): Default value: 10 seconds
Returns:
bool: True if folder is found
"""
logger.info(f"Checking path: {server}{path}")
# Increase hang detection timeout
omni.client.set_hang_detection_time_ms(20000)
result, _ = omni.client.stat(f"{server}{path}")
if result == Result.OK:
logger.info(f"Success: {server}{path}")
return True
else:
logger.info(f"Failure: {server}{path} not accessible")
return False
def get_assets_root_path(*, skip_check: bool = False) -> str:
"""Tries to find the root path to the Isaac Sim assets on a Nucleus server
Args:
skip_check (bool): If True, skip the checking step to verify that the resolved path exists.
Raises:
RuntimeError: if the root path setting is not set.
RuntimeError: if the root path is not found.
Returns:
url (str): URL of Nucleus server with root path to assets folder.
"""
# get timeout
timeout = carb.settings.get_settings().get(DEFAULT_ASSET_ROOT_TIMEOUT_SETTING)
if not isinstance(timeout, (int, float)):
timeout = 10.0
# resolve path
logger.info(f"Check {DEFAULT_ASSET_ROOT_PATH_SETTING} setting")
default_asset_root = carb.settings.get_settings().get(DEFAULT_ASSET_ROOT_PATH_SETTING)
if not default_asset_root:
raise RuntimeError(f"The '{DEFAULT_ASSET_ROOT_PATH_SETTING}' setting is not set")
if skip_check:
return default_asset_root
# check path
result = check_server(default_asset_root, "/Isaac", timeout)
if result:
result = check_server(default_asset_root, "/NVIDIA", timeout)
if result:
logger.info(f"Assets root found at {default_asset_root}")
return default_asset_root
raise RuntimeError(f"Could not find assets root folder: {default_asset_root}")
...@@ -32,10 +32,9 @@ try: ...@@ -32,10 +32,9 @@ try:
except ModuleNotFoundError: except ModuleNotFoundError:
from pxr import Semantics from pxr import Semantics
from isaaclab.sim import schemas
from isaaclab.utils.string import to_camel_case from isaaclab.utils.string import to_camel_case
from . import schemas
if TYPE_CHECKING: if TYPE_CHECKING:
from .spawners.spawner_cfg import SpawnerCfg from .spawners.spawner_cfg import SpawnerCfg
......
...@@ -45,11 +45,6 @@ import numpy as np ...@@ -45,11 +45,6 @@ import numpy as np
import os import os
import random import random
try:
import isaacsim.storage.native as nucleus_utils
except ModuleNotFoundError:
import isaacsim.core.utils.nucleus as nucleus_utils
import isaacsim.core.utils.prims as prim_utils import isaacsim.core.utils.prims as prim_utils
import omni.replicator.core as rep import omni.replicator.core as rep
from isaacsim.core.api.world import World from isaacsim.core.api.world import World
...@@ -58,6 +53,8 @@ from isaacsim.core.utils.viewports import set_camera_view ...@@ -58,6 +53,8 @@ from isaacsim.core.utils.viewports import set_camera_view
from PIL import Image, ImageChops from PIL import Image, ImageChops
from pxr import Gf, UsdGeom from pxr import Gf, UsdGeom
import isaaclab.sim.utils.nucleus as nucleus_utils
# check nucleus connection # check nucleus connection
if nucleus_utils.get_assets_root_path() is None: if nucleus_utils.get_assets_root_path() is None:
msg = ( msg = (
......
...@@ -33,7 +33,6 @@ simulation_app = SimulationApp({"headless": args_cli.headless}) ...@@ -33,7 +33,6 @@ simulation_app = SimulationApp({"headless": args_cli.headless})
import logging import logging
import torch import torch
import isaacsim.core.utils.nucleus as nucleus_utils
import isaacsim.core.utils.prims as prim_utils import isaacsim.core.utils.prims as prim_utils
import isaacsim.core.utils.stage as stage_utils import isaacsim.core.utils.stage as stage_utils
import omni.kit.commands import omni.kit.commands
...@@ -45,6 +44,7 @@ from pxr import PhysxSchema, UsdPhysics ...@@ -45,6 +44,7 @@ from pxr import PhysxSchema, UsdPhysics
# import logger # import logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import isaaclab.sim.utils.nucleus as nucleus_utils
# check nucleus connection # check nucleus connection
if nucleus_utils.get_assets_root_path() is None: if nucleus_utils.get_assets_root_path() is None:
......
...@@ -44,11 +44,6 @@ import logging ...@@ -44,11 +44,6 @@ import logging
import os import os
import torch import torch
try:
import isaacsim.storage.native as nucleus_utils
except ModuleNotFoundError:
import isaacsim.core.utils.nucleus as nucleus_utils
import isaacsim.core.utils.prims as prim_utils import isaacsim.core.utils.prims as prim_utils
from isaacsim.core.api.world import World from isaacsim.core.api.world import World
from isaacsim.core.cloner import GridCloner from isaacsim.core.cloner import GridCloner
...@@ -57,6 +52,7 @@ from isaacsim.core.utils.viewports import set_camera_view ...@@ -57,6 +52,7 @@ from isaacsim.core.utils.viewports import set_camera_view
# import logger # import logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import isaaclab.sim.utils.nucleus as nucleus_utils
# check nucleus connection # check nucleus connection
if nucleus_utils.get_assets_root_path() is None: if nucleus_utils.get_assets_root_path() is None:
......
...@@ -38,17 +38,13 @@ import gc ...@@ -38,17 +38,13 @@ import gc
import logging import logging
import torch # noqa: F401 import torch # noqa: F401
try:
import isaacsim.storage.native as nucleus_utils
except ModuleNotFoundError:
import isaacsim.core.utils.nucleus as nucleus_utils
import isaacsim.core.utils.prims as prim_utils import isaacsim.core.utils.prims as prim_utils
from isaacsim.core.api.simulation_context import SimulationContext from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.prims import Articulation from isaacsim.core.prims import Articulation
# import logger # import logger
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import isaaclab.sim.utils.nucleus as nucleus_utils
# check nucleus connection # check nucleus connection
if nucleus_utils.get_assets_root_path() is None: if nucleus_utils.get_assets_root_path() is None:
......
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