Skip to content

Commit abbeda4

Browse files
Trim kitless module stubs in iface test guards
run_ovphysx.sh adds pxr/carb/omni/omni.kit/omni.kit.app to PYTHONPATH, so they are real imports under the kitless run -- not stubs. Only the modules that genuinely cannot resolve (isaacsim.core[.simulation_manager], omni.physics[.tensors], omni.physx, omni.timeline, omni.usd) need MagicMock entries. Because ``omni`` is a real namespace package, attribute access on it will not fall through to ``sys.modules`` for missing submodules; install each ``omni.<sub>`` mock as both a ``sys.modules`` entry and an attribute on the live ``omni`` module so ``import omni.timeline`` and later ``omni.timeline.foo()`` access both resolve. Addresses Antoine's PR #5426 review comments on test_rigid_object_iface.py (lines 19, 55) and test_articulation_iface.py (line 29).
1 parent 5cdc178 commit abbeda4

2 files changed

Lines changed: 28 additions & 36 deletions

File tree

source/isaaclab/test/assets/test_articulation_iface.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,20 @@
3434
simulation_app = AppLauncher(headless=True).app
3535
else:
3636
simulation_app = None
37-
# Stub out Kit/Omniverse modules that are unavailable in the kitless
38-
# ovphysx wheel environment so downstream isaaclab_physx imports don't fail.
39-
for _mod in (
40-
"isaacsim.core",
41-
"isaacsim.core.simulation_manager",
42-
"omni",
43-
"omni.physics",
44-
"omni.physics.tensors",
45-
"omni.physx",
46-
"omni.kit",
47-
"omni.kit.app",
48-
"omni.timeline",
49-
"omni.usd",
50-
"carb",
51-
"pxr",
52-
"pxr.Sdf",
53-
"pxr.UsdUtils",
54-
):
37+
# Stub out the Kit/Omniverse modules that are not present under
38+
# run_ovphysx.sh (pxr, carb, omni, omni.kit[.app] are real on PYTHONPATH).
39+
# ``omni`` is a real namespace package, so missing submodules also need
40+
# to be installed as attributes on it -- ``sys.modules`` alone is not
41+
# enough because attribute access on the real ``omni`` won't fall
42+
# through to ``sys.modules``.
43+
import omni as _omni
44+
45+
for _mod in ("physics", "physics.tensors", "physx", "timeline", "usd"):
46+
_stub = MagicMock()
47+
sys.modules[f"omni.{_mod}"] = _stub
48+
# Bind the leaf attribute so that ``omni.<leaf>`` resolves.
49+
setattr(_omni, _mod.split(".", 1)[0], _stub)
50+
for _mod in ("isaacsim.core", "isaacsim.core.simulation_manager"):
5551
sys.modules.setdefault(_mod, MagicMock())
5652

5753
import numpy as np

source/isaaclab/test/assets/test_rigid_object_iface.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,20 @@
3434
simulation_app = AppLauncher(headless=True).app
3535
else:
3636
simulation_app = None
37-
# Stub out Kit/Omniverse modules that are unavailable in the kitless
38-
# ovphysx wheel environment so downstream isaaclab_physx imports don't fail.
39-
for _mod in (
40-
"isaacsim.core",
41-
"isaacsim.core.simulation_manager",
42-
"omni",
43-
"omni.physics",
44-
"omni.physics.tensors",
45-
"omni.physx",
46-
"omni.kit",
47-
"omni.kit.app",
48-
"omni.timeline",
49-
"omni.usd",
50-
"carb",
51-
"pxr",
52-
"pxr.Sdf",
53-
"pxr.UsdUtils",
54-
):
37+
# Stub out the Kit/Omniverse modules that are not present under
38+
# run_ovphysx.sh (pxr, carb, omni, omni.kit[.app] are real on PYTHONPATH).
39+
# ``omni`` is a real namespace package, so missing submodules also need
40+
# to be installed as attributes on it -- ``sys.modules`` alone is not
41+
# enough because attribute access on the real ``omni`` won't fall
42+
# through to ``sys.modules``.
43+
import omni as _omni
44+
45+
for _mod in ("physics", "physics.tensors", "physx", "timeline", "usd"):
46+
_stub = MagicMock()
47+
sys.modules[f"omni.{_mod}"] = _stub
48+
# Bind the leaf attribute so that ``omni.<leaf>`` resolves.
49+
setattr(_omni, _mod.split(".", 1)[0], _stub)
50+
for _mod in ("isaacsim.core", "isaacsim.core.simulation_manager"):
5551
sys.modules.setdefault(_mod, MagicMock())
5652

5753
import numpy as np

0 commit comments

Comments
 (0)