-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Problem Description
The current import handling for MuJoCo and Bullet engines masks actual import errors that occur within the farms_mujoco and farms_bullet modules. This makes debugging dependency issues difficult.
Current Code
ENGINE_MUJOCO = False
try:
from farms_mujoco.simulation.simulation import (
Simulation as MuJoCoSimulation,
)
ENGINE_MUJOCO = True
except ImportError:
MuJoCoSimulation = None
ENGINE_BULLET = False
try:
from farms_bullet.simulation.simulation import (
AnimatSimulation as PybulletSimulation
)
ENGINE_BULLET = True
except ImportError:
PybulletSimulation = None
if not ENGINE_MUJOCO and not ENGINE_BULLET:
raise ImportError('Neither MuJoCo nor Bullet are installed')Issue
When farms_mujoco or farms_bullet packages are installed but have internal dependency issues (missing libraries, version mismatches, etc.), the broad except ImportError catches these errors and treats them as if the packages aren't installed at all. This leads to:
- Silent failures: Real configuration problems are hidden
- Misleading error messages: Users get "Neither MuJoCo nor Bullet are installed" instead of the actual error
- Difficult debugging: Developers can't see what's actually wrong
Expected Behavior
The code should distinguish between:
- Package not installed (expected case)
- Package installed but failing to import due to internal errors (needs user attention)
Proposed Solution
Approach using ModuleNotFoundError :
ENGINE_MUJOCO = False
try:
from farms_mujoco.simulation.simulation import (
Simulation as MuJoCoSimulation,
)
ENGINE_MUJOCO = True
except ModuleNotFoundError:
# Package not installed - this is expected
MuJoCoSimulation = None
except ImportError as e:
# Package exists but has internal import issues - re-raise with context
raise ImportError(f"farms_mujoco is installed but failed to import: {e}") from e
ENGINE_BULLET = False
try:
from farms_bullet.simulation.simulation import (
AnimatSimulation as PybulletSimulation
)
ENGINE_BULLET = True
except ModuleNotFoundError:
# Package not installed - this is expected
PybulletSimulation = None
except ImportError as e:
# Package exists but has internal import issues - re-raise with context
raise ImportError(f"farms_bullet is installed but failed to import: {e}") from e
if not ENGINE_MUJOCO and not ENGINE_BULLET:
raise ImportError('Neither MuJoCo nor Bullet packages are installed')Reproduction Steps
To reproduce the current issue:
- Install
farms_mujocowith missing system dependencies - Try to import - you'll get the generic "Neither MuJoCo nor Bullet are installed" message
- The actual dependency error is hidden
jarreguit
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request