Adds strict type checking and clear split between cfg and implementation#4718
Conversation
90b17f8 to
245a723
Compare
Greptile SummaryThis PR separates configuration dataclasses from their implementation counterparts across the IsaacLab codebase, and defers heavy simulation-backend imports (
Issues found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph "Before: Cfg + Impl coupled"
A[env_cfg.py / env.py<br/>Combined file] -->|"import omni, carb, pxr"| B[Kit/Simulator Required]
A -->|"contains Cfg + Env class"| C[Cannot load cfg<br/>without simulator]
end
subgraph "After: Cfg / Impl split"
D[env_cfg.py<br/>Pure config dataclass] -->|"no simulator imports"| E[Loadable without Kit]
F[env.py<br/>Implementation only] -->|"import omni, carb, pxr"| G[Kit required at runtime]
F -->|"imports cfg from"| D
H["configclass._validate()"] -->|"resolves 'mod:Class' strings"| I[string_to_callable]
J["has_kit()"] -->|"sys.modules check"| K{"Kit running?"}
K -->|"Yes"| L["import omni.kit.app"]
K -->|"No"| M["Skip import"]
end
style C fill:#f99,stroke:#c00
style E fill:#9f9,stroke:#0c0
Last reviewed commit: 5f0641c |
| if isinstance(value, str) and _CALLABLE_STR_RE.match(value): | ||
| with contextlib.suppress(ImportError, AttributeError, ValueError): | ||
| obj_dict[key] = string_to_callable(value) |
There was a problem hiding this comment.
Silent suppression of resolution errors in validation
The contextlib.suppress(ImportError, AttributeError, ValueError) silently swallows errors when a string matching the "module.path:ClassName" pattern fails to resolve. If a user has a typo in a callable string (e.g., "isaaclab.controllers.rmp_flw:RmpFlowController"), it will be silently left as a string. The actual failure will then surface much later with a cryptic error when the string is used where a callable is expected.
Consider at minimum logging a warning when resolution fails, so users can debug configuration typos more easily:
if isinstance(value, str) and _CALLABLE_STR_RE.match(value):
try:
obj_dict[key] = string_to_callable(value)
except (ImportError, AttributeError, ValueError):
import logging
logging.getLogger(__name__).debug(
"Could not resolve callable string %r for field %r", value, key
)There was a problem hiding this comment.
looks like a good idea!
...ce/isaaclab_tasks/isaaclab_tasks/direct/cart_double_pendulum/cart_double_pendulum_env_cfg.py
Show resolved
Hide resolved
Additional Comments (1)
The camera-based cartpole environments (lines 36, 47, 58, 69, 80, 91) were updated to point to This should be updated to: And the |
| if isinstance(value, str) and _CALLABLE_STR_RE.match(value): | ||
| with contextlib.suppress(ImportError, AttributeError, ValueError): | ||
| obj_dict[key] = string_to_callable(value) |
There was a problem hiding this comment.
looks like a good idea!
source/isaaclab_tasks/isaaclab_tasks/direct/cartpole/cartpole_camera_env_cfg.py
Show resolved
Hide resolved
source/isaaclab_tasks/isaaclab_tasks/direct/cartpole/cartpole_env_cfg.py
Show resolved
Hide resolved
48c0eaf to
ae5b58e
Compare
be1ecd0 to
11b05ff
Compare
Description
Adds strict type checking and split between cfg and implementaion
Fixes # (issue)
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there