Skip to content

Commit cfd9f31

Browse files
committed
Generalize versioned camera scopes
1 parent 101dabb commit cfd9f31

2 files changed

Lines changed: 26 additions & 33 deletions

File tree

‎src/wrbench/benchmark.py‎

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,20 @@ def _scope_camera_spec(row: dict[str, Any], *, index: int) -> Natural25CameraSpe
107107
)
108108

109109

110-
def _release_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25CameraScope:
111-
"""Adapt a versioned paper scope to the per-model generation runner."""
110+
def _versioned_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25CameraScope:
111+
"""Adapt an immutable release scope without depending on a release id."""
112112
scope_id = str(payload.get("scope_id") or "")
113-
if scope_id == "paper_main_20260608.api_prompt_camera":
113+
if payload.get("control_semantics"):
114114
raise ValueError(
115-
f"{path}: the frozen API prompt-camera scope is inspect-only; it records prompt intent "
115+
f"{path}: this prompt-camera scope is inspect-only; it records prompt intent "
116116
"without requested degrees or target C2W and must not be passed to --camera-scope"
117117
)
118118

119-
if scope_id == "paper_main_20260608.local_dual_angle":
120-
expected_keys = {
121-
"cells",
122-
"expected_rows",
123-
"models",
124-
"prompt_catalog_id",
125-
"rows_per_cell_per_model",
126-
"schema_version",
127-
"scope_id",
128-
}
129-
if set(payload) != expected_keys:
130-
raise ValueError(f"{path}: local dual-angle release scope keys do not match the schema")
119+
models = tuple(str(model) for model in payload.get("models", ()))
120+
if not scope_id or not models:
121+
raise ValueError(f"{path}: versioned camera scope requires scope_id and models")
122+
123+
if "cells" in payload and "rows_per_cell_per_model" in payload:
131124
cameras = tuple(
132125
_scope_camera_spec(
133126
{
@@ -143,7 +136,6 @@ def _release_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25Ca
143136
)
144137
rows_per_cell = int(payload["rows_per_cell_per_model"])
145138
expected_task_count = rows_per_cell * len(cameras)
146-
models = tuple(str(model) for model in payload["models"])
147139
if int(payload["expected_rows"]) != expected_task_count * len(models):
148140
raise ValueError(f"{path}: aggregate rows do not match models x cells x rows-per-cell")
149141
return Natural25CameraScope(
@@ -154,19 +146,7 @@ def _release_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25Ca
154146
applicable_models=models,
155147
)
156148

157-
if scope_id == "paper_main_20260608.local_static":
158-
expected_keys = {
159-
"camera_type",
160-
"excluded_models",
161-
"expected_rows",
162-
"models",
163-
"prompt_catalog_id",
164-
"rows_per_model",
165-
"schema_version",
166-
"scope_id",
167-
}
168-
if set(payload) != expected_keys:
169-
raise ValueError(f"{path}: local static release scope keys do not match the schema")
149+
if "camera_type" in payload and "rows_per_model" in payload:
170150
camera_type = str(payload["camera_type"])
171151
camera = _scope_camera_spec(
172152
{
@@ -178,7 +158,6 @@ def _release_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25Ca
178158
},
179159
index=0,
180160
)
181-
models = tuple(str(model) for model in payload["models"])
182161
expected_task_count = int(payload["rows_per_model"])
183162
if int(payload["expected_rows"]) != expected_task_count * len(models):
184163
raise ValueError(f"{path}: aggregate rows do not match models x rows-per-model")
@@ -190,14 +169,14 @@ def _release_camera_scope(payload: dict[str, Any], *, path: Path) -> Natural25Ca
190169
applicable_models=models,
191170
)
192171

193-
raise ValueError(f"{path}: unknown versioned paper camera scope {scope_id!r}")
172+
raise ValueError(f"{path}: unsupported versioned camera scope shape for {scope_id!r}")
194173

195174

196175
def load_natural25_camera_scope(path: str | Path) -> Natural25CameraScope:
197176
resolved = Path(path)
198177
payload = json.loads(resolved.read_text(encoding="utf-8"))
199178
if payload.get("schema_version") == "wrbench.camera_scope.v1":
200-
return _release_camera_scope(payload, path=resolved)
179+
return _versioned_camera_scope(payload, path=resolved)
201180
expected_keys = {"schema_version", "scope_id", "variant_filter", "expected_task_count", "cameras"}
202181
keys = set(payload)
203182
if keys != expected_keys:

‎tests/test_benchmark_tasks.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
from collections import Counter
5+
from pathlib import Path
56

67
import pytest
78

@@ -134,6 +135,19 @@ def test_paper_local_static_scope_is_runner_compatible() -> None:
134135
assert {task.stress_yaw_deg for task in tasks} == {None}
135136

136137

138+
def test_versioned_scope_loader_does_not_depend_on_release_id(tmp_path: Path) -> None:
139+
source = natural25_release_path("camera_scopes/local_static.json")
140+
payload = json.loads(source.read_text(encoding="utf-8"))
141+
payload["scope_id"] = "example_release.local_static"
142+
path = tmp_path / "scope.json"
143+
path.write_text(json.dumps(payload), encoding="utf-8")
144+
145+
scope = load_natural25_camera_scope(path)
146+
147+
assert scope.scope_id == "example_release.local_static"
148+
assert scope.expected_task_count == 100
149+
150+
137151
def test_paper_api_prompt_camera_scope_is_explicitly_inspect_only() -> None:
138152
with pytest.raises(ValueError, match="inspect-only"):
139153
load_natural25_camera_scope(

0 commit comments

Comments
 (0)