Skip to content

[6Bi] Simplify task preset traversal and CLI help - #8476

Merged
ooctipus merged 2 commits into
isaac-sim:developfrom
ooctipus:refactor/pr6bi-task-preset-cleanup
Oct 13, 2026
Merged

ooctipus merged 2 commits into
isaac-sim:developfrom
ooctipus:refactor/pr6bi-task-preset-cleanup

Conversation

@ooctipus

@ooctipus ooctipus commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Simplify task preset traversal and replace the custom CLI argument scanner, help builder, and formatter with argparse. This includes observable changes to help, error output, and configuration traversal; the examples below show those changes.

Preset parsing, categories, and traversal now live together in isaaclab_tasks.utils.hydra; preset_cli.py and preset_target.py are removed. Preset handling stays in isaaclab_tasks. Runtime launch and visualizer selection changes are in #8126; the independent SDG fix is #8475. 22 files; +354 / −894 lines (540 fewer overall).

Before and after

Unknown preset: same rejection, different error output

uv run isaaclab train --task Isaac-Cartpole-Direct --rl_library rsl_rl presets=typo

Before, the error grouped names by their affected paths:

ValueError: Unknown preset(s): typo

Available presets (grouped by affected paths):

  isaacsim_physx, newton_kamino, newton_mjwarp, ovphysx, physx
    -> env.sim.physics

After, it lists each configuration path and its choices directly, in declaration order:

ValueError: Unknown preset(s): typo
Available presets by config path:
  env.sim.physics: isaacsim_physx, ovphysx, physx, newton_mjwarp, newton_kamino

The command still fails before simulation launch. Typed-selector errors are also shorter. For example:

uv run isaaclab train --task Isaac-Cartpole-Camera-Direct --rl_library rsl_rl physics=rgb

Both revisions reject physics=rgb because RGB is not a physics preset. After this change, the error retains Typed preset selector(s) physics=rgb did not match any preset of that type for this task. and removes the following explanation/suggested fixes.

Help invoked with an explicit argument list now uses that list

uv run python -c 'from isaaclab.cli import train; train(["--task", "Isaac-Cartpole-Direct", "--rl_library", "rsl_rl", "--help"])'
  • Before: help looked at process-wide sys.argv for the task, so it printed Pass --task=X along with --help to see preset variants available for that task, despite the task being supplied to train().
  • After: help reads the supplied arguments and lists isaacsim_physx, newton_kamino, newton_mjwarp, ovphysx, and physx under physics=NAME.

The ordinary uv run isaaclab train --task Isaac-Cartpole-Direct --rl_library rsl_rl --help command lists those choices in both revisions. Help formatting now uses argparse's RawDescriptionHelpFormatter.

Python configuration traversal changes

These affect callers constructing configurations in Python:

from types import SimpleNamespace
from isaaclab_tasks.utils.hydra import collect_presets, preset, resolve_presets

choice = preset(default=1, fast=2)

a = resolve_presets({"items": (choice,)}, ["fast"])["items"][0]
b = resolve_presets(SimpleNamespace(mode=choice), ["fast"]).mode

class Custom:
    mode = choice

c = list(collect_presets(Custom()))
d = list(collect_presets(preset(default={"nested": choice})))
Result Before After
a: preset inside a tuple Unresolved PresetCfg 2
b: preset inside a namespace Unresolved PresetCfg 2
c: discovery on an arbitrary custom object ["mode"] []
d: paths inside a dictionary-valued alternative [""] — the nested key was lost ["", "nested"]

Custom-configuration compatibility: traversal now uses config/dataclass instance fields, namespaces, mappings, lists, and tuples. It no longer inspects arbitrary object properties or class attributes with dir()/getattr(). Callers relying on that discovery must use @configclass fields or one of the supported containers.

Direct imports

Replace isaaclab_tasks.utils.preset_cli and isaaclab_tasks.utils.preset_target imports with isaaclab_tasks.utils.hydra. The package-level from isaaclab_tasks.utils import setup_preset_cli remains unchanged. This consolidation preserves selection and help behavior and fixes the environment documentation tool's stale alias lookup.

Validation

  • Verified the CLI/error and Python examples above against the previous implementation (e21e2515) and the pre-rebase implementation (d00bbe09d).
  • After rebasing onto develop 3c02cf760, 159 focused tests passed across preset composition/help, Franka presets, checkpoint tooling, task discovery, and environment documentation. The existing help test also guards against reintroducing the two removed modules.
  • Formatting/lint and changelog checks passed; the Sphinx build passed with warnings treated as errors.
  • The CI case that previously exited with code 139, test_visualizer_golden[newton-cartpole-kit-tiled], passed locally on GPU0 in 28 seconds. The complete Newton golden-image file finished with 9 passes and 3 image mismatches; all 3 mismatches also reproduced on unmodified develop with effectively identical image scores. No skips, thresholds, or retries were changed.
  • Fresh CI is running for 80aa4326b; the earlier native CI crash has not been reproduced locally or established as fixed.

Type of change

  • Refactoring with CLI help/error and configuration traversal changes
  • Compatibility change for custom objects relying on implicit attribute discovery

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • Read the contribution guidelines
  • Ran formatting/lint and changelog checks
  • Updated and built documentation
  • Validated focused coverage and reviewed consolidated tests
  • Added package changelog fragments
  • Contributor already listed
  • Full CI

@ooctipus
ooctipus requested a review from a team October 12, 2026 06:50
@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Oct 12, 2026
@ooctipus

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 12, 2026
@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Refactors preset selection and CLI help internals.

Fix the remaining alias-method callers before merging; environment-browser tooling currently cannot load.

Findings

  1. P1 Environment browser tooling crashes ▶

Summary

This PR resolves environment and agent presets in one traversal and replaces private CLI help helpers with argparse.

  • Task configuration presets resolve together and report choices by path.
  • Task help lists preset choices for the selected task.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Load environment and agent configs] --> B[Walk both configs together]
    B --> C[Choose each active preset]
    C --> D[Check unknown names and typed choices]
    D --> E[Apply play-mode changes]
    E --> F[Apply scalar overrides]
    G[CLI help] --> H[Parse task with argparse]
    H --> I[Discover preset alternatives]
    I --> J[Print argparse help]
Loading

Reviews (1) · Last reviewed commit: "Simplify task preset traversal and CLI h..." · Reviewed by Greptile

Comment on lines +37 to +39
return isinstance(cfg, self.base_classes) or (
self is PresetTarget.PHYSICS and isinstance(cfg, SimulationCfg) and isinstance(cfg.physics, PhysicsCfg)
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Environment browser tooling crashes

Removing PresetTarget.all_legacy_aliases() breaks tools/environ_docs.py, which still calls it twice while building _BACKEND_MIRROR_NAMES at import time. The environment-browser update command now raises AttributeError before it can run, and tools/test/test_environ_docs.py fails during test collection.

Update these callers to use the shared alias table, or retain a compatible method.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

Needs attention: Compatibility and deprecation (1), Implementation (1), Style consistency (1), Test quality (1). Other reviewed categories look good.

  • PR description: The body matches the traversal/help diff and line counts, but must disclose the PresetTarget API removal and contributing-guide change; this non-hot-path refactor needs no performance evidence.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: documented PresetTarget alias accessors are removed without deprecation; retain forwarding accessors, targeted warnings, migration guidance, removal guidance, and transition coverage.
  • Implementation: Unknown-preset diagnostics emit blank entries for default-only paths, obscuring available choices; filter out paths with no non-default alternatives.
  • Style consistency: Help bullet indentation duplicates the selector width and gap as a space literal; derive it from the same named dimensions.
  • Test quality: Both changed test files were audited; remove the module-introspection assertion because it enforces class absence rather than CLI behavior already covered by help-output tests.

Significant concerns. Posted 4 inline findings.

Automated review; human maintainers own approval decisions.

lines.append(f"'{name}' was renamed to '{_LEGACY_PRESET_ALIASES[name]}'; this task declares neither.")
lines.append("Available presets by config path:")
lines.extend(
f" {path}: {', '.join(name for name in fields if name != 'default')}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Implementation — Error lists paths without selectable names

A path whose only field is default renders as env.x: with an empty list, unlike the previous message which omitted such paths. Skip paths that contribute no selectable names.

)
description.append(f" {syntax:23} {meaning}" + (". Available:" if variants is not None else ""))
if variants is not None:
description.extend(f" - {name}" for name in variants[target])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Style Consistency — Bullet indent duplicates column width

The 30-space literal must track the {syntax:23} field plus the prefix and gap on line 122; changing either silently misaligns help output. Derive the indent from the same width value.

if isinstance(cfg, self.base_classes):
return True
return self is PresetTarget.PHYSICS and isinstance(cfg, SimulationCfg) and isinstance(cfg.physics, PhysicsCfg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Public alias API removed without deprecation

PresetTarget.all_legacy_aliases() and each member's legacy_aliases were public, documented members; deleting them breaks callers outright. Keep forwarding accessors over the new table with a DeprecationWarning until the announced removal.

from isaaclab_tasks.utils.preset_cli import setup_preset_cli

# Keep parsing and formatting in argparse, without private helper classes in the CLI module.
assert not any(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Test Quality — Assertion checks module structure

This asserts the module defines no classes, so it fails under any behavior-preserving refactor while catching no CLI regression. Remove it; the help-output assertions already own this contract.

@ooctipus

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 12, 2026
@ooctipus

Copy link
Copy Markdown
Collaborator Author

run-ci

@ooctipus
ooctipus force-pushed the refactor/pr6bi-task-preset-cleanup branch from 799aa92 to 80aa432 Compare October 12, 2026 21:43
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 12, 2026
level = 1
frame = sys._getframe(1)
while frame is not None and frame.f_globals.get("__name__", "").startswith(__package__):
while frame is not None and frame.f_globals.get("__name__", "").startswith("isaaclab_tasks.utils"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a very interesting hack, is there a better way to write it?

@ooctipus
ooctipus merged commit 4c8228f into isaac-sim:develop Oct 13, 2026
61 checks passed
@ooctipus
ooctipus deleted the refactor/pr6bi-task-preset-cleanup branch October 13, 2026 05:40
AntoineRichard added a commit to AntoineRichard/IsaacLab that referenced this pull request Oct 13, 2026
…uncher

Develop moved under this branch: isaac-sim#8476 folded preset_cli and preset_target into
isaaclab_tasks.utils.hydra, list_envs grew a public registry walk, and the
launcher validators the tools/ module imported now take a dict, so every
resolved combination was being dropped as an "API failure".

Resolution now lives beside enumerate_task_presets as resolve_task_runs, which
passes tokens through resolve_task_config(overrides=) instead of swapping
sys.argv, and checks each combination with a new public
isaaclab.app.validate_launch -- the scan and validation launch_simulation starts
with, which now calls it too. Only ValueError counts as a rejection; any other
error propagates. Across the registry that is 140 tasks and 1032 distinct runs
in 133s, with no other exception raised and every default run accepted.

``isaaclab list_envs --resolve`` is the in-tree consumer. The tools/ module, its
copies of the training-task filter and RL-library order, and its stubbed tests
are removed; environ_docs is left as develop has it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation infrastructure isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants