Skip to content

Support custom modules in env spec through Arena plugins - #1804

Open
xyao-nv wants to merge 9 commits into
mainfrom
xyao/feature/env_graph_python_modules
Open

xyao-nv wants to merge 9 commits into
mainfrom
xyao/feature/env_graph_python_modules

Conversation

@xyao-nv

@xyao-nv xyao-nv commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Let an installed package register its own robots, objects, tasks, relations, policies, and environments with Arena through isaaclab_arena.plugins entry points, so environment YAML and Experiments can name them.

Why this change?

A YAML environment that names a custom robot or object fails with Unknown asset registry_name, because neither runner can import the module that registers it. Reported by VDR https://nvbugspro.nvidia.com/bug/7173054

An Experiment also cannot select an environment that an external package registers. External repositories work around both by wrapping Arena's runner and patching its internals to import their modules first. However, users tend to launch eval exps with our experiment_runner.py, instead of their own runner py.

What changes?

  • ensure_assets_registered() loads every installed isaaclab_arena.plugins entry point after Arena's own components, in name order. An entry point names a module, which is imported; an entry point that names a module attribute is rejected. A plugin that fails to load raises with a note naming it.
  • ensure_environments_registered() also loads plugins, so Experiments can select environments that a plugin registers.
  • The errors for an unregistered asset, task, or relation name in an environment graph spec suggest checking the spelling or installing the package as an Arena plugin.
  • The external environment example registers its task and environment, so a package that declares it as a plugin runs franka_table by name. franka_table.yaml shows the same environment as an environment YAML.
  • The "Arena in your repository" guide documents plugins, and the concept pages link to it.

Usage example

Your repository keeps Arena as an unmodified submodule:

my_repo/
├── submodules/IsaacLab-Arena/      ← unmodified
├── pyproject.toml                  ← declares the plugins
├── my_project/
│   ├── __init__.py
│   ├── robots.py                   ← custom robot
│   ├── objects.py                  ← custom object
│   ├── tasks.py                    ← custom task
│   └── envs.py                     ← custom Python environment
└── envs/widget_lift.yaml           ← environment: pure data

pyproject.toml declares the modules that register the custom components:

[project]
name = "my-project"
version = "0.1.0"

[project.entry-points."isaaclab_arena.plugins"]
my_project_robots = "my_project.robots"
my_project_objects = "my_project.objects"
my_project_tasks = "my_project.tasks"
my_project_envs = "my_project.envs"

After installing the package with install_package.sh, the environment YAML names them like built-in components:

embodiment:
  id: robot
  registry_name: my_soft_franka        # my_project.robots
objects:
- id: widget
  registry_name: my_widget             # my_project.objects
task:
  composition: atomic
  description: Lift the widget above 30 cm.
  subtasks:
  - kind: LiftAboveHeightTask          # my_project.tasks
    params:
      lift_object: widget
      height_m: 0.3

An Experiment selects the environment by its path, and Arena's experiment_runner.py runs it unchanged:

# experiments/widget_lift_experiment.yaml
shared:
  policy:
    type: zero_action
  rollout_limit:
    num_episodes: 2

runs:
  widget_lift:
    environment:
      type: envs/widget_lift.yaml        # relative to the working directory
cd my_repo
python submodules/IsaacLab-Arena/isaaclab_arena/evaluation/experiment_runner.py \
  --experiment_config experiments/widget_lift_experiment.yaml

A Python environment in the same package works the same way. my_project/envs.py registers a factory that uses the custom components:

# Imports omitted.
@dataclass
class WidgetTableEnvironmentCfg(ArenaEnvironmentCfg):
    object: str = "my_widget"


@register_environment
class WidgetTableEnvironment(ArenaEnvironmentFactory[WidgetTableEnvironmentCfg]):
    name: str = "widget_table"

    def build(self, cfg: WidgetTableEnvironmentCfg) -> IsaacLabArenaEnvironment:
        background = self.asset_registry.get_asset_by_name("maple_table_robolab")()
        widget = self.asset_registry.get_asset_by_name(cfg.object)()  # my_project.objects
        embodiment = self.asset_registry.get_asset_by_name("my_soft_franka")(  # my_project.robots
            enable_cameras=cfg.enable_cameras
        )
        table = ObjectReference(
            name="table", prim_path="{ENV_REGEX_NS}/maple_table_robolab/table", parent_asset=background
        )
        table.add_relation(IsAnchor())
        widget.add_relation(On(table))
        return IsaacLabArenaEnvironment(
            name=self.name,
            embodiment=embodiment,
            scene=Scene(assets=[background, table, widget]),
            task=LiftAboveHeightTask(lift_object=widget, height_m=0.3),  # my_project.tasks
        )

An Experiment selects it by its registered name. A built-in Python environment also accepts the custom components by name:

runs:
  widget_table:
    environment:
      type: widget_table
  maple_table_with_my_parts:
    environment:
      type: pick_and_place_maple_table
      embodiment: my_soft_franka
      pick_up_object: my_widget

On the command line, widget_table is an environment subcommand like the built-in ones:

python submodules/IsaacLab-Arena/isaaclab_arena/scripts/environment_runner.py widget_table --object my_widget

Before this change, the same YAML failed with Unknown asset registry_name 'my_soft_franka' unless a custom launcher imported my_project first.

Validation

  • Installed the example package into a temporary directory. The full YAML validates with the custom robot, object, and task resolved. Without the package, it fails with the three unknown names and the plugin hint.
  • With the package installed, load_arena_experiment_from_config_file loads the Experiment above, and its Run selects envs/widget_lift.yaml.
  • With the package installed, the Experiment above loads widget_table as WidgetTableEnvironmentCfg and pick_and_place_maple_table with my_soft_franka and my_widget. environment_runner.py widget_table --object my_widget parses.
  • With the external environment example declared as a plugin, one Experiment ran franka_table by name and franka_table.yaml by path, each with object: tomato_soup_can and a zero-action policy. Both episodes succeeded at step 50.

A YAML environment graph that named a robot or object registered in an
external package failed with "Unknown asset registry_name", because
neither runner had a way to import the registering module.

Add a python_modules list to ArenaEnvGraphSpec. A before-validator
imports the listed modules, so their @register_* decorators run before
registry names are checked, for every loader of the spec. The field is
hidden from the JSON schema, and spec inference drops it from model
output, so a generated spec cannot import code. The unknown registry
name error now points to python_modules.

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

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds python_modules to ArenaEnvGraphSpec so external packages can register assets, tasks, and relations before graph checks run.

  • Environment graphs import listed modules before checking registered names.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Authored graph] --> B[Import listed modules]
  B --> C[Check graph and registered names]
  D[Generated response] --> E[Remove python_modules]
  E --> C
  C --> F[Validated graph]
Loading

Reviews (1) · Last reviewed commit: "Import an environment graph's python_mod..." · Reviewed by Greptile

@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR adds a python_modules list to ArenaEnvGraphSpec. A before-validator imports the listed modules, so a YAML spec can name robots, objects, tasks, and relations that an external package registers. SpecInference removes the key from generated output. The approach is sound, and the notes below are small.

Findings

🔵 Improvement: docs/pages/concepts/environment/environment_definition.rst:288: python_modules can be defined in only one external_yaml file. If a scene file and a task file each list a module, loading fails with Conflicting env graph spec value at 'python_modules'. I confirmed this by running load_env_graph_spec_dict on two such files. The fix is to merge the list across includes or to document the limit.

🔵 Improvement: isaaclab_arena/environment_spec/arena_env_graph_types.py:52: only the unknown-asset error points to python_modules. The unknown task kind and unknown relation kind errors don't, even though the field description says externally registered tasks and relations are covered.

Test Coverage and CI Cost

🔵 test_a_spec_naming_unimported_external_assets_points_to_python_modules starts a new Python process for a check that gives the same result inside the pytest process. That process imports torch, Isaac Lab, and every Arena embodiment and task. An in-process from_dict check, or a stricter match in the existing "unknown registry name" case, keeps the coverage without the extra process. The positive test does need its own process.

CI status: when this review ran, "Run tests (native uv, source)" had been skipped and pre-commit was still queued, so I couldn't see test results. I didn't run the tests myself.

Verdict

Minor fixes needed

- Add the python_modules hint as a note in from_dict only, so the LLM's
  critic retry no longer gets advice it cannot follow. Unknown task and
  relation kinds get the same note.
- Leave assets registered by a spec's python_modules out of the agent's
  asset catalogue, so the review GUI cannot save a spec that loads
  nowhere else.
- Register Arena's assets before importing python_modules, name the
  entry in import errors, and reject relative module names.
- Keep python_modules in the public JSON schema and remove it only from
  SpecInference's strict schema.
- Join python_modules lists across external_yaml includes.
- Document importability, trust, and process lifetime of the imports.

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
…elper

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
@xyao-nv xyao-nv changed the title Import an environment graph's python_modules before validating it Support importing custom modules in env spec yaml Dec 2, 2026
An environment YAML stays pure data. Instead of listing modules to
import in each YAML, a package declares the modules that register its
components as entry points in the isaaclab_arena.plugins group.

- ensure_assets_registered() loads every installed plugin after Arena's
  own components, so a plugin cannot take a built-in registry name. An
  entry point names a module to import or a module:function to call.
- ensure_environments_registered() loads plugins too, so Experiments
  can select environments that a plugin registers.
- A plugin that fails to load raises with a note naming it.
- ArenaEnvGraphSpec.from_dict points unknown asset, task, and relation
  names to Arena plugins.
- Remove python_modules and the code it needed: the spec inference
  schema edit, the agent catalogue exclusion, and the include merge rule.
- Document plugins in the Arena in your repository guide.

Signed-off-by: Xinjie Yao <xyao@nvidia.com>
@xyao-nv xyao-nv changed the title Support importing custom modules in env spec yaml Support custom modules in env spec yaml through Arena plugins Dec 2, 2026
Signed-off-by: Xinjie Yao <xyao@nvidia.com>
@xyao-nv xyao-nv changed the title Support custom modules in env spec yaml through Arena plugins Support custom modules in env spec through Arena plugins Dec 2, 2026
Signed-off-by: Xinjie Yao <xyao@nvidia.com>
Signed-off-by: Xinjie Yao <xyao@nvidia.com>

@qianl-nv qianl-nv left a comment

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.

Thanks for address this long overdue issue.

Added a few comments.

Comment thread isaaclab_arena/assets/registries.py Resolved
…h_python_modules

# Conflicts:
#	docs/pages/arena_in_your_repo/external_tasks_and_embodiments.rst
- Accept only modules as isaaclab_arena.plugins entry points.
- Append a plugin hint to the unregistered asset, task, and relation
  errors, and drop the from_dict note that matched error text.
- Register the external example's task and environment, so a package
  that declares the example as a plugin runs franka_table by name. The
  task accepts task_description, which an environment YAML passes.
- Add franka_table.yaml, the example as an environment YAML. The plugin
  tests declare the example module as the plugin and load that YAML.
- Docs: move the plugin section before "Putting It All Together",
  install with install_package.sh, run the example and its YAML with
  experiment_runner.py, and note in "Choosing a runner" that plugin
  environments run in the Experiment Runner.

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

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.

3 participants