Skip to content

Share one helper to import a class from its path - #1698

Merged
cvolkcvolk merged 2 commits into
mainfrom
cvolk/refactor/import-class-from-path
Nov 18, 2026
Merged

cvolkcvolk merged 2 commits into
mainfrom
cvolk/refactor/import-class-from-path

Conversation

@cvolkcvolk

@cvolkcvolk cvolkcvolk commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Add import_class_from_path and use it wherever Arena imports a class named by a path: the Experiment policy lookup, the GR00T embodiment adapter lookup, and --external_environment_class_path.

Builds on #1461, which moves the policy lookup into arena_experiment_config_loader.py.

Why this change?

Three places split a class path, imported the module, and read the class with their own code:

  • resolve_policy_type_from_name_or_class_path in arena_experiment_config_loader.py, for policy.type in Experiments.
  • import_gr00t_embodiment_adapter_class in gr00t_embodiment_adapter.py, for gr00t_embodiment_adapter.
  • parse_and_return_external_environment_from_string in isaaclab_arena_environments/cli.py, for --external_environment_class_path module_path:ClassName.

Alex suggested a shared helper in the review of #1461.

What changes?

  • isaaclab_arena/utils/class_path.py adds import_class_from_path(class_path, separator="."). It asserts that the path contains the separator, that the module has the attribute, and that the attribute is a class, then returns the class.
  • The three places above call it. Each keeps its own checks on top, such as the GR00T adapter's built-in names and its Gr00tEmbodimentAdapter subclass check.
  • --external_environment_class_path keeps the module_path:ClassName form by passing separator=":". Errors there are now assertions with the expected form, and a missing module raises the ModuleNotFoundError from the import instead of a ValueError.

Isaac Lab's string_to_callable also splits a path, but it accepts any callable, evaluates lambda strings, and its error message always names the module:attribute_name form.

Hydra's get_class, used by _validated_target_class in isaaclab_arena/hydra/config_override.py, finds the same classes but gives less useful errors for paths people type by hand. It reports a misspelled class name as a missing module, and it logs every failure at ERROR before raising it.

Validation

Locally in the Arena Docker image built from main:

  • New test_class_path.py (6 passed).
  • test_arena_experiment_config_loader.py (26 passed), including the policy class path test.
  • test_gr00t_remote_closedloop_policy.py without subprocess tests (22 passed), including the adapter error messages.
  • test_external_environment.py (3 passed): the Isaac Lab callback and two policy_runner.py runs with --external_environment_class_path.
  • pre-commit passes.

@cvolkcvolk
cvolkcvolk marked this pull request as ready for review November 18, 2026 09:59
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

This refactor shares one class-import helper across policy lookup, GR00T adapters, and external environments.

  • Experiment policy paths now resolve only to classes.
  • GR00T adapter paths now use the shared class importer.
  • External environment paths now use the shared importer with colons.

No actionable issues found.

Reviews (1) · Last reviewed commit: "Share one helper to import a class from ..." · Reviewed by Greptile

Comment thread isaaclab_arena/utils/class_path.py Resolved
Comment thread isaaclab_arena/utils/class_path.py Resolved
@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR adds import_class_from_path in isaaclab_arena/utils/class_path.py and uses it for three lookups: the Experiment policy, the GR00T embodiment adapter, and --external_environment_class_path. The refactor is small, and each caller keeps its own checks and error messages. My main question is whether Arena needs a new helper at all. Hydra's get_class already does this job in _validated_target_class, which answers the question Alex raised on #1461.

CI ran no tests on this head commit: "Run tests" and "Run tests with subprocess" were skipped, and pre-commit was still queued. The only test results are the local runs listed in the description.

Findings

🔵 Improvement: isaaclab_arena/utils/class_path.py:9: Arena already imports classes by dotted path with Hydra's get_class in isaaclab_arena/hydra/config_override.py:279, and get_class rejects non-classes. Could the three callers use it, so this module and its tests aren't needed?
🔵 Improvement: isaaclab_arena/utils/class_path.py:16: The Returns section only repeats the summary line, and AGENTS.md says to leave it out in that case.

Verdict

Minor fixes needed

@alexmillane alexmillane 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 cleaning that up!

Three places split a class path, imported the module, and looked up
the class: the policy lookup for Experiments, the GR00T embodiment
adapter lookup, and --external_environment_class_path. Add
import_class_from_path in isaaclab_arena/utils/class_path.py and use it
in all three. It asserts that the path contains the separator, that
the module has the attribute, and that the attribute is a class.

The external environment flag keeps its module_path:ClassName form
through the separator argument. A missing module now raises the
ModuleNotFoundError from the import instead of a ValueError.

Signed-off-by: Clemens Volk <[email protected]>
@cvolkcvolk
cvolkcvolk changed the base branch from cvolk/refactor/move-shared-code-out-of-policy-runner to main November 18, 2026 14:07
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/import-class-from-path branch from 84829bf to 961a7e1 Compare November 18, 2026 14:07
@cvolkcvolk
cvolkcvolk enabled auto-merge (squash) November 18, 2026 14:33
@cvolkcvolk
cvolkcvolk merged commit 9e14495 into main Nov 18, 2026
10 checks passed
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.

2 participants