Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed
^^^^^

* Fixed backend factory resolution raising before simulator initialization by using the team-confirmed ``newton``
fallback when no ``SimulationContext`` exists.
9 changes: 6 additions & 3 deletions source/isaaclab/isaaclab/utils/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ def register(cls, name: str, sub_class) -> None:
def _get_backend(cls, *args, **kwargs) -> str:
"""Return active backend name for this factory.

Falls back to ``"physx"`` for backward compatibility when no simulation
context is initialized yet.
Falls back to ``"newton"`` when no simulation context is initialized yet.
"""
# Import lazily to avoid import cycles at module load time.
from isaaclab.sim.simulation_context import SimulationContext

manager_name = SimulationContext.instance().physics_manager.__name__.lower()
sim_context = SimulationContext.instance()
if sim_context is None:
return "newton"

manager_name = sim_context.physics_manager.__name__.lower()
if manager_name.startswith("newton"):
return "newton"
if manager_name.startswith("ovphysx"):
Expand Down
3 changes: 3 additions & 0 deletions source/isaaclab/isaaclab/visualizers/base_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ def physics_backend(self) -> str | None:
Backend name string, or ``None`` when no simulation context is active yet.
"""
try:
from isaaclab.sim.simulation_context import SimulationContext
from isaaclab.utils.backend_utils import FactoryBase

if SimulationContext.instance() is None:
return None
return FactoryBase._get_backend()
except Exception:
return None
Expand Down
8 changes: 8 additions & 0 deletions source/isaaclab/test/utils/test_backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

"""Tests for backend module resolution."""

from isaaclab.sim.simulation_context import SimulationContext
from isaaclab.utils.backend_utils import FactoryBase


Expand All @@ -24,3 +25,10 @@ def test_get_module_name_preserves_other_backend_conventions(monkeypatch):
assert FactoryBase._get_package_name("newton") == "isaaclab_newton"
assert FactoryBase._get_module_name("physx") == "isaaclab_physx.assets.articulation"
assert FactoryBase._get_module_name("newton") == "isaaclab_newton.assets.articulation"


def test_factory_backend_falls_back_to_newton_without_simulation_context(monkeypatch):
"""Backend resolution uses Newton before a simulation context exists."""
monkeypatch.setattr(SimulationContext, "_instance", None)

assert FactoryBase._get_backend() == "newton"
Loading