Repository navigation
Move shared rollout and policy lookup out of policy_runner - #1461
Conversation
[Low impact] The PR appears safe to merge; no actionable issues were found. SummaryMoves shared rollout and policy lookup code out of
No actionable issues found. Tests were not run during this review. Reviews (2) · Last reviewed commit: "Move shared rollout and policy lookup ou..." · Reviewed by Greptile |
🤖 Isaac Lab-Arena Review BotSummaryThis PR moves FindingsNo new findings. Test Coverage and CI CostCI for the current head was still running during this review. Pre-commit passed, but "Run tests", "Run tests with subprocess", "Build the docs" and "GR00T closed-loop E2E" were still queued or in progress. I didn't run any tests. VerdictShip it |
c509e09 to
3ebba19
Compare
|
/review |
|
The PR changed while this review was running. Please run |
run_execution.py imported rollout_policy from policy_runner.py, and legacy_eval_config.py imported get_policy_cls from it, so the Experiment Runner depended on the module we plan to deprecate. Move rollout_policy unchanged into isaaclab_arena/evaluation/rollout.py. Replace get_policy_cls with resolve_policy_type_from_name_or_class_path in arena_experiment_config_loader.py, which the typed YAML policy resolver already implemented. The YAML loader, legacy JSON Experiments, and policy_runner.py now share that one lookup. Signed-off-by: Clemens Volk <[email protected]>
The summary of resolve_policy_type_from_name_or_class_path already says it returns the policy class. Signed-off-by: Clemens Volk <[email protected]>
afc9e00 to
1e774d1
Compare
alexmillane
left a comment
There was a problem hiding this comment.
LGTM. Some tiny (optional) nits
IsaacLabArenaManagerBasedRLEnvCfg declares metrics, and the Mimic config subclasses it, so every environment rollout_policy receives has the attribute. Check it for None without hasattr. Signed-off-by: Clemens Volk <[email protected]>
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. --------- Signed-off-by: Clemens Volk <[email protected]>
Move
rollout_policyinto a newisaaclab_arena/evaluation/rollout.py, and replaceget_policy_clswithresolve_policy_type_from_name_or_class_pathinarena_experiment_config_loader.py. After this, nothing thatexperiment_runner.pyuses importspolicy_runner.py.Why this change?
We plan to deprecate
policy_runner.pyin favor ofexperiment_runner.py. Two modules thatexperiment_runner.pyuses still imported code from it:run_execution.pyimportedrollout_policy.legacy_eval_config.pyimportedget_policy_clsto resolve a legacy JSON Experiment's policy.policy_runner.pycould not be deleted without breakingexperiment_runner.py.What changes?
rollout_policymoves intoisaaclab_arena/evaluation/rollout.py.run_execution.pyandpolicy_runner.pyimport it from there. The only change to it: it readsenv.unwrapped.cfg.metricswithouthasattr, becauseIsaacLabArenaManagerBasedRLEnvCfgalways declaresmetrics.get_policy_clsis replaced byresolve_policy_type_from_name_or_class_pathinarena_experiment_config_loader.py. It returns the policy class for a registered name or a dotted class path._resolve_policy_cfg_type_from_name_or_class_path, which resolvespolicy.typein typed YAML Experiments, already had the same logic and now callsresolve_policy_type_from_name_or_class_path.legacy_eval_config.pyandpolicy_runner.pyalso callresolve_policy_type_from_name_or_class_pathin place ofget_policy_cls.resolve_policy_type_from_name_or_class_pathdoes not print the "Policy ... is not registered. Dynamically importing from path" message thatget_policy_clsprinted.test_rollout_policy.pytargets the new module.Validation
mainat02a9b1e413, after Deprecate multi-GPU evaluation with torchrun #1459. CI passed on the earlier headafc9e006cd.hasattrchecks:test_rollout_policy.py,test_run_execution.py, andtest_experiment_runner.py::test_experiment_runner_from_typed_yamlpass.main:test_rollout_policy.py(2 passed),test_run_execution.py(23),test_arena_experiment_config_loader.py(26),test_policy_cfgs.py(13),test_legacy_eval_config.py(6), and thetest_policy_runner.pydeprecation test.test_policy_runner.py::test_zero_action_policy,test_experiment_runner.py::test_experiment_runner_from_typed_yaml, andtest_experiment_runner.py::test_experiment_runner_two_jobs_zero_action(legacy JSON) all pass.pre-commitpasses.