Repository navigation
[PresetCLI] Cherry-pick: wire typed preset CLI into unified train/play scripts (#5715) - #5724
Conversation
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.
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.
Code Review Summary
This cherry-pick cleanly integrates the typed preset CLI (setup_preset_cli + fold_preset_tokens) into all 8 unified train/play entrypoints. The implementation is consistent and correct.
✅ What Works Well
Consistent Pattern Application
The same integration pattern is applied uniformly across all 8 scripts:
setup_preset_cli(parser)replacesparser.parse_known_args()- registers preset-selection help textfold_preset_tokens(hydra_args)wraps the args before passing tosys.argvorset_hydra_args()- rewrites typed selectors
Correct Handling of Complex Control Flow
The RSL-RL scripts have additional complexity with external_callback and list_intersection. The implementation correctly:
- In
train_rsl_rl.py: Folds tokens afterlist_intersectionso both paths benefit - In
play_rsl_rl.py: Same approach -fold_preset_tokens(remaining_args)after intersection
Import Structure
- Play scripts: Top-level imports (appropriate for module-level execution)
- Train scripts: Function-scoped imports in
_parse_args()(appropriate for deferred loading)
✅ Test Coverage
The new test file (test_typed_preset_cli_train_play.py) provides excellent regression coverage:
- 8 parametrized cases (train × play × 4 libraries)
- Verifies both conditions:
- Hydra struct error is absent (fold ran before Hydra)
- Resolver error is present (folded token reached resolver)
- Lightweight execution (~20s total, no GPU required)
- Clear documentation of whats tested and why
rlinfis excluded
📋 Notes
- Cherry-pick is clean - no conflicts, straightforward application of the develop fix
- Out of scope is documented -
rlinfscripts manage their own GlobalHydra and are intentionally excluded - CI pending - Recommend waiting for CI to confirm no regressions
Reviewed: architecture/design, error handling, test coverage
Greptile SummaryCherry-picks the typed preset CLI integration (
Confidence Score: 5/5Safe to merge; the change is a focused wiring fix with no behavioural changes for callers that do not use preset selectors. All 8 entrypoints follow the same well-documented pattern. The rsl_rl external-callback path preserves the required pre-fold ordering of list_intersection. The list_intersection(remaining, None) no-callback case is handled correctly by the utility. The test assertions are anchored to the actual error strings produced by the resolver. The only observation is cosmetic: a local import placed mid-function body in three train scripts rather than at the function top. No files require special attention; the test file and all 8 entrypoints look correct. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Dispatcher as train.py / play.py
participant LibScript as train_lib.py / play_lib.py
participant PresetCLI as setup_preset_cli + fold_preset_tokens
participant HydraResolver as Hydra / resolve_presets
User->>Dispatcher: "python train.py --rl_library sb3 --task=X physics=newton"
Dispatcher->>Dispatcher: strip --rl_library, produce library_args
Dispatcher->>LibScript: run(library_args) [train] OR runpy + sys.argv update [play]
LibScript->>PresetCLI: setup_preset_cli(parser, argv)
PresetCLI-->>LibScript: "(args_cli, remaining=[..., physics=newton, ...])"
Note over LibScript: optional list_intersection for rsl_rl external_callback
LibScript->>PresetCLI: fold_preset_tokens(remaining)
PresetCLI-->>LibScript: "[presets=newton, ...]"
LibScript->>HydraResolver: "set_hydra_args([presets=newton]) OR sys.argv=[..., presets=newton]"
HydraResolver-->>LibScript: resolved cfg (or Unknown preset error)
Reviews (1): Last reviewed commit: "Add subprocess test that typed preset se..." | Re-trigger Greptile |
| from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cli | ||
|
|
||
| add_isaaclab_launcher_args(parser) | ||
| args_cli, hydra_args = parser.parse_known_args(argv) | ||
| # setup_preset_cli registers preset-selection help text + runs parse_known_args; | ||
| # fold_preset_tokens rewrites typed selectors (physics=, renderer=, presets=) post-argparse. | ||
| args_cli, hydra_args = setup_preset_cli(parser, argv) |
There was a problem hiding this comment.
The
from isaaclab_tasks.utils import ... import is placed mid-function, after several parser.add_argument calls, rather than at the top of the function body. The companion train_rsl_rl.py groups all local imports at the top of _parse_args, which is the cleaner convention for deferred imports. Moving it to the top of the function would improve readability. The same applies to train_sb3.py and train_skrl.py.
| from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cli | |
| add_isaaclab_launcher_args(parser) | |
| args_cli, hydra_args = parser.parse_known_args(argv) | |
| # setup_preset_cli registers preset-selection help text + runs parse_known_args; | |
| # fold_preset_tokens rewrites typed selectors (physics=, renderer=, presets=) post-argparse. | |
| args_cli, hydra_args = setup_preset_cli(parser, argv) | |
| add_isaaclab_launcher_args(parser) | |
| # setup_preset_cli registers preset-selection help text + runs parse_known_args; | |
| # fold_preset_tokens rewrites typed selectors (physics=, renderer=, presets=) post-argparse. | |
| from isaaclab_tasks.utils import fold_preset_tokens, setup_preset_cli | |
| args_cli, hydra_args = setup_preset_cli(parser, argv) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
7ea13c4
into
isaac-sim:release/3.0.0-beta2
Cherry-pick of #5715 to
release/3.0.0-beta2.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.scripts/reinforcement_learning/test/test_typed_preset_cli_train_play.py) that drivesphysics=does_not_existthrough the unified dispatcher for all 8 entrypoints and asserts the Hydra struct error is absent and the resolver'sUnknown preset(s)error is present.2. Cherry-picked commits
develop4e9ebc75595– Wire preset CLI into unified train/play entrypointsdebaf15404b0dc06846b18– Add subprocess test that typed preset selectors reach the resolverc239fbf2e27No conflicts; clean cherry-pick.
3. Test plan
physics=newton_mjwarpon Isaac-Ant-v0 — each reaches Newton sim init (no Hydra struct error). Both invocation paths (dispatcher + direct) verified.FileNotFoundError.--helpoutput includesphysics=NAME/renderer=NAME/presets=NAME[,NAME,...]with task variant lists.physics=does_not_exist) produces a clearUnknown preset(s)error from the resolver.scripts/reinforcement_learning/test/test_typed_preset_cli_train_play.py— 8 parametrized cases pass in ~20 s on CPU.Docker + Tests.4. Out of scope
train_rlinf.py/play_rlinf.py— manage their ownGlobalHydrainstance, never integrated with the typed preset CLI. Adding support is a feature, not a regression fix.5. Related