Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Selected the registered default RL library of experimental tasks, such as ``Isaac-Cartpole-MDP2``, when
``--rl_library`` is not given.
4 changes: 4 additions & 0 deletions source/isaaclab_rl/isaaclab_rl/entrypoints/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import annotations

import argparse
import contextlib
import importlib
import sys
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -159,6 +160,9 @@ def _resolve_default_library(argv: list[str], backends: dict[str, str]) -> str |
# task registration is deferred until a task name asks for it
import isaaclab_tasks # noqa: F401

with contextlib.suppress(ImportError):

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 — Do not hide registration failures

Suppressing every ImportError also hides failures inside an installed experimental package. Its tasks then appear unregistered and dispatch reports a missing backend. Ignore only absence of the top-level package.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This matches the import in all ten train and play backends (for example train_rsl_rl.py), which guard the optional package with the same contextlib.suppress(ImportError), so dispatch and the selected backend see the same registered tasks. Changing how the optional package is detected would be a separate change across all eleven sites, so this stays as is.

import isaaclab_tasks_experimental # noqa: F401

try:
default_library = gym.spec(args.task.split(":")[-1]).kwargs.get("default_agent")
except gym.error.Error:
Expand Down
12 changes: 12 additions & 0 deletions source/isaaclab_rl/test/test_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,18 @@ def test_dispatch_uses_task_registered_default_backend(monkeypatch) -> None:
assert received == {"module_name": "isaaclab_rl.entrypoints.backends.train_rsl_rl", "argv": ["--task", task_name]}


def test_dispatch_finds_the_default_backend_of_experimental_tasks() -> None:

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 — Mark the regression kitless

This regression needs no Isaac Sim runtime, but its file has no kitless marker, so kitless CI selection misses it. Mark the test pytest.mark.kitless.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The only CI job that selects tests by the kitless marker (test-multi-gpu-pytest.yaml) runs test_multi_gpu_training_smoke.py alone, and none of the 38 tests in this file carries the marker, so marking this one test changes no CI selection. This stays as is.

"""Tasks of the optional experimental task package also select their registered default backend."""
pytest.importorskip("isaaclab_tasks_experimental")
# A fresh process, so that no earlier import has registered the experimental tasks.
code = (
"from isaaclab_rl.entrypoints.dispatch import _resolve_default_library\n"
"print(_resolve_default_library(['--task', 'Isaac-Cartpole-MDP2'], {'rsl_rl': ''}))"
)
result = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, check=True)
assert result.stdout.strip().splitlines()[-1] == "rsl_rl"


def test_dispatch_fuses_option_like_kit_args(monkeypatch) -> None:
"""Space-separated option-like Kit arguments are fused before backend parsing."""
received: dict[str, object] = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def test_mdp2_environment_resets_and_steps(task_name):
env.close()


@pytest.mark.parametrize("disabled", [None, "action_rate"])
@pytest.mark.parametrize("disabled", [None, "action_rate", "joint_vel"])
def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(disabled):
"""The Reach curriculum keeps its reward weights until the first reset after its step threshold, then sets them
in every world, from a captured step. It leaves out a reward that the task disables."""
in every world, from a captured step. It leaves out a reward that the task disables, and every other weight as

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 — State the weight invariant plainly

“And every other weight as it is” obscures the new whole-tensor assertion. Say that non-target reward weights remain unchanged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reworded: the docstring now says the test skips a disabled reward and leaves every other weight unchanged. (303938e)

it is."""
task_name = "Isaac-Reach-Franka-MDP2"
env_cfg, _ = resolve_task_config(task_name, None, overrides=["physics=newton_mjwarp"])
env_cfg.sim.device = "cuda:0"
Expand All @@ -73,10 +74,10 @@ def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(dis
indices = {op.use: op.index for op in unwrapped.mdp.ops[mdp2.Phase.REWARDS]}
names = [name for name in ("action_rate", "joint_vel") if name != disabled]
assert f"rewards.{disabled}" not in indices
columns = [indices[f"rewards.{name}"] for name in names]
weights = unwrapped.state.reward_weights.torch
initial = weights[:, columns].clone()
final = torch.tensor([getattr(env_cfg, f"curriculum_{name}") for name in names], device=unwrapped.device)
initial, final = weights.clone(), weights.clone()
for name in names:
final[:, indices[f"rewards.{name}"]] = getattr(env_cfg, f"curriculum_{name}")

env.reset(seed=0)
actions = torch.zeros(env.action_space.shape, device=unwrapped.device)
Expand All @@ -87,8 +88,8 @@ def test_reach_curriculum_sets_reward_weights_at_first_reset_after_threshold(dis
early_reset |= resetting and step <= env_cfg.curriculum_after_steps
if applied_at is None and resetting and step > env_cfg.curriculum_after_steps:
applied_at = step
expected = final.expand_as(initial) if applied_at is not None else initial
torch.testing.assert_close(weights[:, columns], expected, msg=f"weights after step {step}")
expected = final if applied_at is not None else initial
torch.testing.assert_close(weights, expected, msg=f"weights after step {step}")
assert early_reset and applied_at is not None
# Steps after the first replay the captured graphs, so the curriculum ran inside one.
assert applied_at > 1 and unwrapped.num_graphs > 0
Expand Down
Loading