Repository navigation
[PresetCLI] Make physics=/renderer=/presets= work on the unified train/play scripts - #5715
Conversation
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
This PR correctly wires the typed preset CLI (physics=, renderer=, presets=) into the unified train/play scripts for 4 RL libraries (rl_games, rsl_rl, sb3, skrl). The changes follow the established pattern from PR #5587 that was missed during the #5623 merge.
✅ Strengths
1. Correct API Usage
All 8 files correctly replace parser.parse_known_args() with setup_preset_cli(parser) and apply fold_preset_tokens() before Hydra consumption. The pattern aligns exactly with the documented usage in preset_cli.py.
2. Proper Handling of External Callbacks
The rsl_rl/train_rsl_rl.py change correctly handles the --external_callback intersection flow:
intersected = list_intersection(remaining_args, remaining_args_env_registration)
set_hydra_args(fold_preset_tokens(intersected))This preserves vocabulary matching (pre-fold intersection) as documented.
3. Consistent Import Organization
Train scripts use local imports inside _parse_args() while play scripts use module-level imports—both approaches are valid and match existing patterns in the codebase.
4. Clear Documentation
The inline comments explaining the setup_preset_cli/fold_preset_tokens split are helpful for future maintainers.
🔍 Observations
1. Import Placement Consistency
Train scripts add imports inside _parse_args():
def _parse_args(argv: list[str]) -> argparse.Namespace:
from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cliWhile play scripts use module-level imports. Both work correctly, but the inconsistency is worth noting. Consider standardizing if the team has a preference.
2. rlinf Scripts Exclusion
The PR description correctly notes that train_rlinf.py/play_rlinf.py are out of scope since they use their own GlobalHydra instance. This is appropriate scoping for a bug fix.
🧪 Test Coverage
The existing test_preset_cli.py provides good unit coverage for setup_preset_cli and fold_preset_tokens. The PR relies on these existing tests plus manual smoke testing.
Suggestion: Consider adding an integration test that exercises the end-to-end flow through a unified script entry point with a preset selector token. This would catch similar merge-ordering regressions in the future.
⚠️ Minor Suggestions
-
Error message clarity: If users provide invalid preset names, they get a helpful error listing available variants. Verified this behavior is preserved through the integration.
-
Documentation sync: The docstrings in
preset_cli.pyreferencersl_rl/{train,play}.pybut the actual paths are nowrsl_rl/train_rsl_rl.pyandrsl_rl/play_rsl_rl.py. Consider updating the docstrings for accuracy (separate follow-up PR).
Verdict
LGTM – The implementation correctly addresses the regression with minimal, focused changes. The approach is consistent with the existing preset CLI architecture.
Greptile SummaryThis PR wires
Confidence Score: 5/5Safe to merge — changes are a consistent, mechanical application of the preset CLI pattern to 8 scripts with no logic alterations beyond the targeted CLI wiring. All 8 files apply the same two-function swap (parse_known_args → setup_preset_cli, plus fold_preset_tokens wrapping the remainder). The rsl_rl scripts correctly preserve the pre-fold list_intersection ordering that preset_cli.py's own docstring prescribes. fold_preset_tokens and setup_preset_cli are both properly exported from isaaclab_tasks.utils via the .pyi stub. No existing imports were dropped and no control flow was changed outside the targeted CLI parsing path. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "Wire preset CLI into unified train/play ..." | Re-trigger Greptile |
The typed preset selectors (physics=NAME, renderer=NAME, presets=NAME) from isaac-sim#5587 fail on the unified `scripts/reinforcement_learning/train.py` dispatcher with `Key 'physics' is not in struct`, because the new `train_<library>.py` / `play_<library>.py` scripts introduced by isaac-sim#5623 forward the argparse remainder straight to Hydra without folding the typed tokens into the canonical `presets=<csv>` form. They also don't register the preset-selection help text, so `--help` output doesn't list the syntax. isaac-sim#5623 landed at 2026-05-15 13:03 PDT, isaac-sim#5587 at 14:31 PDT the same day. isaac-sim#5587's diff applied `setup_preset_cli` + `fold_preset_tokens` to the older `*/train.py` / `*/play.py` scripts that existed when the PR was opened; the post-isaac-sim#5623 rebase pulled in the new entrypoint files but didn't apply the same integration because they were not in the PR's diff context. Apply the canonical pattern from `isaaclab_tasks.utils.preset_cli` to the 4 unified train scripts and the 4 unified play scripts. `setup_preset_cli` registers the preset-selection help text on each library's parser and runs `parse_known_args`; `fold_preset_tokens` rewrites the typed selectors into the canonical form post-argparse. Both help-text discovery and the fold work whether invoked through the unified dispatcher or directly. `train_rlinf.py` / `play_rlinf.py` are out of scope -- they manage their own GlobalHydra instance and have never been integrated with the typed-preset CLI. Verified locally on develop: python scripts/reinforcement_learning/train.py --rl_library rsl_rl \ --task=Isaac-Ant-v0 physics=newton_mjwarp --headless reproduces the "Key 'physics' is not in struct" error before the fix and launches Newton training successfully after. Same command via direct invocation (`python scripts/reinforcement_learning/rsl_rl/play_rsl_rl.py ... physics=newton_mjwarp ...`) and `--help` discoverability both verified.
7185e9f to
4e9ebc7
Compare
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot — Updated Review
Previous review: 4333032630 at 7185e9f5
Current commit: 4e9ebc75
Changes Since Last Review
The branch was force-pushed/rebased with no substantive code changes — the implementation remains identical. The previous review findings still apply.
Summary
This PR correctly wires the typed preset CLI (physics=, renderer=, presets=) into the unified train/play scripts for 4 RL libraries (rl_games, rsl_rl, sb3, skrl). The changes follow the established pattern from PR #5587 that was missed during the #5623 merge.
✅ Strengths
1. Correct API Usage
All 8 files correctly replace parser.parse_known_args() with setup_preset_cli(parser) and apply fold_preset_tokens() before Hydra consumption. The pattern aligns exactly with the documented usage in preset_cli.py.
2. Proper Handling of External Callbacks
The rsl_rl/train_rsl_rl.py change correctly handles the --external_callback intersection flow:
intersected = list_intersection(remaining_args, remaining_args_env_registration)
set_hydra_args(fold_preset_tokens(intersected))This preserves vocabulary matching (pre-fold intersection) as documented.
3. Consistent Import Organization
Train scripts use local imports inside _parse_args() while play scripts use module-level imports—both approaches are valid and match existing patterns in the codebase.
4. Clear Documentation
The inline comments explaining the setup_preset_cli/fold_preset_tokens split are helpful for future maintainers.
🔍 Observations
1. Import Placement Consistency
Train scripts add imports inside _parse_args():
def _parse_args(argv: list[str]) -> argparse.Namespace:
from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cliWhile play scripts use module-level imports. Both work correctly, but the inconsistency is worth noting. Consider standardizing if the team has a preference.
2. rlinf Scripts Exclusion
The PR description correctly notes that train_rlinf.py/play_rlinf.py are out of scope since they use their own GlobalHydra instance. This is appropriate scoping for a bug fix.
🧪 CI Status
CI checks are currently pending. No failures detected at time of review.
⚠️ Minor Suggestions
-
Documentation sync: The docstrings in
preset_cli.pyreferencersl_rl/{train,play}.pybut the actual paths are nowrsl_rl/train_rsl_rl.pyandrsl_rl/play_rsl_rl.py. Consider updating the docstrings for accuracy (separate follow-up PR). -
Integration test: Consider adding an integration test that exercises the end-to-end flow through a unified script entry point with a preset selector token. This would catch similar merge-ordering regressions in the future.
Verdict
LGTM – The implementation correctly addresses the regression with minimal, focused changes. The approach is consistent with the existing preset CLI architecture.
|
thanks! would be good to also have some unit tests for these scripts |
Cover the 4 train + 4 play unified entrypoints by invoking each through
the unified dispatcher (`{train,play}.py --rl_library <name>`) with
`physics=does_not_exist`. The test asserts:
- the Hydra struct-override error ("Key 'physics' is not in struct") is
absent, proving fold_preset_tokens ran before Hydra processed the
arguments; and
- the resolver's own "Unknown preset(s)" error is present, proving the
folded token reached resolve_task_config.
Resolve fails before any Kit/sim launch, so each subprocess exits in
seconds without GPU. 8 parametrized cases, ~20 s total on CPU.
This guards against the regression that originally motivated PR isaac-sim#5715:
new train/play entrypoints landed without the preset CLI integration
because the unified dispatcher refactor and the typed preset CLI PR
merged within 90 minutes of each other on parallel filesets.
rlinf is intentionally excluded -- those scripts manage their own
GlobalHydra and have never been integrated with the typed preset CLI.
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot — Updated Review
Previous review: 4333094896 at 4e9ebc75
Current commit: 0dc06846b18fdd2681482fa92ff45aac6cdbd97f
Changes Since Last Review
The new commit adds a comprehensive regression test (test_typed_preset_cli_train_play.py) that exercises all 8 unified train/play entrypoints. This addresses the test coverage suggestion from the previous review.
Summary
This PR correctly wires the typed preset CLI (physics=, renderer=, presets=) into the unified train/play scripts for 4 RL libraries (rl_games, rsl_rl, sb3, skrl) and now includes a thorough regression test suite.
Design Assessment
Design is sound. The implementation follows the canonical pattern documented in preset_cli.py:
setup_preset_cli(parser)registers help text and parses argsfold_preset_tokens(remaining)rewrites typed selectors before Hydra consumption
The special handling in rsl_rl/train_rsl_rl.py for --external_callback intersection correctly preserves pre-fold vocabulary matching.
Findings
🔵 Suggestion: Import placement consistency — multiple files
Train scripts add imports inside _parse_args():
def _parse_args(argv: list[str]) -> argparse.Namespace:
from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cliWhile play scripts use module-level imports. Both approaches work correctly and the difference has justification (train scripts use deferred imports to avoid loading heavy modules before argument parsing), but consider documenting this pattern or standardizing in a future cleanup.
Test Coverage
✅ Regression test added — The new test_typed_preset_cli_train_play.py provides excellent coverage:
- All 8 entrypoints tested: 4 train + 4 play via unified dispatcher
- Tests the specific failure mode: Asserts Hydra struct error is absent AND resolver's "Unknown preset(s)" error is present
- Deterministic: No GPU required, subprocess isolation, 120s timeout
- Documents exclusions:
rlinfomission is explicitly justified in the docstring - Guards against future regressions: Would catch similar merge-ordering issues
CI Status
Core checks passing:
- ✅ Build Wheel
- ✅ pre-commit
- ✅ Check changelog fragments
- ⏳ Docker builds and license-check pending
Verdict
No issues found — Clean implementation that correctly addresses the regression with minimal, focused changes. The addition of the regression test suite completes the fix by protecting against future reoccurrence.
…y scripts (#5715) (#5724) Cherry-pick of #5715 to `release/3.0.0-beta2`. ## 1. Summary - Typed preset selectors (`physics=NAME`, `renderer=NAME`, `presets=NAME`) from #5587 silently fail on the unified `scripts/reinforcement_learning/train.py` dispatcher with `Key 'physics' is not in struct`. - Root cause is merge-ordering between #5587 (preset CLI, 2026-05-15 14:31 PDT) and #5623 (unified train/play refactor, 2026-05-15 13:03 PDT): the new `train_<library>.py` / `play_<library>.py` files were authored without the `setup_preset_cli` + `fold_preset_tokens` integration that #5587 had applied to the older scripts. - Wires the integration into the 4 unified train scripts and the 4 unified play scripts. Adds a regression test (`scripts/reinforcement_learning/test/test_typed_preset_cli_train_play.py`) that drives `physics=does_not_exist` through the unified dispatcher for all 8 entrypoints and asserts the Hydra struct error is absent and the resolver's `Unknown preset(s)` error is present. ## 2. Cherry-picked commits | Commit on `develop` | Cherry-pick | |---|---| | `4e9ebc75595` – Wire preset CLI into unified train/play entrypoints | `debaf15404b` | | `0dc06846b18` – Add subprocess test that typed preset selectors reach the resolver | `c239fbf2e27` | No conflicts; clean cherry-pick. ## 3. Test plan - [x] Repro confirmed before the fix. - [x] All 4 train scripts smoke-tested with `physics=newton_mjwarp` on Isaac-Ant-v0 — each reaches Newton sim init (no Hydra struct error). Both invocation paths (dispatcher + direct) verified. - [x] All 4 play scripts smoke-tested — typed selector resolves; downstream failure is the expected fake-checkpoint `FileNotFoundError`. - [x] `--help` output includes `physics=NAME` / `renderer=NAME` / `presets=NAME[,NAME,...]` with task variant lists. - [x] Invalid value (`physics=does_not_exist`) produces a clear `Unknown preset(s)` error from the resolver. - [x] `scripts/reinforcement_learning/test/test_typed_preset_cli_train_play.py` — 8 parametrized cases pass in ~20 s on CPU. - [x] Pre-commit clean. - [ ] CI green on `Docker + Tests`. ## 4. Out of scope `train_rlinf.py` / `play_rlinf.py` — manage their own `GlobalHydra` instance, never integrated with the typed preset CLI. Adding support is a feature, not a regression fix. ## 5. Related - Develop PR: #5715 - Source PR for the typed preset CLI: #5587 - Source PR for the unified train/play refactor: #5623
1. Summary
physics=NAME,renderer=NAME,presets=NAME) from [PresetCLI] Add typed preset selection with task-aware help #5587 silently fail on the unifiedscripts/reinforcement_learning/train.pydispatcher withKey 'physics' is not in struct.train_<library>.py/play_<library>.pyfiles were authored without thesetup_preset_cli+fold_preset_tokensintegration that [PresetCLI] Add typed preset selection with task-aware help #5587 had applied to the older scripts.2. Repro
Before the fix (on develop):
After the fix: training launches normally with the Newton MuJoCo-Warp backend.
For an invalid value (
physics=does_not_exist) the resolver emits a helpful error listing available variants and their cfg paths:3. Fix
Apply the canonical pattern from
isaaclab_tasks.utils.preset_cli:For train scripts:
For play scripts (which set
sys.argvdirectly):rsl_rl/train_rsl_rl.pyhas an extra--external_callbackintersection step; the fold runs after the intersection, matching the documented pattern.4. Out of scope
train_rlinf.py/play_rlinf.py— these use their ownGlobalHydrainstance and were never integrated with the typed-preset CLI. Adding support is a separate feature, not a regression.5. Test plan
physics=newton_mjwarpon Isaac-Ant-v0 — each reaches Newton sim init (no Hydra struct error). Verified via the unified dispatcher AND via direct library-script invocation.physics=newton_mjwarp+ a fake--checkpoint— each resolves env_cfg + agent_cfg successfully and fails downstream at checkpoint loading (expected; proves the typed selector was accepted). Both invocation paths verified.--helpoutput includesphysics=NAME/renderer=NAME/presets=NAME[,NAME,...]syntax with available variants per task. Verified via both invocation paths.physics=does_not_exist) produces a clear error listing available presets.scripts/reinforcement_learning/test/test_typed_preset_cli_train_play.py— parametrized subprocess test that drivesphysics=does_not_existthrough the unified dispatcher for all 8 train/play entrypoints. Asserts the Hydra struct error is absent and the resolver's "Unknown preset(s)" error is present. ~20 s, no GPU. Verified to fail when any of the 8 scripts is reverted to develop's broken state.Docker + Tests.