Repository navigation
Fix skrl MARL observation space config keys - #5841
kellyguo11 merged 1 commit into
Conversation
Preserve non-serialized per-agent observation and action space entries when resolving Hydra environment configs. This keeps direct MARL task metadata complete for skrl multi-agent wrappers.
There was a problem hiding this comment.
Code Review Summary
This PR correctly fixes a bug in replace_strings_with_env_cfg_spaces() where non-serialized per-agent space entries were being silently dropped during Hydra config resolution.
What Changed
The Bug: The original dictionary comprehension used if isinstance(v, str) which filtered out any non-string values:
{k: deserialize_space(v) for k, v in getattr(env_cfg, attr).items() if isinstance(v, str)}The Fix: Changed to a conditional expression that preserves non-string values:
{k: deserialize_space(v) if isinstance(v, str) else v for k, v in getattr(env_cfg, attr).items()}Findings
✅ Correctness
- The fix is minimal and surgical — only the necessary line is modified
- The docstring correction (describing deserialization rather than serialization) is accurate
- Backwards compatible with existing all-string dictionaries
✅ Test Coverage
- New test
test_replace_strings_with_env_cfg_spaces_preserves_unserialized_marl_spacesdirectly validates the fix - Test creates a realistic mixed-type scenario with both pre-resolved integers and serialized strings
- Existing test suite remains intact
ℹ️ Observations
- The function now correctly handles mixed dictionaries where some values are already resolved (integers/space objects) and others are still serialized strings
- No new failure modes introduced
- Pre-commit checks passed; CI still running installation and Docker builds
Verdict
Looks good. This is a clean, well-tested bug fix for MARL environment config deserialization. The change preserves the original contract while fixing the edge case where Hydra leaves some space specs unresolved.
Greptile SummaryThis PR fixes a silent data-loss bug in
Confidence Score: 5/5Safe to merge; the change is a minimal, targeted fix that corrects the deserialization loop without altering any serialization path or public API. The diff is a single-expression change that stops the deserialization loop from silently discarding non-string per-agent space entries. The logic is straightforward, the existing round-trip tests still pass, and the new targeted test directly validates the previously broken case with a mixed-type dict. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["replace_strings_with_env_cfg_spaces(env_cfg)"] --> B["Iterate over observation_spaces / action_spaces dict"]
B --> C{{"isinstance(v, str)?"}}
C -- "Yes (Hydra serialized)" --> D["deserialize_space(v)\n→ gymnasium Space or Python spec"]
C -- "No (not serialized by Hydra)" --> E["Pass through as-is\n(integer dim, Space object, …)"]
D --> F["Rebuilt dict with all agents preserved"]
E --> F
F --> G["setattr(env_cfg, attr, rebuilt_dict)"]
Reviews (1): Last reviewed commit: "Fix MARL config space deserialization" | Re-trigger Greptile |
…nt training fixes from develop (#5855) # Description Cherry pick fixes from the develop branch: - #5805 - #5786 - #5787 - #5793 - #5831 - #5853 - #5841 - #5843 --------- Signed-off-by: sameerchavan0027 <[email protected]> Co-authored-by: Antoine RICHARD <[email protected]> Co-authored-by: hujc <[email protected]> Co-authored-by: sameerchavan0027 <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Description
Fixes MARL environment config space deserialization so non-serialized per-agent
space specs are preserved when Hydra resolves task configs. This keeps
cfg.observation_spacesandcfg.action_spacespopulated for all agents incfg.possible_agents, including:Isaac-Cart-Double-Pendulum-Direct-v0(cart,pendulum)Isaac-Shadow-Hand-Over-Direct-v0(right_hand,left_hand)Fixes: N/A (reported from local reproduction)
Type of change
Screenshots
N/A
Test Plan
./isaaclab.sh -p -m pytest source/isaaclab/test/envs/test_spaces_utils.py::test_replace_strings_with_env_cfg_spaces_preserves_unserialized_marl_spaces -q./isaaclab.sh -p -m pytest source/isaaclab/test/envs/test_spaces_utils.py -qresolve_task_config()preserves observation/action spaces for Cart Double Pendulum and Shadow Hand Over withskrl_ippo_cfg_entry_pointandskrl_mappo_cfg_entry_point../isaaclab.sh -fChecklist
pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there