Skip to content

Add typed Arena experiment runner - #867

Merged
cvolkcvolk merged 16 commits into
mainfrom
cvolk/refactor/typed-evaluation-experiments
Jul 7, 2026
Merged

cvolkcvolk merged 16 commits into
mainfrom
cvolk/refactor/typed-evaluation-experiments

Conversation

@cvolkcvolk

@cvolkcvolk cvolkcvolk commented Jul 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Run evaluations from typed experiment configs. Add ArenaExperimentCfg and RolloutCfg so an experiment describes its environment, policy, and rollout without making execution depend on an argparse namespace.

Detailed description

  • Keep current JSON files working by converting each legacy evaluation config into concrete ArenaExperimentCfg instances with experiment_cfgs_from_legacy_eval_config().
  • Register each environment config with its factory so build_and_run_experiment() can run an ArenaExperimentCfg directly, without a temporary callback wrapper.
  • Keep graph-based environments on the existing argparse path until they have typed configs.

Part of a broader move away from passing argparse.Namespace objects through Arena’s runtime. Environments, policies, builders, and evaluations will consume source-independent typed configs, allowing CLI, YAML/Hydra, and Python callers to share the same execution path.

Depends on #863

Comment thread isaaclab_arena/utils/hydra_overrides.py Resolved
Comment thread isaaclab_arena/assets/register.py Resolved
Comment thread isaaclab_arena/assets/register.py Resolved
Comment thread isaaclab_arena/assets/register.py Resolved
Comment thread isaaclab_arena/assets/registries.py Resolved
Comment thread isaaclab_arena/assets/registries.py Resolved
@cvolkcvolk
cvolkcvolk marked this pull request as ready for review July 7, 2026 12:31
Comment thread isaaclab_arena/evaluation/arena_run.py Resolved
@arena-review-bot

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

This PR replaces the mutable Job/JobManager execution model with typed ArenaExperimentCfg / RolloutCfg declarations and a build_and_run_experiment() runtime, while keeping the JSON and graph-YAML CLI paths working behind clearly-marked legacy adapters. The decomposition is clean: sim-touching orchestration lives in evaluation/, the domain types stay dependency-light, the reverse config→factory/policy lookups are well-scoped, and every temporary bridge carries a dated removal TODO. Two points below are worth a look — one a continue_on_error behavior change, one a bit of not-yet-reachable machinery — neither a blocker.

Findings

🟡 experiment_execution.py:50 — The rebuild loop is try/finally with no except, so a rebuild failure aborts the whole experiment. Under --continue_on_error this drops metrics from already-successful rebuilds and skips the rest, where the old code recorded the failure and continued. Arguably cleaner for benchmark integrity, but a behavior change for that flag worth confirming (a NOTE if deliberate).

🔵 arena_experiment.py:79 — build_and_run_experiment only ever returns COMPLETED (failures raise), so ExperimentStatus.FAILED and eval_runner's else Status.FAILED branch are unreachable today. Does the status/FAILED machinery need to exist yet, or is it a deliberate seam for the typed frontend?

Test Coverage

Good. The new pure-Python logic is well covered without a sim: test_experiment_execution exercises episode-budget splitting, resource cleanup on failure, and the unbounded-policy assertion via monkeypatch; test_legacy_eval_config covers JSON→typed conversion, the graph-YAML compatibility path, and unknown-field rejection; test_arena_experiment and test_policy_cfgs cover config validation and the reverse registry lookup. These are non-sim unit tests, so the inner/outer run_simulation_app_function pattern correctly does not apply, and they land in Phase 1.

Verdict

Ship it (after confirming the continue_on_error scope change is intended).

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces ArenaExperimentCfg and RolloutCfg as typed experiment declarations, replacing the argparse-namespace and JSON-dict wiring in the evaluation pipeline. Existing JSON eval configs are kept alive via experiment_cfgs_from_legacy_eval_config, which resolves environment and policy names to their registered typed configs and routes graph-YAML environments through a narrow compatibility shim (LegacyGraphEnvironmentCfg).

  • build_and_run_experiment consolidates the rebuild loop and resource cleanup that previously lived in eval_runner.py, and PolicyRegistry/EnvironmentRegistry each gain a reverse config→class lookup so typed execution can find the right factory without a name string.
  • overrides_from_dict is extracted from Job into variations_hydra.py for shared use, and resource-cleanup helpers are moved to a dedicated resource_cleanup.py module.

Confidence Score: 3/5

Two behavioral changes in the legacy adapter path need attention before this merges: per-rebuild failure recovery is gone and certain existing JSON configs will be rejected outright.

The old eval loop placed its try/except inside the per-rebuild for loop so that continue_on_error=True could skip a failing rebuild and aggregate metrics from the successful ones. build_and_run_experiment uses only try/finally in that loop, so any rebuild exception now propagates immediately, discarding all partial metrics and preventing remaining rebuilds from running. Separately, the top-level assert set(config) == {"jobs"} in experiment_cfgs_from_legacy_eval_config will raise for any existing JSON config that carries extra metadata fields, contradicting the stated goal of keeping current JSON files working.

experiment_execution.py (rebuild failure handling) and legacy_eval_config.py (config key assertion) need the most attention.

Important Files Changed

Filename Overview
isaaclab_arena/evaluation/arena_experiment.py New file defining ArenaExperimentCfg, RolloutCfg, and ArenaExperimentResult; ExperimentStatus.FAILED is defined but never returned by the execution layer.
isaaclab_arena/evaluation/experiment_execution.py New file containing build_and_run_experiment; silently removes per-rebuild continue_on_error recovery and drops partial metrics when any rebuild fails mid-sweep.
isaaclab_arena/evaluation/legacy_eval_config.py New legacy adapter from JSON eval configs to typed experiments; top-level key assertion is too strict and will reject existing configs with extra metadata fields.
isaaclab_arena/evaluation/eval_runner.py Heavy simplification delegating all rebuild/rollout logic to build_and_run_experiment; continue_on_error now only applies at job granularity, not per-rebuild.
isaaclab_arena/assets/registries.py Adds reverse config-to-factory lookup to EnvironmentRegistry and config-to-policy lookup to PolicyRegistry; duplicate-registration assertions are correct and symmetric.
isaaclab_arena/assets/register.py Switches register_environment from registry.register() to registry.register_environment() and adds _environment_cfg_type_from_factory resolver mirroring the existing policy resolver.
isaaclab_arena/evaluation/resource_cleanup.py Extracts _close_policy, _close_env, and _close_job_resources from eval_runner.py into a dedicated module; logic is unchanged and collect_garbage_and_clear_cuda_cache is still called in all paths.
isaaclab_arena/evaluation/legacy_graph_environment_cli.py Provides LegacyGraphEnvironmentCfg as a typed shim carrying raw CLI args for graph-YAML environments; correctly gated by isinstance check in the execution path.
isaaclab_arena/variations/variations_hydra.py Extracts the overrides_from_dict helper from Job._variations_to_hydra_overrides; logic is identical and the old method now delegates to the new one.
isaaclab_arena/evaluation/legacy_environment_cli_args.py Extracts Job.convert_args_dict_to_cli_args_list into its own module; argument ordering and boolean-flag handling match the original implementation exactly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["eval_runner.main()"] --> B["experiment_cfgs_from_legacy_eval_config()"]
    B --> C{"environment is\ngraph YAML?"}
    C -- yes --> D["LegacyGraphEnvironmentCfg\n(arena_env_args: list[str])"]
    C -- no --> E["EnvironmentRegistry\n.get_environment_cfg_type()\n→ concrete ArenaEnvironmentCfg"]
    D --> F["ArenaExperimentCfg"]
    E --> F
    B --> G["PolicyRegistry\n.get_policy_cfg_type()\n→ concrete PolicyCfg"]
    G --> F
    F --> H["build_and_run_experiment()"]
    H --> I["_split_episodes_across_rebuilds()"]
    I --> J["for each rebuild"]
    J --> K{"LegacyGraphEnvironmentCfg?"}
    K -- yes --> L["build_arena_builder_from_legacy_graph()\n(argparse path)"]
    K -- no --> M["EnvironmentRegistry\n.get_factory_type_for_cfg()\n→ factory.build(cfg)"]
    L --> N["arena_builder.make_registered()"]
    M --> N
    N --> O["_build_policy_from_cfg()\nPolicyRegistry.get_policy_type_for_cfg()"]
    O --> P["rollout_policy()"]
    P --> Q["close_experiment_resources()"]
    Q --> R["aggregate_metrics()\n→ ArenaExperimentResult(COMPLETED)"]
Loading
%%{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"}}}%%
flowchart TD
    A["eval_runner.main()"] --> B["experiment_cfgs_from_legacy_eval_config()"]
    B --> C{"environment is\ngraph YAML?"}
    C -- yes --> D["LegacyGraphEnvironmentCfg\n(arena_env_args: list[str])"]
    C -- no --> E["EnvironmentRegistry\n.get_environment_cfg_type()\n→ concrete ArenaEnvironmentCfg"]
    D --> F["ArenaExperimentCfg"]
    E --> F
    B --> G["PolicyRegistry\n.get_policy_cfg_type()\n→ concrete PolicyCfg"]
    G --> F
    F --> H["build_and_run_experiment()"]
    H --> I["_split_episodes_across_rebuilds()"]
    I --> J["for each rebuild"]
    J --> K{"LegacyGraphEnvironmentCfg?"}
    K -- yes --> L["build_arena_builder_from_legacy_graph()\n(argparse path)"]
    K -- no --> M["EnvironmentRegistry\n.get_factory_type_for_cfg()\n→ factory.build(cfg)"]
    L --> N["arena_builder.make_registered()"]
    M --> N
    N --> O["_build_policy_from_cfg()\nPolicyRegistry.get_policy_type_for_cfg()"]
    O --> P["rollout_policy()"]
    P --> Q["close_experiment_resources()"]
    Q --> R["aggregate_metrics()\n→ ArenaExperimentResult(COMPLETED)"]
Loading

Reviews (1): Last reviewed commit: "Simplify legacy config conversion signat..." | Re-trigger Greptile

@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.

LGTM.

Only comment is on what we call the experiments. Let's discuss that.

Comment thread isaaclab_arena/assets/registries.py Resolved
Comment thread isaaclab_arena/assets/registries.py Resolved
Comment thread isaaclab_arena/evaluation/arena_run.py Resolved
Comment thread isaaclab_arena/evaluation/arena_run.py Resolved
Separate portable experiment declarations from execution results and sequential dispatch. Remove the mutable Job and JobManager model while preserving the current JSON and environment-graph CLI paths behind explicit compatibility adapters.

Signed-off-by: Clemens Volk <[email protected]>
cvolkcvolk added 10 commits July 7, 2026 15:53
Return one resolved plan per legacy JSON job instead of parallel config and builder collections. Keep failure reporting in eval_runner and limit experiment results to data currently consumed.

Signed-off-by: Clemens Volk <[email protected]>
Register environment config-to-factory mappings so typed execution no longer carries temporary builder callbacks. Keep graph configs on the legacy argparse branch and require explicit or policy-provided rollout limits.

Signed-off-by: Clemens Volk <[email protected]>
Name config and legacy builders explicitly, document which registry direction remains part of typed execution, and explain the one import that must wait for SimulationApp.

Signed-off-by: Clemens Volk <[email protected]>
Pass only preserved CLI arguments and the values they require into the legacy builder adapter. Keep the typed experiment and builder configs outside the argparse compatibility function.

Signed-off-by: Clemens Volk <[email protected]>
Keep the JSON job adapter focused on producing typed experiment configs while limiting argparse compatibility to graph-YAML environment construction. Reject unknown registered-environment fields instead of silently falling back to the legacy parser.

Signed-off-by: Clemens Volk <[email protected]>
Separate shared legacy CLI argument formatting from the graph-only compatibility path, and name the JSON conversion module after the evaluation configuration it consumes.

Signed-off-by: Clemens Volk <[email protected]>
@cvolkcvolk
cvolkcvolk force-pushed the cvolk/refactor/typed-evaluation-experiments branch from f76a805 to e4f1f18 Compare July 7, 2026 13:53
@cvolkcvolk
cvolkcvolk changed the base branch from cvolk/refactor/arena-env-builder-cfg to main July 7, 2026 13:55
@cvolkcvolk
cvolkcvolk merged commit dc0dd8c into main Jul 7, 2026
6 checks passed
cvolkcvolk added a commit that referenced this pull request Jul 9, 2026
## Summary
Use typed Runs for experiment orchestration. Replace the CLI-oriented
`Job` and `JobManager` layer with the typed Run configuration and result
model introduced in #867.

## Detailed description
- Treat each JSON document as an ordered Experiment of Runs and execute
them directly through build_and_run.
- Preserve the legacy JSON schema, CLI, chunking, camera preflight,
reporting, and continue-on-error behavior.

---------

Signed-off-by: Clemens Volk <[email protected]>
cvolkcvolk added a commit that referenced this pull request Jul 14, 2026
## Summary
Keep local planning files `CONTEXT.md` and `CONTEXT-MAP.md` out of Git

## Detailed description
- `CONTEXT.md` was created while planning #867 and was merged
unintentionally.
- Removes the file and ignores `/CONTEXT.md` and `/CONTEXT-MAP.md` at
the repository root so they are not committed by mistake

---------

Signed-off-by: Clemens Volk <[email protected]>
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