Skip to content

Cherry-pick: Support custom modules in env spec through Arena plugins (#1804) - #1828

Open
xyao-nv wants to merge 2 commits into
release/0.4.0from
xyao/cp/1804/release/0.4.0
Open

xyao-nv wants to merge 2 commits into
release/0.4.0from
xyao/cp/1804/release/0.4.0

Conversation

@xyao-nv

@xyao-nv xyao-nv commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Cherry-pick #1804 into release/0.4.0, so an environment YAML on the release branch can name robots, objects, tasks, and relations that an installed isaaclab_arena.plugins package registers (https://nvbugspro.nvidia.com/bug/7173054).

#1804 is still open. Its net change is picked as one commit, because its first commits added python_modules, which later commits replaced with plugins. Later review changes to #1804 will be picked here too.

The second commit is release-only. Release still has basic.py and advanced.py instead of #1782's franka_table_environment.py, so this branch leaves out the decorated example and franka_table.yaml, and:

  • Keeps the release tasks page's --external_environment_class_path commands and drops the main paragraphs that run franka_table by name.
  • Says how to make a custom task usable from YAML, without pointing to the YAML example that release lacks.
  • Uses advanced.py as the plugin in the tests, which registers franka_ik_soft.

…#1804)

Net change of #1804 at 8df62af, applied as one commit because its
first commits added python_modules, which later commits replaced with
Arena plugins.

Left out: isaaclab_arena_examples/external_environments/
franka_table_environment.py and franka_table.yaml, which build on #1782
and don't exist on release/0.4.0. Conflicts resolved toward release's
content, where release lacks the tags docs (#1775) and the
register_environment import (#1729), and where release's tasks page
still runs advanced.py with --external_environment_class_path.

(cherry picked from commits 16b9ca5..8df62af)

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
Release has advanced.py instead of #1782's franka_table_environment.py,
and its external environments are ExampleEnvironmentBase subclasses
loaded with --external_environment_class_path.

- Keep the flag commands and drop the paragraphs that run franka_table
  by name through a plugin.
- Say how to make a custom task usable from an environment YAML, without
  pointing to the YAML example that release lacks.
- Name my_environment_with_task in the plugin entry-point example, as the
  release page does.
- Use advanced.py, which registers franka_ik_soft, as the test plugin.

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The shared registration path now reaches Arena’s graph and environment workflows when installed plugins are present.

The PR appears safe to merge, with a non-blocking gap in plugin test coverage.

Findings

  1. P2 Plugin tests cover only robots ▶

Summary

Adds automatic loading of installed isaaclab_arena.plugins modules after built-in components.

  • Arena loads installed plugin modules so their registered components are available to lookups.

xyao-nv explicitly describes omitting the decorated environment example and franka_table.yaml as intentional for this release branch, which retains basic.py and advanced.py.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Asset lookup or environment registration] --> B[Load built-in components]
  B --> C[Find installed plugin entry points]
  C --> D[Import plugin modules in name order]
  D --> E[Run registration decorators]
  E --> F[Resolve graph components or select environment]
Loading

Reviews (1) · Last reviewed commit: "Adapt the Arena plugin docs and tests to..." · Reviewed by Greptile

Comment on lines +705 to +714
def test_a_spec_names_components_that_an_installed_plugin_registers(tmp_path):
_install_plugin_package(tmp_path, _EXAMPLE_PLUGIN_MODULE)
data = _minimal_env_graph_data()
data["embodiment"]["registry_name"] = "franka_ik_soft"
spec_path = tmp_path / "env_graph.yaml"
spec_path.write_text(yaml.safe_dump(data), encoding="utf-8")

result = _load_spec_in_a_fresh_process(spec_path, extra_python_path=tmp_path)

assert result.returncode == 0, f"loading the spec failed:\n{result.stderr}"

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.

P2 Plugin tests cover only robots

Both new success tests check only franka_ik_soft. The fixture registers no task, relation, or environment, and _REPLAY_SCRIPT never builds the graph. These tests can pass even if the other advertised plugin uses fail. Add a small plugin fixture that registers those components, build its graph, and check that its environment can be selected.

"""
import isaaclab_arena_environments # noqa: F401

ensure_assets_registered()

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.

🟡 A plugin environment breaks the argparse runners on this branch

This call puts plugin environments in EnvironmentRegistry before add_example_environments_cli_args builds a subparser for every registered environment.

  • Why it fails: On release/0.4.0, add_environment_cli_args still goes through _get_legacy_argparse_cfg_type, which asserts that the factory has the private _legacy_argparse_cfg_type attribute. A plugin with a typed @register_environment factory won't have it. The new docs suggest registering environments through plugins ("an Experiment cannot select an environment that your package registers").
  • What breaks: policy_runner.py and environment_runner.py then fail for every environment, built-ins included. So do graph-YAML Experiment runs, which build that parser in build_arena_builder_from_legacy_graph. Only --env_spec CLI runs avoid it.

Main fixed this in #1716, which reads the config type from EnvironmentRegistry and only removes one line from each factory. Could we pick #1716 into this branch first or alongside this PR?

assert entry_point.attr is None, "an Arena plugin entry point must name a module, not a module attribute"
entry_point.load()
except Exception as exc:
exc.add_note(f"Raised while loading Arena plugin '{entry_point.name} = {entry_point.value}'.")

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.

🟡 The plugin name is lost when spec validation hits the failure

If the first registry lookup happens inside ArenaEnvGraphSpec validation, pydantic turns an AssertionError or ValueError from the plugin into a ValidationError and drops this note. That happens, for example, when record_placement_layouts.py:124 calls ArenaEnvGraphSpec.from_yaml.

  • Affected failures: the entry_point.attr check above, and every assert in the register_* decorators.
  • What the user sees: Assertion failed, an Arena plugin entry point must name a module…, blamed on a valid name like franka_ik, once per validated field, with no plugin named.

I reproduced this with pydantic 2.14: the error has no note and no __cause__. Raising a new error that names the plugin isn't converted by pydantic, and it keeps the original error as the cause:

        except Exception as exc:
            raise RuntimeError(f"Failed to load Arena plugin '{entry_point.name} = {entry_point.value}'.") from exc
  • Test: test_a_plugin_that_fails_to_load_is_named_in_the_error raises RuntimeError, which pydantic lets through, so it misses this case. Making the broken plugin fail an assert instead would cover it.
  • Docs: The line "an error whose note names the plugin" would then become "an error that names the plugin".

The same code is in #1804.

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This cherry-picks #1804 onto release/0.4.0. Installed packages that declare isaaclab_arena.plugins entry points are now imported on the first registry lookup, so environment YAML and Experiments can name the robots, objects, tasks, and relations those packages register. The core code is the same as #1804. Only the docs and the tests built on advanced.py are specific to the release branch.

Two things need fixing before this ships in a release:

Findings

🟡 Warning: isaaclab_arena_environments/cli.py:35

  • Problem: A plugin that registers a typed @register_environment factory makes add_example_environments_cli_args assert on the private _legacy_argparse_cfg_type attribute, which only built-in environments set.
  • Impact: policy_runner.py and environment_runner.py fail for every environment, built-in ones included. Graph-YAML Experiment runs fail too, because they go through build_arena_builder_from_legacy_graph. Only --env_spec CLI runs avoid it.
  • Fix: Main fixed this in Read argparse environment configs from the registry #1716, which is small. Could we pick it into this branch first or alongside this PR?

🟡 Warning: isaaclab_arena/assets/registries.py:428

  • Problem: When the first registry lookup happens inside ArenaEnvGraphSpec validation, pydantic turns a plugin's AssertionError/ValueError into a ValidationError and drops the note. Spec loading in record_placement_layouts.py and the review GUI are examples.
  • Impact: The error blames a valid name, repeats once per validated field, and never names the plugin. Affected failures include the entry_point.attr check and every assert in the register_* decorators.
  • Fix: Raise a RuntimeError that names the plugin, chained with from exc. The same code is in Support custom modules in env spec through Arena plugins #1804, so it may be easiest to fix there and pick it.

🔵 Improvement (already broken before this PR): docs/pages/arena_in_your_repo/external_tasks_and_embodiments.rst:48

  • The "complete example" link points to blob/main/.../advanced.py, which main no longer has since Merge the external environment examples into one #1782.
  • The new paragraph just below it builds on that example, so pointing the link at release/0.4.0 would help readers of the release docs.

Test Coverage and CI Cost

  • No test of a plugin environment: On this branch, test_environment_registration_loads_installed_plugins only checks the asset franka_ik_soft, because release's advanced.py registers no environment. So no test runs a plugin environment through get_isaaclab_arena_environments_cli_parser(), which is how the first finding slips through. After picking Read argparse environment configs from the registry #1716, the same fresh-process script could register a small typed environment from a module in tmp_path and build the parser, without starting another process.
  • Failure test misses the dropped-note case: test_a_plugin_that_fails_to_load_is_named_in_the_error raises RuntimeError, which pydantic lets through, so it doesn't cover the second finding. See the inline comment.
  • CI not run yet: The test jobs hadn't run when I reviewed (the Arena image build was still in progress), and I didn't run the suite myself.

Verdict

Minor fixes needed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant