Add typed configurations to Arena policies - #862
Conversation
Greptile SummaryThis PR decouples Arena policy construction from argparse by introducing a
Confidence Score: 4/5The change is a well-scoped refactor with a clear compatibility bridge; no existing policy construction paths are broken. Two spots use assert for runtime validation of user-supplied config data and API-misuse guards — one in the scheduler branch of Gr00tRemoteClosedloopPolicy.init and one in register_policy. Both are silently stripped by Python's optimizer, so an invalid scheduler string from a JSON job config or an incorrect decorator call could produce a confusing downstream failure rather than a clear error message. Everything else in the refactor looks correct and well-tested. isaaclab_arena/assets/register.py (assert-based API guards) and isaaclab_arena_gr00t/policy/gr00t_remote_closedloop_policy.py (assert-based scheduler validation). Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant JSON as Job JSON Config
participant ER as eval_runner
participant PR as PolicyRegistry
participant Cfg as PolicyCfg (typed)
participant Policy as PolicyBase[T]
JSON->>ER: policy_config_dict
ER->>PR: get_policy_cfg_type(policy_cls)
alt Typed path (preferred)
PR-->>ER: PolicyCfgType
ER->>Cfg: "PolicyCfgType(**policy_config_dict)"
Cfg-->>ER: cfg instance
ER->>Policy: policy_cls(cfg)
else Deprecated argparse fallback
PR-->>ER: None
ER->>ER: DeprecationWarning
ER->>Policy: policy_cls.from_args(parsed_args)
end
Policy-->>ER: policy instance
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant JSON as Job JSON Config
participant ER as eval_runner
participant PR as PolicyRegistry
participant Cfg as PolicyCfg (typed)
participant Policy as PolicyBase[T]
JSON->>ER: policy_config_dict
ER->>PR: get_policy_cfg_type(policy_cls)
alt Typed path (preferred)
PR-->>ER: PolicyCfgType
ER->>Cfg: "PolicyCfgType(**policy_config_dict)"
Cfg-->>ER: cfg instance
ER->>Policy: policy_cls(cfg)
else Deprecated argparse fallback
PR-->>ER: None
ER->>ER: DeprecationWarning
ER->>Policy: policy_cls.from_args(parsed_args)
end
Policy-->>ER: policy instance
Reviews (1): Last reviewed commit: "Strengthen typed policy configuration te..." | Re-trigger Greptile |
🤖 Isaac Lab-Arena Review BotSummaryThis PR decouples policy construction from argparse: Findings🔵 Improvement — Test CoverageGood. The new VerdictShip it — one optional readability nit, nothing blocking. |
baaf3d9 to
2316763
Compare
alexmillane
left a comment
There was a problem hiding this comment.
LGTM!
One question I have is, in a few places you state that there are compatibility branches to policies that don't use config classes. To me it looks as if everything has been switched over. What still remains?
Separate the policy runtime contract from argparse while preserving the existing CLI adapters. Make scheduler and embodiment-adapter selection part of serializable policy configs so CLI and dictionary construction remain equivalent. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep the policy runtime contract limited to typed config instances. Associate config types during registration for legacy JSON evaluation and mark policy-owned argparse paths for removal. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep the custom-policy guide focused on typed construction. Document the current policy_runner limitation without teaching new policies to implement deprecated argparse adapters. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Reuse one dataclass-to-argparse compatibility helper for environment and policy frontends. Remove first-party policy-owned argparse adapters while preserving the deprecated untyped fallback. Signed-off-by: Clemens Volk <cvolk@nvidia.com>
2316763 to
5204bcd
Compare
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Summary
Decouple policy construction from argparse
Detailed description
PolicyCfgcontract and limitPolicyBaseto typed runtime configs.Cfgconvention.