Upload folder using huggingface_hub (part 15)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- bw_0220/tests/blenderworld/cli.py +82 -0
- bw_0220/tests/blenderworld/data.py +127 -0
- bw_0220/tests/blenderworld/evaluation.py +270 -0
- bw_0220/tests/blenderworld/evaluators/__init__.py +1 -0
- bw_0220/tests/blenderworld/evaluators/asset_paths.py +163 -0
- bw_0220/tests/blenderworld/evaluators/evidence_checks.py +250 -0
- bw_0220/tests/blenderworld/evaluators/judge_blender_agent.py +878 -0
- bw_0220/tests/blenderworld/evaluators/judge_blender_binary_rubrics.py +0 -0
- bw_0220/tests/blenderworld/harbor_export.py +205 -0
- bw_0220/tests/blenderworld/harbor_verify.py +80 -0
- bw_0220/tests/blenderworld/render_agent.py +130 -0
- bw_0220/tests/blenderworld/runtime.py +102 -0
- bw_0220/tests/blenderworld/submissions.py +211 -0
- bw_0220/tests/dataset/dataset.jsonl +1 -0
- bw_0220/tests/dataset/rubrics.json +361 -0
- bw_0220/tests/dataset/tasks/bw_0220/query.txt +1 -0
- bw_0220/tests/dataset/tasks/bw_0220/references/video_01.mp4 +3 -0
- bw_0220/tests/dataset/tasks/bw_0220/rubric.json +357 -0
- bw_0220/tests/dataset/tasks/bw_0220/task.json +41 -0
- bw_0220/tests/install_blender.sh +16 -0
- bw_0220/tests/requirements-verifier.txt +4 -0
- bw_0220/tests/test.sh +6 -0
- bw_0221/environment/Dockerfile +37 -0
- bw_0221/environment/LICENSE +21 -0
- bw_0221/environment/blender_startup.py +21 -0
- bw_0221/environment/inputs/input.json +9 -0
- bw_0221/environment/inputs/instruction.html +5 -0
- bw_0221/environment/inputs/query.txt +1 -0
- bw_0221/environment/inputs/reference_images.base64.json +6 -0
- bw_0221/environment/inputs/references/video_01.mp4 +3 -0
- bw_0221/environment/install_blender.sh +16 -0
- bw_0221/environment/mcp_bridge.py +80 -0
- bw_0221/environment/requirements-tools.txt +6 -0
- bw_0221/instruction.md +25 -0
- bw_0221/task.toml +63 -0
- bw_0221/tests/Dockerfile +31 -0
- bw_0221/tests/LICENSE +21 -0
- bw_0221/tests/blenderworld/__init__.py +2 -0
- bw_0221/tests/blenderworld/__main__.py +3 -0
- bw_0221/tests/blenderworld/blender_runtime.py +65 -0
- bw_0221/tests/blenderworld/cli.py +82 -0
- bw_0221/tests/blenderworld/data.py +127 -0
- bw_0221/tests/blenderworld/evaluation.py +270 -0
- bw_0221/tests/blenderworld/evaluators/__init__.py +1 -0
- bw_0221/tests/blenderworld/evaluators/asset_paths.py +163 -0
- bw_0221/tests/blenderworld/evaluators/evidence_checks.py +250 -0
- bw_0221/tests/blenderworld/evaluators/judge_blender_agent.py +878 -0
- bw_0221/tests/blenderworld/evaluators/judge_blender_binary_rubrics.py +0 -0
- bw_0221/tests/blenderworld/harbor_export.py +205 -0
- bw_0221/tests/blenderworld/harbor_verify.py +80 -0
bw_0220/tests/blenderworld/cli.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Command line interface for local task preparation and evaluation."""
|
| 2 |
+
import argparse
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from .data import load_tasks, prepare, verify
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def main():
|
| 11 |
+
parser = argparse.ArgumentParser(prog="bw", description="BlenderWorld benchmark tools")
|
| 12 |
+
commands = parser.add_subparsers(dest="command", required=True)
|
| 13 |
+
download = commands.add_parser("download", help="Download the frozen dataset from Hugging Face")
|
| 14 |
+
download.add_argument("--repo-id", default="Qwen/BlenderWorld")
|
| 15 |
+
download.add_argument("--revision", default="main")
|
| 16 |
+
download.add_argument("--output", default="data/BlenderWorld")
|
| 17 |
+
check = commands.add_parser("verify", help="Verify task content, paths and checksums")
|
| 18 |
+
check.add_argument("dataset")
|
| 19 |
+
listing = commands.add_parser("list", help="List tasks")
|
| 20 |
+
listing.add_argument("dataset")
|
| 21 |
+
listing.add_argument("--modality", choices=["text", "image", "video"])
|
| 22 |
+
staging = commands.add_parser("prepare", help="Stage a task's generator-visible inputs")
|
| 23 |
+
staging.add_argument("--dataset", required=True)
|
| 24 |
+
staging.add_argument("--task-id", required=True)
|
| 25 |
+
staging.add_argument("--output", required=True)
|
| 26 |
+
packing = commands.add_parser("pack-submission", help="Package model outputs as one submission ZIP")
|
| 27 |
+
packing.add_argument("--source", required=True, help="Output directory or ZIP with final.blend at its root")
|
| 28 |
+
packing.add_argument("--task-id", required=True)
|
| 29 |
+
packing.add_argument("--output", required=True, help="New submissions/bw_XXXX.zip")
|
| 30 |
+
harbor = commands.add_parser("export-harbor", help="Export self-contained Harbor tasks (Python 3.12+)")
|
| 31 |
+
harbor.add_argument("--dataset", required=True)
|
| 32 |
+
harbor.add_argument("--output", required=True)
|
| 33 |
+
harbor.add_argument("--namespace", default="Qwen")
|
| 34 |
+
harbor.add_argument("--task-id", action="append")
|
| 35 |
+
harbor.add_argument("--cpus", type=int, default=8)
|
| 36 |
+
harbor.add_argument("--memory-mb", type=int, default=16384)
|
| 37 |
+
harbor.add_argument("--gpus", type=int, default=0)
|
| 38 |
+
harbor.add_argument("--agent-timeout", type=int, default=14400)
|
| 39 |
+
harbor.add_argument("--verifier-timeout", type=int, default=28800)
|
| 40 |
+
scoring = commands.add_parser("evaluate", help="Render and judge per-task BlenderWorld submission ZIPs")
|
| 41 |
+
scoring.add_argument("--dataset", required=True)
|
| 42 |
+
scoring.add_argument("--submissions", "--submission", dest="submissions", required=True,
|
| 43 |
+
help="Directory of bw_XXXX.zip files, or a single task ZIP")
|
| 44 |
+
scoring.add_argument("--output", required=True)
|
| 45 |
+
scoring.add_argument("--task-id", action="append")
|
| 46 |
+
scoring.add_argument("--dry-run", action="store_true")
|
| 47 |
+
scoring.add_argument("--resume", action="store_true")
|
| 48 |
+
scoring.add_argument("--blender-bin", default=os.environ.get("BLENDER_BIN", "blender"))
|
| 49 |
+
scoring.add_argument("--render-agent-model", default=os.environ.get("RENDER_AGENT_MODEL", "gpt-5.6-terra"))
|
| 50 |
+
scoring.add_argument("--agent-judge-model", default=os.environ.get("AGENT_JUDGE_MODEL", "gpt-5.6-terra"))
|
| 51 |
+
scoring.add_argument("--judge-model", default=os.environ.get("JUDGE_MODEL", "gpt-5.6-terra"))
|
| 52 |
+
scoring.add_argument("--judge-api-endpoint", default=os.environ.get("JUDGE_API_ENDPOINT", "https://api.openai.com/v1/chat/completions"))
|
| 53 |
+
args = parser.parse_args()
|
| 54 |
+
try:
|
| 55 |
+
if args.command == "download":
|
| 56 |
+
from huggingface_hub import snapshot_download
|
| 57 |
+
snapshot_download(args.repo_id, repo_type="dataset", revision=args.revision, local_dir=args.output)
|
| 58 |
+
result = verify(args.output)
|
| 59 |
+
elif args.command == "verify":
|
| 60 |
+
result = verify(args.dataset)
|
| 61 |
+
elif args.command == "prepare":
|
| 62 |
+
result = prepare(args.dataset, args.task_id, args.output)
|
| 63 |
+
elif args.command == "pack-submission":
|
| 64 |
+
from .submissions import pack_submission
|
| 65 |
+
result = pack_submission(args.source, args.task_id, args.output)
|
| 66 |
+
elif args.command == "list":
|
| 67 |
+
result = [{"task_id": r["task_id"], "modality": r["modality"], "rubric_count": r["rubric_count"]}
|
| 68 |
+
for r in load_tasks(args.dataset) if not args.modality or r["modality"] == args.modality]
|
| 69 |
+
elif args.command == "export-harbor":
|
| 70 |
+
from .harbor_export import export_harbor
|
| 71 |
+
result = export_harbor(args.dataset, args.output, args.namespace, args.task_id,
|
| 72 |
+
args.cpus, args.memory_mb, args.gpus,
|
| 73 |
+
args.agent_timeout, args.verifier_timeout)
|
| 74 |
+
else:
|
| 75 |
+
from .evaluation import evaluate
|
| 76 |
+
result = evaluate(args)
|
| 77 |
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
| 78 |
+
if args.command == "evaluate" and not args.dry_run and result["overall"]["succeeded"] != result["overall"]["task_count"]:
|
| 79 |
+
return 2
|
| 80 |
+
return 0
|
| 81 |
+
except (OSError, ValueError, RuntimeError) as error:
|
| 82 |
+
parser.exit(2, f"bw: {error}\n")
|
bw_0220/tests/blenderworld/data.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Load and verify the portable dataset without a model service."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
from collections import Counter
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
RESOURCE_FIELDS = ("attachments", "supplemental_attachments", "reference_images",
|
| 12 |
+
"reference_videos", "rubric_reference_images")
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def sha256(path):
|
| 16 |
+
h = hashlib.sha256()
|
| 17 |
+
with Path(path).open("rb") as stream:
|
| 18 |
+
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
| 19 |
+
h.update(chunk)
|
| 20 |
+
return h.hexdigest()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def write_json(path, obj):
|
| 24 |
+
path = Path(path)
|
| 25 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 26 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 27 |
+
temporary.write_text(json.dumps(obj, ensure_ascii=False, indent=2) + "\n")
|
| 28 |
+
temporary.replace(path)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def resolve(root, relative):
|
| 32 |
+
root = Path(root).resolve()
|
| 33 |
+
path = root / relative
|
| 34 |
+
if Path(relative).is_absolute() or not path.resolve().is_relative_to(root):
|
| 35 |
+
raise ValueError(f"Path escapes dataset: {relative}")
|
| 36 |
+
return path
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def load_tasks(root):
|
| 40 |
+
rows = [json.loads(s) for s in (Path(root) / "dataset.jsonl").read_text().splitlines() if s.strip()]
|
| 41 |
+
ids = [r["task_id"] for r in rows]
|
| 42 |
+
if len(set(ids)) != len(ids) or not all(re.fullmatch(r"bw_\d{4}", s) for s in ids):
|
| 43 |
+
raise ValueError("Task IDs must be unique neutral identifiers")
|
| 44 |
+
return rows
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def verify(root):
|
| 48 |
+
root = Path(root)
|
| 49 |
+
rows = load_tasks(root)
|
| 50 |
+
modalities = Counter(r["modality"] for r in rows)
|
| 51 |
+
if modalities != {"text": 78, "image": 130, "video": 15}:
|
| 52 |
+
raise ValueError(f"Unexpected benchmark task counts: {modalities}")
|
| 53 |
+
bundled = json.loads((root / "rubrics.json").read_text())["results"]
|
| 54 |
+
combined = {r["task_id"]: r for r in bundled}
|
| 55 |
+
if len(combined) != 223 or len(bundled) != 223:
|
| 56 |
+
raise ValueError("Combined rubric index must have 223 unique tasks")
|
| 57 |
+
criteria, resources = 0, 0
|
| 58 |
+
for row in rows:
|
| 59 |
+
task_root = root / "tasks" / row["task_id"]
|
| 60 |
+
if json.loads((task_root / "task.json").read_text()) != row:
|
| 61 |
+
raise ValueError(f"Task/index mismatch: {row['task_id']}")
|
| 62 |
+
if resolve(root, row["query_file"]).read_text() != row["query"]:
|
| 63 |
+
raise ValueError(f"Query mismatch: {row['task_id']}")
|
| 64 |
+
rubric = json.loads(resolve(root, row["rubric_file"]).read_text())
|
| 65 |
+
if rubric != combined[row["task_id"]] or rubric["prompt"] != row["query"]:
|
| 66 |
+
raise ValueError(f"Rubric/query/index mismatch: {row['task_id']}")
|
| 67 |
+
ids = [r["id"] for r in rubric["rubrics"]]
|
| 68 |
+
if len(set(ids)) != len(ids) or len(ids) != row["rubric_count"]:
|
| 69 |
+
raise ValueError(f"Invalid criterion IDs: {row['task_id']}")
|
| 70 |
+
for criterion in rubric["rubrics"]:
|
| 71 |
+
if criterion["score_values"] != [0, 1] or criterion["importance_weight"] not in (1, 2, 3):
|
| 72 |
+
raise ValueError("Invalid binary criterion/importance weight")
|
| 73 |
+
if criterion["evidence_type"] not in {"scene_summary", "render", "either"}:
|
| 74 |
+
raise ValueError("Unknown evidence route")
|
| 75 |
+
for attachment in rubric["attachments"]:
|
| 76 |
+
if not resolve(task_root, attachment["file"]).is_file():
|
| 77 |
+
raise ValueError(f"Missing rubric attachment: {attachment['file']}")
|
| 78 |
+
if rubric.get("image_file") and not resolve(task_root, rubric["image_file"]).is_file():
|
| 79 |
+
raise ValueError(f"Missing rubric image: {rubric['image_file']}")
|
| 80 |
+
for field in RESOURCE_FIELDS:
|
| 81 |
+
for entry in row[field]:
|
| 82 |
+
path = resolve(root, entry["path"])
|
| 83 |
+
if path != resolve(task_root, entry["task_relative_path"]):
|
| 84 |
+
raise ValueError("Resource path aliases disagree")
|
| 85 |
+
if path.stat().st_size != entry["bytes"] or sha256(path) != entry["sha256"]:
|
| 86 |
+
raise ValueError(f"Resource checksum mismatch: {entry['path']}")
|
| 87 |
+
resources += 1
|
| 88 |
+
criteria += len(ids)
|
| 89 |
+
if criteria != 2651:
|
| 90 |
+
raise ValueError(f"Expected 2651 criteria, got {criteria}")
|
| 91 |
+
checksums = root / "SHA256SUMS"
|
| 92 |
+
if not checksums.is_file():
|
| 93 |
+
raise ValueError("Missing release SHA256SUMS")
|
| 94 |
+
checksum_paths = set()
|
| 95 |
+
for line in checksums.read_text().splitlines():
|
| 96 |
+
checksum, relative = line.split(" ", 1)
|
| 97 |
+
if relative in checksum_paths or sha256(resolve(root, relative)) != checksum:
|
| 98 |
+
raise ValueError(f"Duplicate or incorrect checksum: {relative}")
|
| 99 |
+
checksum_paths.add(relative)
|
| 100 |
+
actual_paths = {p.relative_to(root).as_posix() for p in root.rglob("*") if p.is_file()
|
| 101 |
+
and not any(part in {".git", ".cache"} for part in p.relative_to(root).parts)}
|
| 102 |
+
if actual_paths != checksum_paths | {"SHA256SUMS"}:
|
| 103 |
+
raise ValueError("Release checksum inventory does not cover the complete file tree")
|
| 104 |
+
manifest = json.loads((root / "manifest.json").read_text())
|
| 105 |
+
if {r["path"] for r in manifest["files"]} != actual_paths - {"manifest.json", "SHA256SUMS"}:
|
| 106 |
+
raise ValueError("Manifest does not cover the complete release payload")
|
| 107 |
+
return {"tasks": len(rows), "modalities": dict(modalities), "criteria": criteria,
|
| 108 |
+
"resources": resources, "checksums_verified": checksums.exists()}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def prepare(root, task_id, output):
|
| 112 |
+
"""Stage only generator-visible inputs; evaluation rubrics remain in the dataset."""
|
| 113 |
+
root, output = Path(root), Path(output)
|
| 114 |
+
row = next((r for r in load_tasks(root) if r["task_id"] == task_id), None)
|
| 115 |
+
if row is None:
|
| 116 |
+
raise ValueError(f"Unknown task: {task_id}")
|
| 117 |
+
output.mkdir(parents=True, exist_ok=False)
|
| 118 |
+
(output / "query.txt").write_text(row["query"])
|
| 119 |
+
inputs = []
|
| 120 |
+
for field in ("attachments", "reference_images", "reference_videos"):
|
| 121 |
+
for entry in row[field]:
|
| 122 |
+
target = resolve(output, entry["task_relative_path"])
|
| 123 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 124 |
+
shutil.copyfile(resolve(root, entry["path"]), target)
|
| 125 |
+
inputs.append(entry["task_relative_path"])
|
| 126 |
+
write_json(output / "input.json", {"task_id": task_id, "query_file": "query.txt", "files": inputs})
|
| 127 |
+
return {"task_id": task_id, "output": str(output), "input_files": len(inputs)}
|
bw_0220/tests/blenderworld/evaluation.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Local evidence preparation, rendering, judging, and benchmark aggregation."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import csv
|
| 5 |
+
import fcntl
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
import shutil
|
| 9 |
+
import subprocess
|
| 10 |
+
import sys
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
from . import render_agent
|
| 14 |
+
from .data import RESOURCE_FIELDS, load_tasks, resolve, sha256, write_json
|
| 15 |
+
from .evaluators import judge_blender_binary_rubrics as vision
|
| 16 |
+
from .evaluators.evidence_checks import cli_log_status
|
| 17 |
+
from .runtime import RuntimeValidationError, inspect_runtime, record_runtime, requirements
|
| 18 |
+
from .submissions import FORMAT, inspect_submission, unpack_submission
|
| 19 |
+
|
| 20 |
+
PROTOCOL = {"version": 1, "views": 8, "resolution": 1024, "samples": 64,
|
| 21 |
+
"engine": "CYCLES", "max_corrective_rerenders": 2,
|
| 22 |
+
"dimension_weight": 0.5, "score_cap": None,
|
| 23 |
+
"structural_evidence": ["scene_summary"], "visual_evidence": ["render", "either"]}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def tree_hashes(root):
|
| 27 |
+
root = Path(root)
|
| 28 |
+
return {p.relative_to(root).as_posix(): sha256(p) for p in sorted(root.rglob("*")) if p.is_file()}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def sample_video(source, destination, count):
|
| 32 |
+
destination.mkdir(parents=True, exist_ok=True)
|
| 33 |
+
probe = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration",
|
| 34 |
+
"-of", "json", str(source)], check=True, capture_output=True, text=True, timeout=60)
|
| 35 |
+
duration = float(json.loads(probe.stdout)["format"]["duration"])
|
| 36 |
+
if duration <= 0:
|
| 37 |
+
raise ValueError(f"Video has no positive duration: {source.name}")
|
| 38 |
+
# Sample across the whole clip, including both ends without seeking past its last frame.
|
| 39 |
+
for i in range(count):
|
| 40 |
+
timestamp = max(0, duration - min(0.1, duration / count)) * i / max(1, count - 1)
|
| 41 |
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-ss", str(timestamp), "-i", str(source),
|
| 42 |
+
"-frames:v", "1", str(destination / f"frame_{i:03d}.png")],
|
| 43 |
+
check=True, capture_output=True, timeout=120)
|
| 44 |
+
if len(list(destination.glob("*.png"))) != count:
|
| 45 |
+
raise ValueError(f"Incomplete video sampling: {source.name}")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def prepare_evaluation(dataset, row, submission, task_dir):
|
| 49 |
+
task_dir.mkdir(parents=True, exist_ok=False)
|
| 50 |
+
snapshot = task_dir / ".eval_workspace"
|
| 51 |
+
# The public ZIP contract is independent of the model's generation harness.
|
| 52 |
+
manifest = unpack_submission(submission, row["task_id"], snapshot)
|
| 53 |
+
write_json(task_dir / "submission_archive.json", manifest)
|
| 54 |
+
(task_dir / "query.txt").write_text(row["query"])
|
| 55 |
+
rubric = json.loads(resolve(dataset, row["rubric_file"]).read_text())
|
| 56 |
+
write_json(task_dir / "rubric.json", rubric)
|
| 57 |
+
input_hashes = {entry["sha256"] for field in RESOURCE_FIELDS for entry in row[field]}
|
| 58 |
+
write_json(task_dir / "input_media_sha256.json", sorted(input_hashes))
|
| 59 |
+
for field in RESOURCE_FIELDS:
|
| 60 |
+
for entry in row[field]:
|
| 61 |
+
path = resolve(task_dir, entry["task_relative_path"])
|
| 62 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 63 |
+
shutil.copyfile(resolve(dataset, entry["path"]), path)
|
| 64 |
+
judge_refs = task_dir / "image_assets"
|
| 65 |
+
judge_refs.mkdir()
|
| 66 |
+
image_entries = row["rubric_reference_images"] or row["reference_images"]
|
| 67 |
+
for entry in image_entries:
|
| 68 |
+
shutil.copyfile(resolve(dataset, entry["path"]), judge_refs / Path(entry["path"]).name)
|
| 69 |
+
for i, entry in enumerate(row["reference_videos"]):
|
| 70 |
+
sample_video(resolve(dataset, entry["path"]), judge_refs / f"video_{i:02d}", 4)
|
| 71 |
+
for i, video in enumerate(sorted(snapshot.rglob("*"))):
|
| 72 |
+
if (video.is_file() and video.suffix.lower() in {".mp4", ".mov", ".mkv", ".webm"}
|
| 73 |
+
and sha256(video) not in input_hashes):
|
| 74 |
+
sample_video(video, task_dir / "animation_frames" / f"clip_{i:03d}", 16)
|
| 75 |
+
write_json(task_dir / "submission_sha256.json", tree_hashes(snapshot))
|
| 76 |
+
write_json(task_dir / "rubrics_batch.json", {"results": [{**rubric, "task_dir": str(task_dir.resolve())}]})
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def run_module(module, args, log):
|
| 80 |
+
with log.open("w") as stream:
|
| 81 |
+
completed = subprocess.run([sys.executable, "-m", "blenderworld.evaluators." + module, *args],
|
| 82 |
+
env={**os.environ, "DISABLE_AUTOUPDATER": "1"},
|
| 83 |
+
stdout=stream, stderr=subprocess.STDOUT, check=False)
|
| 84 |
+
if completed.returncode:
|
| 85 |
+
raise RuntimeError(f"{module} failed ({completed.returncode}); see {log.name}")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def validate_score(row, rubric, result):
|
| 89 |
+
if result.get("ok") is not True or result.get("dry_run"):
|
| 90 |
+
raise ValueError("Judge did not produce a successful scored result")
|
| 91 |
+
if result.get("cap_applied") or not result.get("rendered_image_files"):
|
| 92 |
+
raise ValueError("Result does not follow the public scoring protocol")
|
| 93 |
+
scores = result.get("rubric_scores", [])
|
| 94 |
+
expected = {r["id"] for r in rubric["rubrics"]}
|
| 95 |
+
if {r["id"] for r in scores} != expected or len(scores) != len(expected):
|
| 96 |
+
raise ValueError("Incomplete or duplicate rubric scores")
|
| 97 |
+
if any(type(r.get("score")) is not int or r["score"] not in (0, 1) for r in scores):
|
| 98 |
+
raise ValueError("Rubric scores must be binary integers")
|
| 99 |
+
dimensions = result.get("dimension_scores", [])
|
| 100 |
+
expected_dims = {r["id"] for r in vision.DIMENSIONS}
|
| 101 |
+
if {r["id"] for r in dimensions} != expected_dims or len(dimensions) != len(expected_dims):
|
| 102 |
+
raise ValueError("Incomplete or duplicate dimension scores")
|
| 103 |
+
if any(type(r.get("score")) is not int or not 1 <= r["score"] <= 10 for r in dimensions):
|
| 104 |
+
raise ValueError("Dimension scores must be integers from 1 to 10")
|
| 105 |
+
rubric_score = vision.build_score_summary(rubric["rubrics"], scores)["weighted_score_0_100"]
|
| 106 |
+
dimension_score = 10 * sum(d["score"] for d in dimensions) / len(dimensions)
|
| 107 |
+
fused = 0.5 * (rubric_score + dimension_score)
|
| 108 |
+
if abs(fused - result["fused_score_0_100"]) > 1e-6:
|
| 109 |
+
raise ValueError("Fused score differs from the paper's uncapped 1:1 formula")
|
| 110 |
+
return {"task_id": row["task_id"], "modality": row["modality"], "ok": True,
|
| 111 |
+
"score": fused, "rubric_score": rubric_score, "dimension_score": dimension_score,
|
| 112 |
+
"error": ""}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def score_task(row, task_dir, options):
|
| 116 |
+
common = ["--rubrics-batch", str(task_dir / "rubrics_batch.json"),
|
| 117 |
+
"--image-glob", "evaluation/multiview/*.png", "--max-images", "8",
|
| 118 |
+
"--reference-image-glob", "image_assets/**/*", "--max-reference-images", "4",
|
| 119 |
+
"--extra-image-glob", ".eval_workspace/**/*.png,.eval_workspace/**/*.jpg,.eval_workspace/**/*.jpeg,.eval_workspace/**/*.webp"]
|
| 120 |
+
rubric = json.loads((task_dir / "rubric.json").read_text())
|
| 121 |
+
if any(r["evidence_type"] == "scene_summary" for r in rubric["rubrics"]):
|
| 122 |
+
run_module("judge_blender_agent", common + ["--agent-evidence-types", "scene_summary",
|
| 123 |
+
"--no-dimension-pass", "--blender-bin", options.blender_bin,
|
| 124 |
+
"--model", options.agent_judge_model, "--task-concurrency", "1",
|
| 125 |
+
"--batch-output", str(task_dir / "agent_batch.json")], task_dir / "agent_judge.log")
|
| 126 |
+
folder = task_dir / "evaluation/agent_judge_multiview_eval"
|
| 127 |
+
agent_result = json.loads((folder / "judgement.json").read_text())
|
| 128 |
+
if agent_result.get("agent_returncode") != 0:
|
| 129 |
+
raise ValueError("Structural judge did not exit successfully")
|
| 130 |
+
expected_logs = [folder / "agent_judge_stdout.jsonl"] + [
|
| 131 |
+
folder / f"agent_judge_stdout.attempt{i}.jsonl"
|
| 132 |
+
for i in range(2, agent_result.get("agent_attempts", 1) + 1)]
|
| 133 |
+
if any(not p.is_file() for p in expected_logs):
|
| 134 |
+
raise ValueError("Structural judge attempt logs are incomplete")
|
| 135 |
+
for log in folder.glob("agent_judge_stdout*.jsonl"):
|
| 136 |
+
terminal, refused = cli_log_status(log)
|
| 137 |
+
if refused:
|
| 138 |
+
raise ValueError("Structural judge encountered an upstream content refusal")
|
| 139 |
+
terminal, refused = cli_log_status(resolve(task_dir, agent_result["agent_stdout_path"]))
|
| 140 |
+
if not terminal or terminal.get("is_error"):
|
| 141 |
+
raise ValueError("Structural judge did not terminate successfully")
|
| 142 |
+
for key in ("agent_raw_path", "bpy_dump_path"):
|
| 143 |
+
if not json.loads(resolve(task_dir, agent_result[key]).read_text()):
|
| 144 |
+
raise ValueError("Structural judge has no inspectable raw evidence")
|
| 145 |
+
run_module("judge_blender_binary_rubrics", common + ["--evidence-routing",
|
| 146 |
+
"--model", options.judge_model, "--api-endpoint", options.judge_api_endpoint,
|
| 147 |
+
"--anim-frame-glob", "animation_frames/**/*.png", "--max-anim-frames", "16",
|
| 148 |
+
"--task-concurrency", "1", "--batch-output", str(task_dir / "vision_batch.json")],
|
| 149 |
+
task_dir / "vision_judge.log")
|
| 150 |
+
result = json.loads((task_dir / "evaluation/judge_vlm/judgement.json").read_text())
|
| 151 |
+
if tree_hashes(task_dir / ".eval_workspace") != json.loads((task_dir / "submission_sha256.json").read_text()):
|
| 152 |
+
raise ValueError("Evaluator modified the submitted workspace")
|
| 153 |
+
return validate_score(row, rubric, result)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def summarize(rows, records):
|
| 157 |
+
def aggregate(selected):
|
| 158 |
+
count = len(selected)
|
| 159 |
+
known = [records[r["task_id"]] for r in selected if r["task_id"] in records]
|
| 160 |
+
return {"task_count": count, "completed": len(known), "succeeded": sum(r["ok"] for r in known),
|
| 161 |
+
"mean_score": sum(r["score"] for r in known) / count if count else None}
|
| 162 |
+
return {"complete": len(records) == len(rows), "overall": aggregate(rows),
|
| 163 |
+
"text": aggregate([r for r in rows if r["modality"] == "text"]),
|
| 164 |
+
"multimodal": aggregate([r for r in rows if r["modality"] != "text"]),
|
| 165 |
+
"results": [records[r["task_id"]] for r in rows if r["task_id"] in records]}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def evaluate(options):
|
| 169 |
+
dataset, submissions, output = map(lambda p: Path(p).resolve(), (options.dataset, options.submissions, options.output))
|
| 170 |
+
options.blender_bin = render_agent.normalize_blender_path(getattr(options, "blender_bin", "blender"))
|
| 171 |
+
rows = load_tasks(dataset)
|
| 172 |
+
single_zip = submissions.suffix.lower() == ".zip" and not submissions.is_dir()
|
| 173 |
+
if single_zip and not options.task_id:
|
| 174 |
+
options.task_id = [submissions.stem]
|
| 175 |
+
if options.task_id:
|
| 176 |
+
requested = set(options.task_id)
|
| 177 |
+
rows = [r for r in rows if r["task_id"] in requested]
|
| 178 |
+
if {r["task_id"] for r in rows} != requested:
|
| 179 |
+
raise ValueError("Unknown task ID in selection")
|
| 180 |
+
if single_zip and len(rows) != 1:
|
| 181 |
+
raise ValueError("A single submission ZIP must select exactly one task")
|
| 182 |
+
if output == submissions or (submissions.is_dir() and output.is_relative_to(submissions)):
|
| 183 |
+
raise ValueError("Evaluation output must be outside the submissions directory")
|
| 184 |
+
archives = {r["task_id"]: submissions if single_zip else submissions / (r["task_id"] + ".zip") for r in rows}
|
| 185 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 186 |
+
# A run has one owner. A live owner must never be mistaken for a stopped run.
|
| 187 |
+
with (output / ".run.lock").open("a") as lock:
|
| 188 |
+
try:
|
| 189 |
+
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
| 190 |
+
except BlockingIOError as error:
|
| 191 |
+
raise RuntimeError("This run is already active") from error
|
| 192 |
+
plan = {"dataset_sha256": sha256(dataset / "dataset.jsonl"),
|
| 193 |
+
"rubrics_sha256": sha256(dataset / "rubrics.json"),
|
| 194 |
+
"code_sha256": {str(p.relative_to(Path(__file__).parent)): sha256(p)
|
| 195 |
+
for p in sorted(Path(__file__).parent.rglob("*.py"))},
|
| 196 |
+
"task_ids": [r["task_id"] for r in rows], "protocol": PROTOCOL,
|
| 197 |
+
"models": {"render": options.render_agent_model, "agent": options.agent_judge_model,
|
| 198 |
+
"vision": options.judge_model}, "submissions": str(submissions),
|
| 199 |
+
"endpoints": {"vision": getattr(options, "judge_api_endpoint", ""),
|
| 200 |
+
"agent": os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com")},
|
| 201 |
+
"blender_bin": getattr(options, "blender_bin", "blender"),
|
| 202 |
+
"submission_format": FORMAT, "runtime_requirements": requirements(),
|
| 203 |
+
"submission_hashes": {tid: sha256(path) if path.is_file() and not path.is_symlink() else None
|
| 204 |
+
for tid, path in archives.items()}}
|
| 205 |
+
plan_file = output / "plan.json"
|
| 206 |
+
if plan_file.exists():
|
| 207 |
+
if not options.resume:
|
| 208 |
+
raise ValueError("Run exists; use --resume or choose a new output directory")
|
| 209 |
+
if json.loads(plan_file.read_text()) != plan:
|
| 210 |
+
raise ValueError("Inputs, models, code, or protocol changed; start a new run")
|
| 211 |
+
else:
|
| 212 |
+
write_json(plan_file, plan)
|
| 213 |
+
if options.dry_run:
|
| 214 |
+
inventory, errors = {}, {}
|
| 215 |
+
for task_id, path in archives.items():
|
| 216 |
+
try:
|
| 217 |
+
inventory[task_id] = inspect_submission(path, task_id)
|
| 218 |
+
except (OSError, ValueError) as error:
|
| 219 |
+
errors[task_id] = str(error)
|
| 220 |
+
return {"dry_run": True, "tasks": len(rows), "plan": str(plan_file),
|
| 221 |
+
"missing_submissions": [tid for tid, path in archives.items() if not path.is_file()],
|
| 222 |
+
"submission_inventory": inventory, "submission_errors": errors}
|
| 223 |
+
runtime_checked = False
|
| 224 |
+
records = {}
|
| 225 |
+
for row in rows:
|
| 226 |
+
task_id = row["task_id"]
|
| 227 |
+
task_dir = output / "tasks" / task_id
|
| 228 |
+
outcome = task_dir / "result.json"
|
| 229 |
+
if outcome.exists():
|
| 230 |
+
records[task_id] = json.loads(outcome.read_text())
|
| 231 |
+
continue
|
| 232 |
+
if task_dir.exists():
|
| 233 |
+
# Preserve incomplete evidence; resume in a new attempt directory.
|
| 234 |
+
n = 1
|
| 235 |
+
while (output / "incomplete" / f"{task_id}.{n}").exists():
|
| 236 |
+
n += 1
|
| 237 |
+
saved = output / "incomplete" / f"{task_id}.{n}"
|
| 238 |
+
saved.parent.mkdir(parents=True, exist_ok=True)
|
| 239 |
+
task_dir.rename(saved)
|
| 240 |
+
print(f"Evaluating {task_id}", flush=True)
|
| 241 |
+
try:
|
| 242 |
+
submission = archives[task_id]
|
| 243 |
+
if not submission.is_file():
|
| 244 |
+
raise ValueError("Missing submission ZIP: " + task_id + ".zip")
|
| 245 |
+
if sha256(submission) != plan["submission_hashes"][task_id]:
|
| 246 |
+
raise ValueError("Submission ZIP changed after planning")
|
| 247 |
+
prepare_evaluation(dataset, row, submission, task_dir)
|
| 248 |
+
if not runtime_checked:
|
| 249 |
+
record_runtime(output, inspect_runtime(options.blender_bin))
|
| 250 |
+
runtime_checked = True
|
| 251 |
+
render_agent.run(row, task_dir, options.blender_bin, options.render_agent_model)
|
| 252 |
+
result = score_task(row, task_dir, options)
|
| 253 |
+
if sha256(submission) != plan["submission_hashes"][task_id]:
|
| 254 |
+
raise ValueError("Original submission ZIP changed during evaluation")
|
| 255 |
+
except RuntimeValidationError:
|
| 256 |
+
# A wrong evaluator runtime must not become 223 failed agent scores.
|
| 257 |
+
raise
|
| 258 |
+
except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
|
| 259 |
+
result = {"task_id": task_id, "modality": row["modality"], "ok": False,
|
| 260 |
+
"score": 0.0, "rubric_score": None, "dimension_score": None, "error": str(error)}
|
| 261 |
+
write_json(outcome, result)
|
| 262 |
+
records[task_id] = result
|
| 263 |
+
write_json(output / "summary.json", summarize(rows, records))
|
| 264 |
+
summary = summarize(rows, records)
|
| 265 |
+
write_json(output / "summary.json", summary)
|
| 266 |
+
with (output / "results.csv").open("w", newline="") as stream:
|
| 267 |
+
writer = csv.DictWriter(stream, fieldnames=["task_id", "modality", "ok", "score", "rubric_score", "dimension_score", "error"])
|
| 268 |
+
writer.writeheader()
|
| 269 |
+
writer.writerows(summary["results"])
|
| 270 |
+
return {k: v for k, v in summary.items() if k != "results"}
|
bw_0220/tests/blenderworld/evaluators/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Evidence-routed BlenderWorld judges."""
|
bw_0220/tests/blenderworld/evaluators/asset_paths.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Restore bundled image paths in memory when Blender opens an archived project.
|
| 2 |
+
|
| 3 |
+
The saved project is never rewritten. Ambiguous filenames remain unresolved;
|
| 4 |
+
an evaluator must not silently substitute another task's texture.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path, PurePosixPath
|
| 12 |
+
|
| 13 |
+
_handler = None
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def workspace_for(blend_path, root):
|
| 17 |
+
root = Path(root).resolve()
|
| 18 |
+
blend = Path(blend_path).resolve()
|
| 19 |
+
if not blend.is_relative_to(root):
|
| 20 |
+
return None
|
| 21 |
+
for parent in blend.parents:
|
| 22 |
+
if not parent.is_relative_to(root):
|
| 23 |
+
break
|
| 24 |
+
if parent.name == ".eval_workspace":
|
| 25 |
+
return parent
|
| 26 |
+
candidate = parent / ".eval_workspace"
|
| 27 |
+
if candidate.is_dir():
|
| 28 |
+
return candidate
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def find_asset(saved_path, workspace):
|
| 33 |
+
"""Prefer the longest matching archived suffix; never pick an ambiguous name."""
|
| 34 |
+
workspace = Path(workspace).resolve()
|
| 35 |
+
parts = PurePosixPath(str(saved_path).replace("\\", "/")).parts
|
| 36 |
+
if not parts or ".." in parts:
|
| 37 |
+
return None
|
| 38 |
+
files = [
|
| 39 |
+
p
|
| 40 |
+
for p in workspace.rglob(parts[-1])
|
| 41 |
+
if p.is_file() and p.resolve().is_relative_to(workspace)
|
| 42 |
+
]
|
| 43 |
+
# Glob metacharacters in a legitimate filename must not select another file.
|
| 44 |
+
files = [p for p in files if p.name == parts[-1]]
|
| 45 |
+
for count in range(len(parts), 0, -1):
|
| 46 |
+
suffix = parts[-count:]
|
| 47 |
+
matches = [p for p in files if p.relative_to(workspace).parts[-count:] == suffix]
|
| 48 |
+
if len(matches) == 1:
|
| 49 |
+
return matches[0]
|
| 50 |
+
if matches:
|
| 51 |
+
return None
|
| 52 |
+
return None
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def restore_images(bpy, root):
|
| 56 |
+
if not bpy.data.filepath:
|
| 57 |
+
return []
|
| 58 |
+
workspace = workspace_for(bpy.data.filepath, root)
|
| 59 |
+
if workspace is None:
|
| 60 |
+
return []
|
| 61 |
+
changes = []
|
| 62 |
+
for image in bpy.data.images:
|
| 63 |
+
if image.source != "FILE" or image.packed_file or not image.filepath:
|
| 64 |
+
continue
|
| 65 |
+
old = image.filepath
|
| 66 |
+
if Path(bpy.path.abspath(old, library=image.library)).is_file():
|
| 67 |
+
continue
|
| 68 |
+
replacement = find_asset(old, workspace)
|
| 69 |
+
if replacement is None:
|
| 70 |
+
changes.append({"action": "unresolved_image", "image": image.name, "path": old})
|
| 71 |
+
continue
|
| 72 |
+
image.filepath = str(replacement)
|
| 73 |
+
try:
|
| 74 |
+
image.reload()
|
| 75 |
+
if not all(image.size):
|
| 76 |
+
raise RuntimeError("image has no readable pixels")
|
| 77 |
+
except (RuntimeError, OSError, ValueError) as exc:
|
| 78 |
+
image.filepath = old
|
| 79 |
+
changes.append(
|
| 80 |
+
{
|
| 81 |
+
"action": "image_reload_failed",
|
| 82 |
+
"image": image.name,
|
| 83 |
+
"path": old,
|
| 84 |
+
"error": str(exc),
|
| 85 |
+
}
|
| 86 |
+
)
|
| 87 |
+
else:
|
| 88 |
+
changes.append(
|
| 89 |
+
{
|
| 90 |
+
"action": "restored_image",
|
| 91 |
+
"image": image.name,
|
| 92 |
+
"from": old,
|
| 93 |
+
"to": str(replacement),
|
| 94 |
+
}
|
| 95 |
+
)
|
| 96 |
+
return changes
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def compatible_denoising(scenes):
|
| 100 |
+
changes = []
|
| 101 |
+
for scene in scenes:
|
| 102 |
+
cycles = scene.cycles
|
| 103 |
+
if cycles.use_denoising and cycles.denoiser == "OPTIX":
|
| 104 |
+
# OptiX rendering can work even when its denoiser cannot initialize.
|
| 105 |
+
# OIDN on CPU preserves denoising without changing render samples.
|
| 106 |
+
cycles.denoiser = "OPENIMAGEDENOISE"
|
| 107 |
+
if hasattr(cycles, "denoising_use_gpu"):
|
| 108 |
+
cycles.denoising_use_gpu = False
|
| 109 |
+
changes.append(
|
| 110 |
+
{
|
| 111 |
+
"action": "denoiser_compatibility",
|
| 112 |
+
"scene": scene.name,
|
| 113 |
+
"from": "OPTIX",
|
| 114 |
+
"to": "OPENIMAGEDENOISE",
|
| 115 |
+
}
|
| 116 |
+
)
|
| 117 |
+
return changes
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def apply_runtime(bpy):
|
| 121 |
+
root = os.environ.get("BLENDER_EVAL_ASSET_ROOT")
|
| 122 |
+
if not root or not getattr(bpy.data, "filepath", ""):
|
| 123 |
+
return
|
| 124 |
+
if workspace_for(bpy.data.filepath, root) is None:
|
| 125 |
+
return
|
| 126 |
+
changes = restore_images(bpy, root) + compatible_denoising(bpy.data.scenes)
|
| 127 |
+
if not changes:
|
| 128 |
+
return
|
| 129 |
+
event = {"blend": bpy.data.filepath, "changes": changes}
|
| 130 |
+
line = json.dumps(event, ensure_ascii=False)
|
| 131 |
+
print("BLENDER_EVAL_RUNTIME " + line, flush=True)
|
| 132 |
+
audit = os.environ.get("BLENDER_EVAL_RUNTIME_AUDIT")
|
| 133 |
+
if audit:
|
| 134 |
+
with Path(audit).open("a", encoding="utf-8") as stream:
|
| 135 |
+
stream.write(line + "\n")
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def register():
|
| 139 |
+
import bpy
|
| 140 |
+
from bpy.app.handlers import persistent
|
| 141 |
+
|
| 142 |
+
global _handler
|
| 143 |
+
if _handler is not None:
|
| 144 |
+
return
|
| 145 |
+
|
| 146 |
+
@persistent
|
| 147 |
+
def on_load_or_render(*_args):
|
| 148 |
+
apply_runtime(bpy)
|
| 149 |
+
|
| 150 |
+
# Both hooks are needed: scripts may select another image or scene after load.
|
| 151 |
+
bpy.app.handlers.load_post.append(on_load_or_render)
|
| 152 |
+
bpy.app.handlers.render_pre.append(on_load_or_render)
|
| 153 |
+
_handler = on_load_or_render
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def unregister():
|
| 157 |
+
import bpy
|
| 158 |
+
|
| 159 |
+
global _handler
|
| 160 |
+
for handlers in (bpy.app.handlers.load_post, bpy.app.handlers.render_pre):
|
| 161 |
+
if _handler in handlers:
|
| 162 |
+
handlers.remove(_handler)
|
| 163 |
+
_handler = None
|
bw_0220/tests/blenderworld/evaluators/evidence_checks.py
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Read-only evidence helpers; no task IDs or verdict overrides.
|
| 3 |
+
|
| 4 |
+
Normal Python: --inventory-root <materialized submission> --output <json>
|
| 5 |
+
Blender: open the original with --disable-autoexec, then --python this_file --
|
| 6 |
+
--output <json> [--uv-layer <name>]. No scene is saved or rendered.
|
| 7 |
+
"""
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
import argparse
|
| 10 |
+
import hashlib
|
| 11 |
+
import json
|
| 12 |
+
import math
|
| 13 |
+
import re
|
| 14 |
+
import struct
|
| 15 |
+
import sys
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def cli_event_content_refusal(event):
|
| 20 |
+
"""Recognize provider errors, never a prompt merely mentioning filtering."""
|
| 21 |
+
if not isinstance(event, dict):
|
| 22 |
+
return False
|
| 23 |
+
kind = event.get('type')
|
| 24 |
+
status = event.get('api_error_status')
|
| 25 |
+
if kind == 'result' and event.get('is_error') is True:
|
| 26 |
+
text = str(event.get('result', ''))
|
| 27 |
+
elif kind == 'assistant' and event.get('error'):
|
| 28 |
+
message = event.get('message', {})
|
| 29 |
+
content = message.get('content', []) if isinstance(message, dict) else []
|
| 30 |
+
text = '\n'.join(str(block.get('text', '')) for block in content
|
| 31 |
+
if isinstance(block, dict) and block.get('type') == 'text')
|
| 32 |
+
elif kind == 'system' and event.get('subtype') == 'api_error':
|
| 33 |
+
error = event.get('error', {})
|
| 34 |
+
if not isinstance(error, dict):
|
| 35 |
+
return False
|
| 36 |
+
status = error.get('status', error.get('status_code', status))
|
| 37 |
+
text = str(error.get('message', ''))
|
| 38 |
+
elif kind == 'system' and event.get('subtype') in {'task_updated', 'task_notification'}:
|
| 39 |
+
details = event.get('patch', {}) if event['subtype'] == 'task_updated' else event
|
| 40 |
+
if not isinstance(details, dict) or details.get('status') != 'failed':
|
| 41 |
+
return False
|
| 42 |
+
text = str(details.get('error', details.get('summary', '')))
|
| 43 |
+
prefix = 'Agent terminated early due to an API error: '
|
| 44 |
+
if not text.startswith(prefix):
|
| 45 |
+
return False
|
| 46 |
+
text = text[len(prefix):]
|
| 47 |
+
elif kind == 'user' and isinstance(event.get('tool_use_result'), str):
|
| 48 |
+
# Claude Code emits this metadata for failed child tasks, alongside
|
| 49 |
+
# system task notifications. Ordinary user messages have no such field.
|
| 50 |
+
prefix = 'Error: Agent terminated early due to an API error: '
|
| 51 |
+
if not event['tool_use_result'].startswith(prefix):
|
| 52 |
+
return False
|
| 53 |
+
content = event.get('message', {}).get('content', [])
|
| 54 |
+
if not isinstance(content, list) or not any(
|
| 55 |
+
isinstance(block, dict) and block.get('type') == 'tool_result'
|
| 56 |
+
and block.get('is_error') is True for block in content
|
| 57 |
+
):
|
| 58 |
+
return False
|
| 59 |
+
text = event['tool_use_result'][len(prefix):]
|
| 60 |
+
else:
|
| 61 |
+
return False
|
| 62 |
+
return bool(
|
| 63 |
+
(status == 400 or re.match(r'\s*API Error:\s*400\b', text))
|
| 64 |
+
and re.search(r'\b(?:content_policy_violation|content_filter)\b', text)
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def cli_log_status(path):
|
| 69 |
+
"""Inspect every CLI event, including child errors before parent success."""
|
| 70 |
+
terminal, refused = None, False
|
| 71 |
+
for line in Path(path).read_text(encoding='utf-8', errors='replace').splitlines():
|
| 72 |
+
try:
|
| 73 |
+
event = json.loads(line)
|
| 74 |
+
except ValueError:
|
| 75 |
+
continue
|
| 76 |
+
refused = refused or cli_event_content_refusal(event)
|
| 77 |
+
if isinstance(event, dict) and event.get('type') == 'result':
|
| 78 |
+
terminal = event
|
| 79 |
+
return terminal, refused
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def png_metadata(path):
|
| 83 |
+
with Path(path).open('rb') as f:
|
| 84 |
+
header = f.read(33)
|
| 85 |
+
if len(header) != 33 or header[:8] != b'\x89PNG\r\n\x1a\n' or header[12:16] != b'IHDR':
|
| 86 |
+
raise ValueError('Invalid PNG IHDR')
|
| 87 |
+
width, height, bits, color = struct.unpack('>IIBB', header[16:26])
|
| 88 |
+
result = {'format': 'PNG', 'width': width, 'height': height,
|
| 89 |
+
'bits_per_channel': bits, 'png_color_type': color,
|
| 90 |
+
'has_alpha_channel': color in (4, 6)}
|
| 91 |
+
if color in (4, 6):
|
| 92 |
+
try:
|
| 93 |
+
from PIL import Image
|
| 94 |
+
with Image.open(path) as image:
|
| 95 |
+
# Pillow downconverts RGB(A)16 for display; alpha extrema here are
|
| 96 |
+
# display-scale values, NOT a claim about native file bit depth.
|
| 97 |
+
alpha = image.convert('RGBA').getchannel('A')
|
| 98 |
+
lo, hi = alpha.getextrema()
|
| 99 |
+
result['alpha_display_range_0_255'] = [lo, hi]
|
| 100 |
+
result['has_visible_transparency'] = lo < 255
|
| 101 |
+
except (ImportError, OSError, ValueError) as exc:
|
| 102 |
+
result['alpha_probe_error'] = type(exc).__name__
|
| 103 |
+
return result
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def file_inventory(root):
|
| 107 |
+
root = Path(root).resolve()
|
| 108 |
+
rows = []
|
| 109 |
+
for folder in ('exports', 'output'):
|
| 110 |
+
base = root / folder
|
| 111 |
+
if not base.is_dir():
|
| 112 |
+
continue
|
| 113 |
+
for path in sorted(base.rglob('*')):
|
| 114 |
+
if not path.is_file() or not path.resolve().is_relative_to(root):
|
| 115 |
+
continue
|
| 116 |
+
row = {'path': str(path.relative_to(root)), 'bytes': path.stat().st_size,
|
| 117 |
+
'provenance': 'author_submission', 'suffix': path.suffix.lower()}
|
| 118 |
+
try:
|
| 119 |
+
if path.suffix.lower() == '.png':
|
| 120 |
+
row.update(png_metadata(path))
|
| 121 |
+
elif path.suffix.lower() in ('.jpg', '.jpeg', '.webp'):
|
| 122 |
+
from PIL import Image
|
| 123 |
+
with Image.open(path) as im:
|
| 124 |
+
row.update(format=im.format, width=im.width, height=im.height)
|
| 125 |
+
except (ImportError, OSError, ValueError) as exc:
|
| 126 |
+
row['metadata_error'] = type(exc).__name__
|
| 127 |
+
rows.append(row)
|
| 128 |
+
return {'root': str(root), 'provenance': 'original files materialized from workspace_snapshot',
|
| 129 |
+
'file_count': len(rows), 'files': rows,
|
| 130 |
+
'note': 'Includes auxiliary textures and previews. Presence alone does not identify the final deliverable.'}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def polygon_area(points):
|
| 134 |
+
if len(points) < 3:
|
| 135 |
+
return 0.0
|
| 136 |
+
return abs(sum(a[0]*b[1]-b[0]*a[1] for a,b in zip(points, points[1:]+points[:1]))) * .5
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def triangle_intersection_area(subject, triangle):
|
| 140 |
+
def cross(a,b,c):
|
| 141 |
+
return (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])
|
| 142 |
+
if cross(*triangle) < 0:
|
| 143 |
+
triangle = triangle[::-1]
|
| 144 |
+
output = list(subject)
|
| 145 |
+
for a,b in zip(triangle, triangle[1:]+triangle[:1]):
|
| 146 |
+
source, output = output, []
|
| 147 |
+
if not source:
|
| 148 |
+
break
|
| 149 |
+
prev = source[-1]; dp = cross(a,b,prev)
|
| 150 |
+
for cur in source:
|
| 151 |
+
dc = cross(a,b,cur)
|
| 152 |
+
if (dp >= 0) != (dc >= 0):
|
| 153 |
+
t = dp/(dp-dc)
|
| 154 |
+
output.append((prev[0]+t*(cur[0]-prev[0]), prev[1]+t*(cur[1]-prev[1])))
|
| 155 |
+
if dc >= 0:
|
| 156 |
+
output.append(cur)
|
| 157 |
+
prev, dp = cur, dc
|
| 158 |
+
return polygon_area(output)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def find_uv_overlap(triangles, max_pairs=2_000_000):
|
| 162 |
+
"""Positive-area overlap within one mesh; shared edges do not count.
|
| 163 |
+
|
| 164 |
+
A bounded sweep returns incomplete/unknown when its budget is exhausted;
|
| 165 |
+
an incomplete scan must never be used to assert no overlap.
|
| 166 |
+
"""
|
| 167 |
+
boxes = []
|
| 168 |
+
degenerate = 0
|
| 169 |
+
for i,t in enumerate(triangles):
|
| 170 |
+
if polygon_area(t) <= 1e-12:
|
| 171 |
+
degenerate += 1
|
| 172 |
+
continue
|
| 173 |
+
boxes.append((min(p[0] for p in t), max(p[0] for p in t),
|
| 174 |
+
min(p[1] for p in t), max(p[1] for p in t), i))
|
| 175 |
+
boxes.sort()
|
| 176 |
+
active = []; checked = 0
|
| 177 |
+
for box in boxes:
|
| 178 |
+
xmin,xmax,ymin,ymax,i = box
|
| 179 |
+
active = [b for b in active if b[1] > xmin]
|
| 180 |
+
for b in active:
|
| 181 |
+
checked += 1
|
| 182 |
+
if checked > max_pairs:
|
| 183 |
+
return {'complete': False, 'overlap': None, 'pairs_checked': checked-1,
|
| 184 |
+
'reason': 'candidate pair budget exceeded', 'degenerate_triangles': degenerate}
|
| 185 |
+
if b[3] <= ymin or ymax <= b[2]:
|
| 186 |
+
continue
|
| 187 |
+
area = triangle_intersection_area(triangles[b[4]], triangles[i])
|
| 188 |
+
if area > 1e-10:
|
| 189 |
+
return {'complete': True, 'overlap': True, 'triangle_indices': [b[4],i],
|
| 190 |
+
'intersection_area': area, 'pairs_checked': checked,
|
| 191 |
+
'degenerate_triangles': degenerate}
|
| 192 |
+
active.append(box)
|
| 193 |
+
return {'complete': True, 'overlap': False, 'pairs_checked': checked,
|
| 194 |
+
'degenerate_triangles': degenerate}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def scene_facts(uv_layer=None):
|
| 198 |
+
import bpy
|
| 199 |
+
from mathutils import Vector
|
| 200 |
+
scene = bpy.context.scene
|
| 201 |
+
fps = scene.render.fps / scene.render.fps_base
|
| 202 |
+
result = {'blender_version': bpy.app.version_string, 'blend_file': bpy.data.filepath,
|
| 203 |
+
'engine': scene.render.engine, 'effective_fps': fps, 'cameras': []}
|
| 204 |
+
world = scene.rigidbody_world
|
| 205 |
+
if world:
|
| 206 |
+
result['rigid_body_world'] = {
|
| 207 |
+
'substeps_per_frame': world.substeps_per_frame,
|
| 208 |
+
'steps_per_second_at_scene_fps': world.substeps_per_frame * fps,
|
| 209 |
+
'solver_iterations': world.solver_iterations, 'time_scale': world.time_scale}
|
| 210 |
+
for camera in (o for o in scene.objects if o.type == 'CAMERA'):
|
| 211 |
+
direction = camera.matrix_world.to_quaternion() @ Vector((0,0,-1))
|
| 212 |
+
result['cameras'].append({'name': camera.name, 'active': camera == scene.camera,
|
| 213 |
+
'world_z': camera.matrix_world.translation.z,
|
| 214 |
+
'look_direction_world': list(direction),
|
| 215 |
+
'down_pitch_from_horizontal_degrees': math.degrees(math.atan2(-direction.z, math.hypot(direction.x,direction.y))),
|
| 216 |
+
'lens_mm': camera.data.lens, 'dof_enabled': camera.data.dof.use_dof,
|
| 217 |
+
'fstop': camera.data.dof.aperture_fstop})
|
| 218 |
+
if uv_layer:
|
| 219 |
+
result['uv_checks'] = []
|
| 220 |
+
for obj in scene.objects:
|
| 221 |
+
if obj.type != 'MESH':
|
| 222 |
+
continue
|
| 223 |
+
mesh = obj.data
|
| 224 |
+
row = {'object': obj.name, 'collections': [c.name for c in obj.users_collection],
|
| 225 |
+
'hide_render': obj.hide_render, 'layer': uv_layer}
|
| 226 |
+
uv = mesh.uv_layers.get(uv_layer)
|
| 227 |
+
if uv is None:
|
| 228 |
+
row.update(layer_present=False)
|
| 229 |
+
else:
|
| 230 |
+
mesh.calc_loop_triangles()
|
| 231 |
+
triangles = [[tuple(uv.data[i].uv) for i in t.loops] for t in mesh.loop_triangles]
|
| 232 |
+
row.update(layer_present=True, triangle_count=len(triangles), **find_uv_overlap(triangles))
|
| 233 |
+
result['uv_checks'].append(row)
|
| 234 |
+
return result
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def main():
|
| 238 |
+
parser = argparse.ArgumentParser()
|
| 239 |
+
parser.add_argument('--inventory-root')
|
| 240 |
+
parser.add_argument('--output', required=True)
|
| 241 |
+
parser.add_argument('--uv-layer')
|
| 242 |
+
argv = sys.argv[sys.argv.index('--')+1:] if '--' in sys.argv else sys.argv[1:]
|
| 243 |
+
args = parser.parse_args(argv)
|
| 244 |
+
data = file_inventory(args.inventory_root) if args.inventory_root else scene_facts(args.uv_layer)
|
| 245 |
+
dest = Path(args.output); dest.parent.mkdir(parents=True, exist_ok=True)
|
| 246 |
+
dest.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding='utf-8')
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
if __name__ == '__main__':
|
| 250 |
+
main()
|
bw_0220/tests/blenderworld/evaluators/judge_blender_agent.py
ADDED
|
@@ -0,0 +1,878 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""Agent-as-Judge for Blender trajectory eval (runs in parallel with the GPT-5.6-terra vision judge).
|
| 4 |
+
|
| 5 |
+
Unlike ``judge_blender_binary_rubrics.py`` (a pure-vision pass that can only score what a
|
| 6 |
+
static render shows), this judge spawns a coding agent per task -- by default the same
|
| 7 |
+
GPT-5.6-terra model the render agent already uses, via the ``claude`` CLI pointed at the
|
| 8 |
+
configured Anthropic-compatible endpoint -- that can OPEN THE SUBMITTED ``.blend`` WITH ``bpy``.
|
| 9 |
+
This lets it verify rubrics whose ``evidence_type`` is ``scene_summary`` / ``either``
|
| 10 |
+
(shape keys, drivers, Geometry-Nodes params, triangle budgets, UV layout, material node
|
| 11 |
+
graphs, ``scene.unit_settings`` / ``render.engine`` / ``cycles.samples``, exact mm
|
| 12 |
+
dimensions, physics setup) that the vision judge structurally cannot check, while still
|
| 13 |
+
using the rendered PNGs for ``render``-type (visual) rubrics.
|
| 14 |
+
|
| 15 |
+
The agent emits, per rubric, two cross-check sub-verdicts (``bpy_check`` for the .blend internals
|
| 16 |
+
and ``visual_check`` for its own renders, each pass/fail/na) + method + evidence, and per dimension a
|
| 17 |
+
1-10 impression plus a ``render_conflict`` flag. ALL scoring arithmetic (weighted rubric pass-rate,
|
| 18 |
+
dimension score, the ``0.5*dim + 0.5*rubric`` fusion, and the uncapped fusion) is done here
|
| 19 |
+
in Python, reusing the exact helpers from ``judge_blender_binary_rubrics.py``. Two worst-of-both
|
| 20 |
+
rules make the visible render authoritative: a rubric passes only if EVERY applicable sub-verdict
|
| 21 |
+
passes (so a correct bpy value cannot rescue a wrong-looking render), and any dimension the agent
|
| 22 |
+
flags with ``render_conflict`` is clamped into the low band. Both are backward-compatible (agent
|
| 23 |
+
outputs lacking the new fields score exactly as before) and can be disabled via CLI. The top-level
|
| 24 |
+
per-task ``judgement.json`` and batch schema stay IDENTICAL to the vision judge (the new fields are
|
| 25 |
+
additive inside each ``rubric_scores``/``dimension_scores`` entry; the final per-rubric ``score`` is
|
| 26 |
+
still integer 0/1), so the Stage-7 aggregate in ``main.sh`` and downstream comparisons are unchanged.
|
| 27 |
+
|
| 28 |
+
Audit trail: the agent is required to persist ``agent_bpy_dump.json`` (the bpy query script
|
| 29 |
+
+ its raw output) and ``agent_judgement_raw.json`` next to the judgement, so every
|
| 30 |
+
scene-metadata verdict is checkable after the fact.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
from __future__ import annotations
|
| 34 |
+
|
| 35 |
+
import argparse
|
| 36 |
+
import json
|
| 37 |
+
import os
|
| 38 |
+
import subprocess
|
| 39 |
+
import sys
|
| 40 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 41 |
+
from datetime import datetime, timezone
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
from typing import Any
|
| 44 |
+
|
| 45 |
+
# Reuse the vision judge's pure, model-agnostic helpers so the output schema and scoring
|
| 46 |
+
# math stay bit-for-bit consistent between the two judges.
|
| 47 |
+
from . import judge_blender_binary_rubrics as vj
|
| 48 |
+
from . import evidence_checks
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
from json_repair import repair_json
|
| 52 |
+
except Exception: # noqa: BLE001
|
| 53 |
+
def repair_json(s: str) -> str:
|
| 54 |
+
return s
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
DEFAULT_OUTPUT_DIR = "evaluation/agent_judge_multiview_eval"
|
| 58 |
+
DEFAULT_IMAGE_GLOB = "evaluation/multiview/*.png"
|
| 59 |
+
RAW_NAME = "agent_judgement_raw.json"
|
| 60 |
+
BPY_DUMP_NAME = "agent_bpy_dump.json"
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
# --------------------------------------------------------------------------------------
|
| 64 |
+
# Agent output parsing
|
| 65 |
+
# --------------------------------------------------------------------------------------
|
| 66 |
+
def cli_api_error(path: Path) -> str:
|
| 67 |
+
"""Read the CLI's terminal API failure before attempting JSON output repair."""
|
| 68 |
+
if not path.exists():
|
| 69 |
+
return ""
|
| 70 |
+
event, refused = evidence_checks.cli_log_status(path)
|
| 71 |
+
if refused:
|
| 72 |
+
return "agent_judge_upstream_content_policy_violation"
|
| 73 |
+
if event:
|
| 74 |
+
status = event.get("api_error_status")
|
| 75 |
+
if event.get("is_error") is True and status:
|
| 76 |
+
return f"agent judge API error {status}"
|
| 77 |
+
return ""
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _coerce_binary(value: Any) -> int | None:
|
| 81 |
+
if value in (0, "0", "0.0", False):
|
| 82 |
+
return 0
|
| 83 |
+
if value in (1, "1", "1.0", True):
|
| 84 |
+
return 1
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _coerce_check(value: Any) -> str:
|
| 89 |
+
"""Normalize a per-rubric sub-verdict to ``pass`` / ``fail`` / ``na``.
|
| 90 |
+
|
| 91 |
+
Missing or unrecognized values collapse to ``na`` (not applicable), which makes the
|
| 92 |
+
cross-check enforcement a no-op for that source and lets old outputs (with no ``bpy_check`` /
|
| 93 |
+
``visual_check`` keys) fall back to the model's self-reported ``score`` unchanged."""
|
| 94 |
+
if value is None:
|
| 95 |
+
return "na"
|
| 96 |
+
s = str(value).strip().lower()
|
| 97 |
+
if s in ("pass", "passed", "ok", "yes", "true", "1", "1.0"):
|
| 98 |
+
return "pass"
|
| 99 |
+
if s in ("fail", "failed", "no", "false", "0", "0.0"):
|
| 100 |
+
return "fail"
|
| 101 |
+
return "na" # na / n/a / not_applicable / unknown / "" / anything else
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _truthy(value: Any) -> bool:
|
| 105 |
+
"""Loose truthiness for a model-emitted boolean flag (accepts true/1/yes/'true'...)."""
|
| 106 |
+
if isinstance(value, bool):
|
| 107 |
+
return value
|
| 108 |
+
if value is None:
|
| 109 |
+
return False
|
| 110 |
+
if isinstance(value, (int, float)):
|
| 111 |
+
return value != 0
|
| 112 |
+
return str(value).strip().lower() in ("true", "1", "1.0", "yes", "y")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def normalize_agent_rubrics(
|
| 116 |
+
obj: dict[str, Any] | None,
|
| 117 |
+
rubrics: list[dict[str, Any]],
|
| 118 |
+
*,
|
| 119 |
+
enforce_cross_check: bool = True,
|
| 120 |
+
) -> tuple[bool, list[dict[str, Any]], str]:
|
| 121 |
+
"""Map the agent's per-rubric verdicts onto the canonical rubric_scores shape.
|
| 122 |
+
|
| 123 |
+
Mirrors ``vj.normalize_scores`` (id/score/evidence/source_views/confidence) and adds a
|
| 124 |
+
``method`` field (bpy|visual). Returns (ok, scores, error); ok is False if any rubric id
|
| 125 |
+
is unanswered (build_score_summary still counts those as 0, matching the vision judge).
|
| 126 |
+
|
| 127 |
+
Cross-check enforcement (``enforce_cross_check``, default True): each verdict may carry two
|
| 128 |
+
sub-verdicts, ``bpy_check`` (does the requirement hold in the .blend internals) and
|
| 129 |
+
``visual_check`` (does it hold in the agent's own renders), each ``pass``/``fail``/``na``. The
|
| 130 |
+
final ``score`` is derived as 1 iff EVERY applicable (non-``na``) sub-verdict passes -- so a
|
| 131 |
+
correct bpy value can never rescue a rubric whose render contradicts it (and vice-versa). When
|
| 132 |
+
neither sub-verdict applies (both ``na``, or the keys are absent), we fall back to the model's
|
| 133 |
+
self-reported ``score`` -- keeping old agent outputs bit-for-bit identical. The final ``score``
|
| 134 |
+
stays an integer 0/1 (relied on by ``vj.build_score_summary`` / ``vj.is_complete_judgement``);
|
| 135 |
+
the sub-verdicts + ``model_score`` + ``cross_check_applied`` are stored as an audit trail."""
|
| 136 |
+
if not obj:
|
| 137 |
+
return False, [], "agent output was not valid JSON"
|
| 138 |
+
raw_scores = obj.get("rubric_scores")
|
| 139 |
+
if not isinstance(raw_scores, list):
|
| 140 |
+
return False, [], "missing rubric_scores list"
|
| 141 |
+
|
| 142 |
+
by_id: dict[str, dict[str, Any]] = {}
|
| 143 |
+
for item in raw_scores:
|
| 144 |
+
if not isinstance(item, dict):
|
| 145 |
+
continue
|
| 146 |
+
rid = str(item.get("id", "")).strip()
|
| 147 |
+
if not rid:
|
| 148 |
+
continue
|
| 149 |
+
model_score = _coerce_binary(item.get("score"))
|
| 150 |
+
bpy_check = _coerce_check(item.get("bpy_check"))
|
| 151 |
+
visual_check = _coerce_check(item.get("visual_check"))
|
| 152 |
+
applicable = [c for c in (bpy_check, visual_check) if c in ("pass", "fail")]
|
| 153 |
+
if enforce_cross_check and applicable:
|
| 154 |
+
score = 1 if all(c == "pass" for c in applicable) else 0
|
| 155 |
+
else:
|
| 156 |
+
score = model_score
|
| 157 |
+
if score is None:
|
| 158 |
+
# No usable verdict (no valid score AND no applicable sub-check) -> treat as missing,
|
| 159 |
+
# matching the pre-existing "score is None -> skip" behavior.
|
| 160 |
+
continue
|
| 161 |
+
by_id[rid] = {
|
| 162 |
+
"id": rid,
|
| 163 |
+
"score": score,
|
| 164 |
+
"evidence": str(item.get("evidence", "")).strip(),
|
| 165 |
+
"method": str(item.get("method", "")).strip() or "unknown",
|
| 166 |
+
"bpy_check": bpy_check,
|
| 167 |
+
"visual_check": visual_check,
|
| 168 |
+
"model_score": model_score,
|
| 169 |
+
"cross_check_applied": bool(applicable) and model_score is not None and score != model_score,
|
| 170 |
+
"source_views": item.get("source_views") if isinstance(item.get("source_views"), list) else [],
|
| 171 |
+
"confidence": str(item.get("confidence", "medium")).strip() or "medium",
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
normalized: list[dict[str, Any]] = []
|
| 175 |
+
missing: list[str] = []
|
| 176 |
+
for rubric in rubrics:
|
| 177 |
+
rid = str(rubric.get("id", "")).strip()
|
| 178 |
+
if rid in by_id:
|
| 179 |
+
normalized.append(by_id[rid])
|
| 180 |
+
else:
|
| 181 |
+
missing.append(rid)
|
| 182 |
+
if missing:
|
| 183 |
+
return False, normalized, f"missing scores for ids: {missing[:10]}"
|
| 184 |
+
return True, normalized, ""
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def finalize_judgement(
|
| 188 |
+
task_dir: Path,
|
| 189 |
+
rubrics: list[dict[str, Any]],
|
| 190 |
+
raw_obj: dict[str, Any] | None,
|
| 191 |
+
cfg: dict[str, Any],
|
| 192 |
+
*,
|
| 193 |
+
render_images: list[Path] | None = None,
|
| 194 |
+
extra_images: list[Path] | None = None,
|
| 195 |
+
reference_images: list[Path] | None = None,
|
| 196 |
+
extra_meta: dict[str, Any] | None = None,
|
| 197 |
+
) -> dict[str, Any]:
|
| 198 |
+
"""Compute the canonical judgement object from the agent's raw verdicts.
|
| 199 |
+
|
| 200 |
+
Pure/deterministic given ``raw_obj``: reuses ``vj.build_score_summary`` /
|
| 201 |
+
``vj.score_dimensions`` and the same uncapped fusion logic as the vision judge
|
| 202 |
+
(``judge_blender_binary_rubrics.py`` ~1636-1662). Unit-testable without spawning an agent."""
|
| 203 |
+
render_images = render_images or []
|
| 204 |
+
extra_images = extra_images or []
|
| 205 |
+
reference_images = reference_images or []
|
| 206 |
+
images = render_images + extra_images
|
| 207 |
+
|
| 208 |
+
ok, scores, error = normalize_agent_rubrics(
|
| 209 |
+
raw_obj, rubrics, enforce_cross_check=bool(cfg.get("cross_check", True))
|
| 210 |
+
)
|
| 211 |
+
total = sum(item["score"] for item in scores)
|
| 212 |
+
max_score = len(rubrics)
|
| 213 |
+
score_summary = vj.build_score_summary(rubrics, scores)
|
| 214 |
+
|
| 215 |
+
rubric_score_0_100 = score_summary["weighted_score_0_100"]
|
| 216 |
+
dim_result = vj.score_dimensions(raw_obj, vj.DIMENSIONS) if cfg.get("dimension_pass", True) else None
|
| 217 |
+
if cfg.get("dimension_pass", True) and (not dim_result or not dim_result["ok"]):
|
| 218 |
+
ok = False
|
| 219 |
+
error = "; ".join(x for x in [error, "dimension judge failed"] if x)
|
| 220 |
+
|
| 221 |
+
# Worst-of-both for the 1-10 dimensions: if the agent flagged a dimension's .blend internals as
|
| 222 |
+
# looking correct/better than what its renders actually show (`render_conflict`), the visible
|
| 223 |
+
# result governs -- clamp that dimension into the low band. This mirrors the rubric cross-check
|
| 224 |
+
# and runs before score fusion. The routed public protocol uses the VLM for dimensions.
|
| 225 |
+
dim_conflict_cap = cfg.get("dimension_conflict_cap")
|
| 226 |
+
if dim_result and dim_result.get("ok") and dim_conflict_cap is not None:
|
| 227 |
+
raw_dims = (raw_obj or {}).get("dimensions")
|
| 228 |
+
conflict_ids = {
|
| 229 |
+
str(d.get("id", "")).strip()
|
| 230 |
+
for d in (raw_dims if isinstance(raw_dims, list) else [])
|
| 231 |
+
if isinstance(d, dict) and _truthy(d.get("render_conflict"))
|
| 232 |
+
}
|
| 233 |
+
conflict_ids.discard("")
|
| 234 |
+
capped_any = False
|
| 235 |
+
for row in dim_result.get("dimension_scores", []):
|
| 236 |
+
if str(row.get("id", "")).strip() in conflict_ids:
|
| 237 |
+
row["render_conflict"] = True
|
| 238 |
+
if int(row.get("score", 0)) > dim_conflict_cap:
|
| 239 |
+
row["original_score"] = row.get("score")
|
| 240 |
+
row["score"] = dim_conflict_cap
|
| 241 |
+
issues = row.get("issues")
|
| 242 |
+
if not isinstance(issues, list):
|
| 243 |
+
issues = []
|
| 244 |
+
issues.append(
|
| 245 |
+
f"render conflicts with .blend internals; capped to <= {dim_conflict_cap}"
|
| 246 |
+
)
|
| 247 |
+
row["issues"] = issues
|
| 248 |
+
capped_any = True
|
| 249 |
+
if capped_any:
|
| 250 |
+
denom = 10 * len(vj.DIMENSIONS)
|
| 251 |
+
total_dim = sum(int(r.get("score", 0)) for r in dim_result["dimension_scores"])
|
| 252 |
+
dim_result["dimension_score_0_100"] = (100.0 * total_dim / denom) if denom else 0.0
|
| 253 |
+
|
| 254 |
+
w = float(cfg.get("dimension_weight", 0.5))
|
| 255 |
+
if dim_result and dim_result["ok"]:
|
| 256 |
+
dimension_score_0_100 = dim_result["dimension_score_0_100"]
|
| 257 |
+
fused_score_0_100 = w * dimension_score_0_100 + (1.0 - w) * rubric_score_0_100
|
| 258 |
+
else:
|
| 259 |
+
dimension_score_0_100 = None
|
| 260 |
+
fused_score_0_100 = rubric_score_0_100 # fall back to rubric-only
|
| 261 |
+
|
| 262 |
+
cap_applied = False
|
| 263 |
+
cap_reason = ""
|
| 264 |
+
|
| 265 |
+
obj: dict[str, Any] = {
|
| 266 |
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
| 267 |
+
"task_dir": str(task_dir),
|
| 268 |
+
"judge_kind": "agent",
|
| 269 |
+
"model": cfg.get("model", ""),
|
| 270 |
+
"reference_image_files": [vj.rel(p, task_dir) for p in reference_images],
|
| 271 |
+
"image_files": [vj.rel(p, task_dir) for p in images],
|
| 272 |
+
"rendered_image_files": [vj.rel(p, task_dir) for p in render_images],
|
| 273 |
+
"extra_image_files": [vj.rel(p, task_dir) for p in extra_images],
|
| 274 |
+
"rubric_count": len(rubrics),
|
| 275 |
+
"score": total,
|
| 276 |
+
"max_score": max_score,
|
| 277 |
+
"normalized_score": (total / max_score) if max_score else 0.0,
|
| 278 |
+
"raw_pass": score_summary["raw_pass"],
|
| 279 |
+
"raw_total": score_summary["raw_total"],
|
| 280 |
+
"raw_score_0_100": score_summary["raw_score_0_100"],
|
| 281 |
+
"weighted_pass": score_summary["weighted_pass"],
|
| 282 |
+
"weighted_total": score_summary["weighted_total"],
|
| 283 |
+
"weighted_score_0_100": score_summary["weighted_score_0_100"],
|
| 284 |
+
"score_summary": score_summary,
|
| 285 |
+
"passed_count": total,
|
| 286 |
+
"failed_count": max_score - total,
|
| 287 |
+
"rubric_scores": scores,
|
| 288 |
+
"overall_notes": str((raw_obj or {}).get("overall_notes", "")).strip(),
|
| 289 |
+
# the agent judge does not run a separate blind pass
|
| 290 |
+
"blind_pass": False,
|
| 291 |
+
"blind_description": None,
|
| 292 |
+
"blind_reference_description": None,
|
| 293 |
+
"rubric_batch_size": 0,
|
| 294 |
+
"rubric_chunk_count": 1,
|
| 295 |
+
# --- holistic dimension scoring + fusion ---
|
| 296 |
+
"dimension_pass": bool(cfg.get("dimension_pass", True)),
|
| 297 |
+
"dimension_weight": w,
|
| 298 |
+
"rubric_score_0_100": rubric_score_0_100,
|
| 299 |
+
"dimension_score_0_100": dimension_score_0_100,
|
| 300 |
+
"fused_score_0_100": fused_score_0_100,
|
| 301 |
+
"cap_applied": cap_applied,
|
| 302 |
+
"cap_reason": cap_reason,
|
| 303 |
+
"dimension_scores": (dim_result or {}).get("dimension_scores", []),
|
| 304 |
+
"core_objects_recognizable": (dim_result or {}).get("core_objects_recognizable"),
|
| 305 |
+
"catastrophic_failure": (dim_result or {}).get("catastrophic_failure"),
|
| 306 |
+
"dimension_missing": (dim_result or {}).get("missing_dimensions", []),
|
| 307 |
+
"dimension_notes": str((raw_obj or {}).get("dimension_notes", (raw_obj or {}).get("overall_notes", ""))).strip(),
|
| 308 |
+
"ok": ok,
|
| 309 |
+
}
|
| 310 |
+
if dim_result and not dim_result["ok"]:
|
| 311 |
+
obj["dimension_error"] = dim_result.get("error", "")
|
| 312 |
+
if not ok:
|
| 313 |
+
obj["error"] = error
|
| 314 |
+
if extra_meta:
|
| 315 |
+
obj.update(extra_meta)
|
| 316 |
+
if obj.get("agent_error"):
|
| 317 |
+
obj["ok"] = False
|
| 318 |
+
obj["error"] = obj["agent_error"]
|
| 319 |
+
return obj
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
# --------------------------------------------------------------------------------------
|
| 323 |
+
# Agent prompt + invocation
|
| 324 |
+
# --------------------------------------------------------------------------------------
|
| 325 |
+
def render_rubrics_for_agent(rubrics: list[dict[str, Any]]) -> str:
|
| 326 |
+
lines = []
|
| 327 |
+
for item in rubrics:
|
| 328 |
+
lines.append(
|
| 329 |
+
json.dumps(
|
| 330 |
+
{
|
| 331 |
+
"id": item.get("id"),
|
| 332 |
+
"category": item.get("category") or item.get("category_v2"),
|
| 333 |
+
"evidence_type": item.get("evidence_type"),
|
| 334 |
+
"criterion": item.get("criterion"),
|
| 335 |
+
"pass_condition": item.get("pass_condition"),
|
| 336 |
+
"fail_condition": item.get("fail_condition"),
|
| 337 |
+
},
|
| 338 |
+
ensure_ascii=False,
|
| 339 |
+
)
|
| 340 |
+
)
|
| 341 |
+
return "\n".join(lines)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def build_prompt(
|
| 345 |
+
task_dir: Path,
|
| 346 |
+
prompt_text: str,
|
| 347 |
+
rubrics: list[dict[str, Any]],
|
| 348 |
+
*,
|
| 349 |
+
blend_files: list[Path],
|
| 350 |
+
render_images: list[Path],
|
| 351 |
+
extra_images: list[Path],
|
| 352 |
+
reference_images: list[Path],
|
| 353 |
+
blender_bin: str,
|
| 354 |
+
output_rel: str,
|
| 355 |
+
use_bpy: bool,
|
| 356 |
+
render_required: bool = True,
|
| 357 |
+
) -> str:
|
| 358 |
+
def rels(paths: list[Path]) -> str:
|
| 359 |
+
return "\n".join(f" - {vj.rel(p, task_dir)}" for p in paths) or " (none)"
|
| 360 |
+
|
| 361 |
+
inventory = evidence_checks.file_inventory(task_dir / ".eval_workspace")
|
| 362 |
+
inventory_path = task_dir / output_rel / "submission_manifest.json"
|
| 363 |
+
inventory_path.parent.mkdir(parents=True, exist_ok=True)
|
| 364 |
+
inventory_path.write_text(json.dumps(inventory, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 365 |
+
# The full deterministic manifest stays available even for long sequences.
|
| 366 |
+
inventory_preview = json.dumps({**inventory, "files": inventory["files"][:80]}, ensure_ascii=False)
|
| 367 |
+
checks_script = str(Path(evidence_checks.__file__).resolve())
|
| 368 |
+
dims = "\n".join(f" - {d['id']}: {d['name']} — {d['desc']}" for d in vj.DIMENSIONS)
|
| 369 |
+
raw_rel = f"{output_rel}/{RAW_NAME}"
|
| 370 |
+
bpy_rel = f"{output_rel}/{BPY_DUMP_NAME}"
|
| 371 |
+
renders_rel = f"{output_rel}/agent_renders"
|
| 372 |
+
|
| 373 |
+
# RENDERING POLICY (both modes): rendering is expensive and, in this headless GPU container,
|
| 374 |
+
# EEVEE/Workbench silently degrade or fail — any scoring render MUST go through Cycles. When
|
| 375 |
+
# render_required is False (evidence routing: this agent only owns structural / scene_summary
|
| 376 |
+
# rubrics decided from the .blend internals) the agent should NOT render unless a specific
|
| 377 |
+
# rubric genuinely cannot be settled from bpy.
|
| 378 |
+
cycles_rule = (
|
| 379 |
+
"Whenever you render, you MUST use Cycles — never EEVEE/Workbench, which are unreliable "
|
| 380 |
+
"headless here and degrade quality. In your render script set "
|
| 381 |
+
"`scene.render.engine='CYCLES'`, select the GPU "
|
| 382 |
+
"(`bpy.context.preferences.addons['cycles'].preferences.compute_device_type='OPTIX'` or "
|
| 383 |
+
"`'CUDA'`, refresh devices, enable them, then `scene.cycles.device='GPU'`), and use enough "
|
| 384 |
+
"samples (>=64) so the image is not noisy. Confirm the engine is actually CYCLES before "
|
| 385 |
+
"trusting a render."
|
| 386 |
+
)
|
| 387 |
+
export_scan_rule = (
|
| 388 |
+
"When a rubric concerns an EXPORTED deliverable (a PNG image, a rendered still, an "
|
| 389 |
+
"animation/video such as .mp4/.mov/.gif/.webm, or a baked texture), verify its existence "
|
| 390 |
+
"by scanning the WHOLE submission export tree — check `exports/`, `output/`, `renders/`, "
|
| 391 |
+
"and the submission root recursively (e.g. `find . -type f \\( -iname '*.png' -o -iname "
|
| 392 |
+
"'*.mp4' -o -iname '*.mov' -o -iname '*.gif' -o -iname '*.webm' \\)`). Do NOT assume one "
|
| 393 |
+
"fixed folder; score such a rubric on whether the file actually exists somewhere under the "
|
| 394 |
+
"export paths."
|
| 395 |
+
)
|
| 396 |
+
if render_required:
|
| 397 |
+
render_intro = (
|
| 398 |
+
"Author-delivered images are listed below. To judge any appearance/visual "
|
| 399 |
+
"rubric inspect the relevant author file, or render targeted scene evidence in STEP 3 when needed. If you "
|
| 400 |
+
"have neither inspected a relevant author image nor produced a relevant render, do not pass a visual rubric. " + cycles_rule
|
| 401 |
+
)
|
| 402 |
+
step3 = (
|
| 403 |
+
"STEP 3 — Render MULTIPLE targeted images yourself, GUIDED by the rubric + prompt + "
|
| 404 |
+
"dimensions. " + cycles_rule + " Open a COPY of the .blend and render as many views as "
|
| 405 |
+
"you need — an overview PLUS the specific angles, close-ups and framings that expose what "
|
| 406 |
+
"the rubrics and each dimension actually check (e.g. a close-up on a part a rubric names; "
|
| 407 |
+
"an angle showing support/contact for `physics`; a wide shot for "
|
| 408 |
+
"`layout_spatial`/`completeness`; a material close-up for `lighting_material`/`style_color`). "
|
| 409 |
+
"You may adjust temporary cameras in your COPY. Preserve geometry, materials, lights, animation, visibility and color management. Save all images to " + renders_rel +
|
| 410 |
+
"/ with descriptive names and note what each one shows."
|
| 411 |
+
)
|
| 412 |
+
else:
|
| 413 |
+
render_intro = (
|
| 414 |
+
"You are scoring STRUCTURAL / scene_summary rubrics that are decided from the .blend "
|
| 415 |
+
"INTERNALS via bpy, NOT from appearance. You normally do NOT need to render anything, and "
|
| 416 |
+
"you should NOT re-render unless a specific rubric genuinely cannot be settled from the "
|
| 417 |
+
".blend internals. " + cycles_rule
|
| 418 |
+
)
|
| 419 |
+
step3 = (
|
| 420 |
+
"STEP 3 — Rendering is OPTIONAL for these rubrics and usually unnecessary. Do NOT render "
|
| 421 |
+
"just to have an image. Render your OWN image(s) into " + renders_rel + "/ ONLY if a "
|
| 422 |
+
"specific rubric truly requires visual confirmation that bpy cannot give; if you do, "
|
| 423 |
+
+ cycles_rule + " Preserve geometry, materials, lights, animation, visibility and color management. If no rubric needs a render, skip this step entirely (that is expected "
|
| 424 |
+
"and not an error)."
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
return f"""You are an AGENT-AS-JUDGE for a Blender scene-reconstruction benchmark. You are NOT solving
|
| 428 |
+
the task. You SCORE an already-submitted result (a .blend) against a fixed rubric list and a set of
|
| 429 |
+
holistic dimensions. Unlike an image-only judge you can (a) open the submitted .blend to inspect the
|
| 430 |
+
"original code" — its objects, modifiers, geometry-node graphs, shape keys, drivers, materials, scene
|
| 431 |
+
settings, and any embedded text/script data-blocks — AND (b) render your OWN targeted images from it.
|
| 432 |
+
|
| 433 |
+
# Task prompt given to the solver (the TARGET; the submission is what you judge)
|
| 434 |
+
{prompt_text}
|
| 435 |
+
|
| 436 |
+
# Submitted artifacts (paths relative to your working directory)
|
| 437 |
+
Submitted .blend file(s) — the "original code" (READ-ONLY: work on a COPY; never edit/re-save the original):
|
| 438 |
+
{rels(blend_files)}
|
| 439 |
+
Reference / target image(s) (the goal; do NOT credit the submission for something only here):
|
| 440 |
+
{rels(reference_images)}
|
| 441 |
+
Author-delivered images already discovered (these are original files, not your renders):
|
| 442 |
+
{rels(extra_images)}
|
| 443 |
+
Original file inventory (first 80 records; includes PNG IHDR bit depth):
|
| 444 |
+
{inventory_preview}
|
| 445 |
+
Read the FULL inventory at `{vj.rel(inventory_path, task_dir)}` when needed. Inspect the whole `.eval_workspace/` tree, including root-level exports, nested frame sequences, FBX/EXR and accompanying textures. A configured absolute output path in the .blend may be stale: it is not evidence that a delivered file is absent. Do not count evaluator renders, input references or sampled video frames as author-delivered files. The hashes of supplied inputs are listed in `input_media_sha256.json` when present.
|
| 446 |
+
Blender executable: {blender_bin}
|
| 447 |
+
Read-only evidence helper: `{checks_script}`
|
| 448 |
+
To inspect camera optics and rigid-body units, run the original file with autoexec disabled:
|
| 449 |
+
`{blender_bin} --background <original.blend> --disable-autoexec --python {checks_script} -- --output <probe.json>`
|
| 450 |
+
For a second-UV non-overlap condition add `--uv-layer <actual-layer-name>`. Inspect the relevant low-poly meshes; an incomplete scan is unknown, never proof of no overlap. The helper checks original mesh UVs; inspect evaluated geometry too when modifiers generate or alter the deliverable UVs.
|
| 451 |
+
|
| 452 |
+
{render_intro}
|
| 453 |
+
|
| 454 |
+
Work in this EXACT order:
|
| 455 |
+
|
| 456 |
+
STEP 1 — Plan. Read the task prompt above, EVERY rubric below (note each rubric's `evidence_type`),
|
| 457 |
+
and the {len(vj.DIMENSIONS)} holistic dimensions with their descriptions. Decide which scene facts to
|
| 458 |
+
extract from the .blend and which views / close-ups / angles will best reveal the rubric criteria and
|
| 459 |
+
each dimension.
|
| 460 |
+
|
| 461 |
+
STEP 2 — Inspect the .blend internals (the "original code") with bpy. Run Blender headless
|
| 462 |
+
(`{blender_bin} --background <copy-of-blend> --python /tmp/probe.py`) to extract exactly what the
|
| 463 |
+
rubrics/dimensions need: object list & names, mesh triangle counts, modifiers / Geometry-Nodes
|
| 464 |
+
node-group inputs & values, shape-key/blendshape names & counts, drivers, object bounding-box
|
| 465 |
+
dimensions (mm), scene unit settings (`scene.unit_settings`), render engine/samples/resolution,
|
| 466 |
+
material node graphs (Principled/SSS/IOR), UV layout & overlap, physics / rigid-body / Dynamic-Paint
|
| 467 |
+
settings, collections, and any embedded Text data-blocks (scripts). Save your probe script + raw
|
| 468 |
+
output to `{bpy_rel}` (JSON) as an audit trail. DO NOT modify or re-save the original .blend.
|
| 469 |
+
{export_scan_rule}
|
| 470 |
+
|
| 471 |
+
Evidence rules:
|
| 472 |
+
- PNG bit depth comes from the original PNG IHDR, not Pillow's RGB/RGBA mode; Pillow commonly presents 16-bit RGB files as RGB. Use the manifest or evidence helper.
|
| 473 |
+
- For alpha, inspect the actual channel and composite over a checkerboard. A black-looking RGB preview neither proves nor disproves transparency. Validate silhouettes in the actual alpha image.
|
| 474 |
+
- Convert rigid-body substeps_per_frame using effective fps = fps/fps_base. For example, 10 substeps/frame at 24 fps equals 240 steps/second; record time_scale separately. Do not compare different units directly.
|
| 475 |
+
- Camera downward pitch is measured from the world optical axis (local -Z) to the horizontal plane, not from Euler X. Euler X about 65 degrees can correspond to downward pitch about 25 degrees.
|
| 476 |
+
- UV layer names do not prove non-overlap. Check positive-area triangle intersections within the requested layer, allowing shared boundaries. Check actual coordinates, not beauty renders or labels.
|
| 477 |
+
- Preserve the original .blend as the source of settings. If using a copy for rendering, do not report changed render/world settings as original facts.
|
| 478 |
+
- Final-image composition, focus, noise and required deliverable appearance must be checked against the designated author final file. Previews or your rerenders cannot replace that file. Scene existence/geometry can use targeted views.
|
| 479 |
+
- Exact numerical facts, metadata and UV tests are structural checks: use visual_check=na where pixels cannot establish the numeric fact. A dimension that looks plausible is not an independent numeric measurement.
|
| 480 |
+
|
| 481 |
+
{step3}
|
| 482 |
+
|
| 483 |
+
STEP 4 — Score EVERY rubric by CROSS-CHECKING both evidence sources. Do NOT pick a single method and
|
| 484 |
+
stop. For each rubric produce TWO independent sub-verdicts, each `pass` / `fail` / `na`:
|
| 485 |
+
- `bpy_check`: does the requirement hold in the .blend INTERNALS (bpy)? Use `na` ONLY when the rubric
|
| 486 |
+
has no structural/internal aspect (e.g. "reads as a real chair" — a purely visual judgment).
|
| 487 |
+
- `visual_check`: does the requirement hold in YOUR rendered images? Use `na` ONLY when it is
|
| 488 |
+
genuinely invisible in any render you could make (e.g. triangle-count / UV-overlap / a driver).
|
| 489 |
+
At least one sub-verdict must be non-`na`. Whenever BOTH apply — colour, material, a part being
|
| 490 |
+
present AND correctly shaped, a dimension that is visible, layout — you MUST fill BOTH, and the rubric
|
| 491 |
+
passes ONLY if BOTH pass.
|
| 492 |
+
|
| 493 |
+
THE VISIBLE RENDER IS GROUND TRUTH for appearance. A correct internal value NEVER rescues a wrong
|
| 494 |
+
appearance, and vice-versa. Concretely: if the Principled BSDF base colour is red in the node graph
|
| 495 |
+
(`bpy_check`="pass") but the object renders grey/wrong (`visual_check`="fail"), the rubric FAILS —
|
| 496 |
+
because the material is on the wrong slot, unassigned to the visible faces, overridden by emission /
|
| 497 |
+
vertex colour, or the UVs are broken. Any such mismatch is a FAIL, not a pass.
|
| 498 |
+
|
| 499 |
+
Set the final `score`: 1 only if EVERY applicable (non-`na`) sub-verdict is `pass`, otherwise 0 (the
|
| 500 |
+
harness re-derives this from your sub-verdicts, so make them consistent). Score what is ACTUALLY
|
| 501 |
+
present in the submission (.blend + your renders), never what the prompt merely asked for. If truly
|
| 502 |
+
unverifiable even with bpy + targeted renders, score 0 and say why. Also set `method`="bpy" or
|
| 503 |
+
"visual" for the source that was decisive, and give a short concrete `evidence` string that cites the
|
| 504 |
+
bpy fact AND/OR the render file for each sub-verdict you made.
|
| 505 |
+
|
| 506 |
+
RUBRICS (one JSON object per line):
|
| 507 |
+
{render_rubrics_for_agent(rubrics)}
|
| 508 |
+
|
| 509 |
+
STEP 5 — Rate these {len(vj.DIMENSIONS)} dimensions as integers 1-10, scored by WHAT THE RENDER
|
| 510 |
+
VISIBLY ACHIEVES. The .blend internals may only CONFIRM or LOWER a dimension — a correct internal
|
| 511 |
+
value can NEVER raise a dimension above the visible result. Be strict & calibrated: 9-10 only for
|
| 512 |
+
essentially faithful results; 7-8 good with minor issues; 5-6 clear problems; 3-4 major failures;
|
| 513 |
+
1-2 absent/broken. Do NOT cluster at 7-8. Each dimension needs concrete `reasons` (cite views) + an
|
| 514 |
+
`issues` list.
|
| 515 |
+
{dims}
|
| 516 |
+
For EACH dimension also set a boolean `render_conflict`: true when the .blend internals look
|
| 517 |
+
correct/better than what the renders actually show, or the two disagree (e.g. materials/colours/parts
|
| 518 |
+
that are right in bpy but wrong or missing on screen). When `render_conflict` is true you MUST put
|
| 519 |
+
that dimension in the LOW band (the visible result governs; the harness additionally clamps such
|
| 520 |
+
dimensions).
|
| 521 |
+
Also two booleans: `core_objects_recognizable` (main requested objects independently recognizable) and
|
| 522 |
+
`catastrophic_failure` (scene fundamentally fails / unusable as requested).
|
| 523 |
+
|
| 524 |
+
STEP 6 — Write your verdict as a single JSON object to `{raw_rel}` (create the folder if needed),
|
| 525 |
+
EXACTLY this shape and nothing else in the file:
|
| 526 |
+
{{
|
| 527 |
+
"rubric_scores": [
|
| 528 |
+
{{"id": "R01", "score": 0 or 1, "bpy_check": "pass"/"fail"/"na", "visual_check": "pass"/"fail"/"na", "method": "bpy" or "visual", "evidence": "short reason"}}
|
| 529 |
+
// one entry per rubric id above, all of them
|
| 530 |
+
],
|
| 531 |
+
"dimensions": [
|
| 532 |
+
{{"id": "scene_fidelity", "score": 1-10, "render_conflict": true or false, "reasons": "...", "issues": ["..."]}}
|
| 533 |
+
// one entry per dimension id above, all of them
|
| 534 |
+
],
|
| 535 |
+
"core_objects_recognizable": true or false,
|
| 536 |
+
"catastrophic_failure": true or false,
|
| 537 |
+
"overall_notes": "short summary of the main strengths and failures"
|
| 538 |
+
}}
|
| 539 |
+
|
| 540 |
+
Rules: include every rubric id and every dimension id exactly once; integer scores; each rubric's
|
| 541 |
+
`score` must equal 1 iff every applicable (non-`na`) sub-verdict is `pass`; valid JSON (no trailing
|
| 542 |
+
commas/comments). When `{raw_rel}` is written you are done.
|
| 543 |
+
"""
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
def retry_preface(attempt: int, max_attempts: int, raw_rel: str, reason: str) -> str:
|
| 547 |
+
"""Preface prepended to the judge prompt on a retry.
|
| 548 |
+
|
| 549 |
+
Instead of silently dropping a non-conforming agent judgement to the VLM the moment it fails
|
| 550 |
+
to parse, we re-tell the agent exactly why its previous ``agent_judgement_raw.json`` was
|
| 551 |
+
rejected and ask it to re-emit a complete, valid JSON verdict."""
|
| 552 |
+
return (
|
| 553 |
+
f"RETRY {attempt}/{max_attempts}: your previous write to `{raw_rel}` was REJECTED because: "
|
| 554 |
+
f"{reason}. Common causes: the file was not valid JSON, or some rubric ids were "
|
| 555 |
+
f"missing/duplicated. Re-read EVERY rubric id listed below and re-emit the COMPLETE JSON "
|
| 556 |
+
f"object exactly per the STEP 6 shape — include every rubric id and every dimension id "
|
| 557 |
+
f"exactly once, integer scores, valid JSON only (no comments / no trailing commas), and "
|
| 558 |
+
f"nothing else in the file. Overwrite `{raw_rel}` with the corrected JSON.\n\n"
|
| 559 |
+
)
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
def run_one_task(result: dict[str, Any], cfg: dict[str, Any]) -> dict[str, Any] | None:
|
| 563 |
+
task_dir = Path(str(result.get("task_dir") or "")).expanduser()
|
| 564 |
+
rubrics = result.get("rubrics") or []
|
| 565 |
+
tname = task_dir.name
|
| 566 |
+
# Under evidence_type routing this judge only scores a subset (e.g. scene_summary). Filter
|
| 567 |
+
# immediately so is_complete/normalize/finalize all key off the same subset id-set, and the
|
| 568 |
+
# VLM judge owns the rest. Empty set = score every rubric (legacy behavior).
|
| 569 |
+
ev_types = cfg.get("agent_evidence_types") or set()
|
| 570 |
+
if ev_types:
|
| 571 |
+
rubrics = [r for r in rubrics if str(r.get("evidence_type") or "").strip().lower() in ev_types]
|
| 572 |
+
if not rubrics:
|
| 573 |
+
vj.log.info("[agent-judge] skip %s: no rubrics with evidence_type in %s", tname, sorted(ev_types))
|
| 574 |
+
return None
|
| 575 |
+
if not task_dir.is_dir():
|
| 576 |
+
return {"task_dir": str(task_dir), "ok": False, "error": "task_dir not found", "rubric_scores": []}
|
| 577 |
+
if not rubrics:
|
| 578 |
+
return {"task_dir": str(task_dir), "ok": False, "error": "no rubrics", "rubric_scores": []}
|
| 579 |
+
|
| 580 |
+
out_path = vj.output_path(task_dir, cfg["output_dir"])
|
| 581 |
+
rubric_ids = {str(r.get("id")) for r in rubrics}
|
| 582 |
+
if not cfg["overwrite"] and vj.is_complete_judgement(out_path, rubric_ids):
|
| 583 |
+
vj.log.info("[agent-judge] skip complete %s", tname)
|
| 584 |
+
return json.loads(out_path.read_text(encoding="utf-8"))
|
| 585 |
+
|
| 586 |
+
render_images = vj.find_render_images(task_dir, cfg["image_glob"], cfg["max_images"])
|
| 587 |
+
extra_images = vj.find_extra_submission_images(task_dir, cfg["extra_image_globs"], cfg["max_extra_images"])
|
| 588 |
+
reference_images = (
|
| 589 |
+
[] if cfg["no_reference_images"]
|
| 590 |
+
else vj.find_reference_images(task_dir, cfg["reference_image_glob"], cfg["max_reference_images"])
|
| 591 |
+
)
|
| 592 |
+
# The public submission contract names the primary project explicitly.
|
| 593 |
+
primary_project = task_dir / ".eval_workspace" / "final.blend"
|
| 594 |
+
blend_files = [primary_project] if primary_project.is_file() else []
|
| 595 |
+
|
| 596 |
+
output_rel = Path(cfg["output_dir"])
|
| 597 |
+
output_rel = output_rel if not output_rel.is_absolute() else Path(tname)
|
| 598 |
+
output_rel_str = output_rel.as_posix()
|
| 599 |
+
(task_dir / output_rel).mkdir(parents=True, exist_ok=True)
|
| 600 |
+
raw_path = task_dir / output_rel / RAW_NAME
|
| 601 |
+
if cfg["overwrite"] and raw_path.exists():
|
| 602 |
+
raw_path.unlink()
|
| 603 |
+
|
| 604 |
+
# Renders are required only when this judge owns visual rubrics. Under evidence routing it owns
|
| 605 |
+
# only scene_summary (structural, decided from bpy) → do NOT force a render (that render is
|
| 606 |
+
# wasteful and, if it fails headless, would falsely error the whole scene_summary verdict).
|
| 607 |
+
render_required = (not ev_types) or bool(ev_types & {"either", "render", "visual", "image"})
|
| 608 |
+
prompt = build_prompt(
|
| 609 |
+
task_dir, str(result.get("prompt", "")), rubrics,
|
| 610 |
+
blend_files=blend_files, render_images=render_images, extra_images=extra_images,
|
| 611 |
+
reference_images=reference_images, blender_bin=cfg["blender_bin"],
|
| 612 |
+
output_rel=output_rel_str, use_bpy=cfg["use_bpy"] and bool(blend_files),
|
| 613 |
+
render_required=render_required,
|
| 614 |
+
)
|
| 615 |
+
|
| 616 |
+
base_prompt = prompt
|
| 617 |
+
raw_rel = f"{output_rel_str}/{RAW_NAME}"
|
| 618 |
+
max_attempts = max(1, int(cfg.get("max_attempts", 3)))
|
| 619 |
+
returncode: int | None = None
|
| 620 |
+
agent_error = ""
|
| 621 |
+
raw_obj: dict[str, Any] | None = None
|
| 622 |
+
attempts_used = 0
|
| 623 |
+
last_reason = ""
|
| 624 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.jsonl"
|
| 625 |
+
|
| 626 |
+
if cfg["dry_run"]:
|
| 627 |
+
(task_dir / output_rel / "agent_judge_prompt.txt").write_text(base_prompt, encoding="utf-8")
|
| 628 |
+
else:
|
| 629 |
+
# Instead of dropping non-conforming agent output straight to the VLM, re-prompt the agent
|
| 630 |
+
# with what was wrong and let it re-score, up to max_attempts. Only JSON-conformance misses
|
| 631 |
+
# are retried; a timeout / missing-claude / spawn error is infrastructure, not the agent's
|
| 632 |
+
# scoring, so we stop and let the VLM fallback (load_agent_verdicts guard) handle it.
|
| 633 |
+
for attempt in range(1, max_attempts + 1):
|
| 634 |
+
attempts_used = attempt
|
| 635 |
+
if attempt == 1:
|
| 636 |
+
prompt_n = base_prompt
|
| 637 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.jsonl"
|
| 638 |
+
else:
|
| 639 |
+
prompt_n = retry_preface(attempt, max_attempts, raw_rel, last_reason) + base_prompt
|
| 640 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.attempt{attempt}.jsonl"
|
| 641 |
+
if raw_path.exists():
|
| 642 |
+
raw_path.unlink() # drop the previous bad file so it can't be misread as success
|
| 643 |
+
cmd = [
|
| 644 |
+
"claude", "--verbose",
|
| 645 |
+
"--max-turns", str(cfg["max_turns"]),
|
| 646 |
+
"--output-format", "stream-json",
|
| 647 |
+
"--allowedTools", "Bash", "Read", "Write", "Edit", "Glob", "Grep", "LS",
|
| 648 |
+
"--disallowedTools", "WebFetch", "WebSearch",
|
| 649 |
+
"-p", prompt_n,
|
| 650 |
+
]
|
| 651 |
+
env = os.environ.copy()
|
| 652 |
+
env["ANTHROPIC_BASE_URL"] = cfg["anthropic_base_url"]
|
| 653 |
+
env.setdefault("ANTHROPIC_API_KEY", cfg["anthropic_api_key"])
|
| 654 |
+
env.setdefault("ANTHROPIC_AUTH_TOKEN", "")
|
| 655 |
+
if cfg["model"]:
|
| 656 |
+
env["ANTHROPIC_MODEL"] = cfg["model"]
|
| 657 |
+
agent_error = ""
|
| 658 |
+
try:
|
| 659 |
+
with (task_dir / stdout_rel).open("w", encoding="utf-8") as stdout:
|
| 660 |
+
completed = subprocess.run(
|
| 661 |
+
cmd, cwd=str(task_dir), env=env,
|
| 662 |
+
stdout=stdout, stderr=subprocess.STDOUT,
|
| 663 |
+
text=True, timeout=cfg["timeout"], check=False,
|
| 664 |
+
)
|
| 665 |
+
returncode = completed.returncode
|
| 666 |
+
except subprocess.TimeoutExpired:
|
| 667 |
+
returncode = 124
|
| 668 |
+
agent_error = f"agent judge timed out after {cfg['timeout']}s"
|
| 669 |
+
except FileNotFoundError:
|
| 670 |
+
returncode = 127
|
| 671 |
+
agent_error = "claude command not found"
|
| 672 |
+
except Exception as exc: # noqa: BLE001
|
| 673 |
+
returncode = 1
|
| 674 |
+
agent_error = repr(exc)
|
| 675 |
+
|
| 676 |
+
# A terminal API failure is not a malformed judgement. In particular, an explicit
|
| 677 |
+
# content refusal must stop here, without a JSON repair retry or VLM fallback.
|
| 678 |
+
agent_error = agent_error or cli_api_error(task_dir / stdout_rel)
|
| 679 |
+
if agent_error:
|
| 680 |
+
break
|
| 681 |
+
|
| 682 |
+
# Parse this attempt's raw output (with json_repair fallback).
|
| 683 |
+
raw_obj = None
|
| 684 |
+
if raw_path.exists():
|
| 685 |
+
try:
|
| 686 |
+
text = raw_path.read_text(encoding="utf-8")
|
| 687 |
+
try:
|
| 688 |
+
raw_obj = json.loads(text)
|
| 689 |
+
except Exception: # noqa: BLE001
|
| 690 |
+
raw_obj = json.loads(repair_json(text))
|
| 691 |
+
except Exception as exc: # noqa: BLE001
|
| 692 |
+
raw_obj = None
|
| 693 |
+
last_reason = f"could not parse {RAW_NAME}: {exc!r}"
|
| 694 |
+
else:
|
| 695 |
+
last_reason = f"agent did not write {RAW_NAME}"
|
| 696 |
+
|
| 697 |
+
# Conformance probe (reuses the same normalization finalize will apply): ok iff valid
|
| 698 |
+
# JSON with a score for every rubric id.
|
| 699 |
+
if raw_obj is not None:
|
| 700 |
+
probe_ok, _, probe_reason = normalize_agent_rubrics(
|
| 701 |
+
raw_obj, rubrics, enforce_cross_check=bool(cfg.get("cross_check", True))
|
| 702 |
+
)
|
| 703 |
+
if probe_ok:
|
| 704 |
+
break # valid, complete scoring — done
|
| 705 |
+
last_reason = probe_reason or "agent scoring incomplete"
|
| 706 |
+
|
| 707 |
+
if attempt < max_attempts:
|
| 708 |
+
vj.log.info(
|
| 709 |
+
"[agent-judge] task=%s attempt=%d/%d invalid (%s) — retrying",
|
| 710 |
+
tname, attempt, max_attempts, last_reason,
|
| 711 |
+
)
|
| 712 |
+
continue
|
| 713 |
+
# Attempts exhausted, still non-conforming: flag the error so finalize records it and
|
| 714 |
+
# load_agent_verdicts' guard falls back to VLM (the last resort).
|
| 715 |
+
agent_error = f"agent output invalid after {max_attempts} attempts: {last_reason}"
|
| 716 |
+
|
| 717 |
+
# Enforce a self-render ONLY when this judge owns visual rubrics (render_required). Under
|
| 718 |
+
# evidence routing it scores structural / scene_summary rubrics from bpy, so an empty
|
| 719 |
+
# agent_renders/ is expected and must NOT be treated as an error.
|
| 720 |
+
renders_dir = task_dir / output_rel / "agent_renders"
|
| 721 |
+
agent_render_count = len(list(renders_dir.glob("*.png"))) if renders_dir.exists() else 0
|
| 722 |
+
if render_required and agent_render_count == 0 and not agent_error:
|
| 723 |
+
agent_error = "agent produced no self-rendered images (agent_renders/ empty) — visual rubrics unverified"
|
| 724 |
+
|
| 725 |
+
extra_meta = {
|
| 726 |
+
"agent_returncode": returncode,
|
| 727 |
+
"agent_stdout_path": stdout_rel,
|
| 728 |
+
"agent_raw_path": f"{output_rel_str}/{RAW_NAME}",
|
| 729 |
+
"bpy_dump_path": f"{output_rel_str}/{BPY_DUMP_NAME}",
|
| 730 |
+
"agent_renders_path": f"{output_rel_str}/agent_renders",
|
| 731 |
+
"agent_render_count": agent_render_count,
|
| 732 |
+
"agent_attempts": attempts_used,
|
| 733 |
+
}
|
| 734 |
+
if agent_error:
|
| 735 |
+
extra_meta["agent_error"] = agent_error
|
| 736 |
+
|
| 737 |
+
obj = finalize_judgement(
|
| 738 |
+
task_dir, rubrics, raw_obj, cfg,
|
| 739 |
+
render_images=render_images, extra_images=extra_images, reference_images=reference_images,
|
| 740 |
+
extra_meta=extra_meta,
|
| 741 |
+
)
|
| 742 |
+
obj["output_path"] = str(out_path)
|
| 743 |
+
vj.atomic_write_json(out_path, obj)
|
| 744 |
+
vj.log.info(
|
| 745 |
+
"[agent-judge] task=%s ok=%s fused=%.1f rubric=%.1f dim=%s self_renders=%d attempts=%d rc=%s",
|
| 746 |
+
tname, obj.get("ok"), obj.get("fused_score_0_100") or 0.0,
|
| 747 |
+
obj.get("weighted_score_0_100") or 0.0, obj.get("dimension_score_0_100"),
|
| 748 |
+
agent_render_count, attempts_used, returncode,
|
| 749 |
+
)
|
| 750 |
+
return obj
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
def parse_args() -> argparse.Namespace:
|
| 754 |
+
p = argparse.ArgumentParser(description="Agent-as-Judge for Blender trajectory eval")
|
| 755 |
+
p.add_argument("--rubrics-batch", required=True)
|
| 756 |
+
p.add_argument("--output-dir", default=DEFAULT_OUTPUT_DIR)
|
| 757 |
+
p.add_argument("--batch-output", default="")
|
| 758 |
+
p.add_argument("--image-glob", default=DEFAULT_IMAGE_GLOB)
|
| 759 |
+
p.add_argument("--extra-image-glob", action="append", default=[])
|
| 760 |
+
p.add_argument("--reference-image-glob", default="**/image_assets/*")
|
| 761 |
+
p.add_argument("--no-reference-images", action="store_true")
|
| 762 |
+
p.add_argument("--max-images", type=int, default=8)
|
| 763 |
+
p.add_argument("--max-extra-images", type=int, default=4)
|
| 764 |
+
p.add_argument("--max-reference-images", type=int, default=4)
|
| 765 |
+
p.add_argument("--model", default=os.environ.get("AGENT_JUDGE_MODEL") or os.environ.get("MODEL", ""))
|
| 766 |
+
p.add_argument("--max-turns", type=int, default=int(os.environ.get("AGENT_JUDGE_MAX_TURNS", "500")))
|
| 767 |
+
p.add_argument(
|
| 768 |
+
"--max-attempts", type=int,
|
| 769 |
+
default=int(os.environ.get("AGENT_JUDGE_MAX_ATTEMPTS", "3")),
|
| 770 |
+
help="Max agent-judge attempts per task. When the agent produces non-conforming JSON "
|
| 771 |
+
"(missing file / unparseable / missing rubric ids), it is re-prompted to re-score "
|
| 772 |
+
"up to this many times before the VLM fallback is used as a last resort.",
|
| 773 |
+
)
|
| 774 |
+
p.add_argument("--timeout", type=int, default=int(os.environ.get("AGENT_JUDGE_TIMEOUT", "14400")))
|
| 775 |
+
p.add_argument("--task-concurrency", type=int, default=int(os.environ.get("AGENT_JUDGE_TASK_CONCURRENCY", "2")))
|
| 776 |
+
p.add_argument("--dimension-weight", type=float, default=0.5)
|
| 777 |
+
p.add_argument("--no-dimension-pass", action="store_true")
|
| 778 |
+
p.add_argument("--dimension-conflict-cap", type=int, default=4,
|
| 779 |
+
help="Clamp any dimension the agent flags with render_conflict=true to <= this "
|
| 780 |
+
"1-10 value (worst-of-both; the visible render governs). Default 4.")
|
| 781 |
+
p.add_argument("--no-dimension-conflict-cap", action="store_true",
|
| 782 |
+
help="Disable the render_conflict dimension clamp.")
|
| 783 |
+
p.add_argument("--no-rubric-cross-check", action="store_true",
|
| 784 |
+
help="Disable conjunctive rubric scoring; fall back to the model's self-reported "
|
| 785 |
+
"0/1 score (ignore bpy_check/visual_check).")
|
| 786 |
+
p.add_argument("--blender-bin", default=os.environ.get("BLENDER_BIN", "blender"))
|
| 787 |
+
p.add_argument("--no-bpy", action="store_true")
|
| 788 |
+
p.add_argument("--anthropic-base-url", default=os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com"))
|
| 789 |
+
p.add_argument("--anthropic-api-key", default=os.environ.get("ANTHROPIC_API_KEY", ""))
|
| 790 |
+
p.add_argument("--limit", type=int, default=0)
|
| 791 |
+
p.add_argument("--overwrite", action="store_true")
|
| 792 |
+
p.add_argument("--dry-run", action="store_true")
|
| 793 |
+
p.add_argument(
|
| 794 |
+
"--agent-evidence-types",
|
| 795 |
+
default="",
|
| 796 |
+
help=(
|
| 797 |
+
"Comma list of evidence_type values this agent judge should score. Empty (default) "
|
| 798 |
+
"means score every rubric (legacy behavior). Under evidence_type routing set this to "
|
| 799 |
+
"'scene_summary' so the agent only judges those rubrics and the VLM handles the rest."
|
| 800 |
+
),
|
| 801 |
+
)
|
| 802 |
+
return p.parse_args()
|
| 803 |
+
|
| 804 |
+
|
| 805 |
+
def main() -> int:
|
| 806 |
+
args = parse_args()
|
| 807 |
+
rubrics_batch = Path(args.rubrics_batch)
|
| 808 |
+
results = vj.load_rubric_results(rubrics_batch)
|
| 809 |
+
if args.limit > 0:
|
| 810 |
+
results = results[: args.limit]
|
| 811 |
+
|
| 812 |
+
extra_globs = args.extra_image_glob or list(vj.DEFAULT_EXTRA_IMAGE_GLOBS)
|
| 813 |
+
cfg = {
|
| 814 |
+
"output_dir": args.output_dir,
|
| 815 |
+
"image_glob": args.image_glob,
|
| 816 |
+
"extra_image_globs": extra_globs,
|
| 817 |
+
"reference_image_glob": args.reference_image_glob,
|
| 818 |
+
"no_reference_images": args.no_reference_images,
|
| 819 |
+
"max_images": args.max_images,
|
| 820 |
+
"max_extra_images": args.max_extra_images,
|
| 821 |
+
"max_reference_images": args.max_reference_images,
|
| 822 |
+
"model": args.model,
|
| 823 |
+
"max_turns": args.max_turns,
|
| 824 |
+
"max_attempts": args.max_attempts,
|
| 825 |
+
"timeout": args.timeout,
|
| 826 |
+
"dimension_weight": args.dimension_weight,
|
| 827 |
+
"dimension_pass": not args.no_dimension_pass,
|
| 828 |
+
"dimension_conflict_cap": None if args.no_dimension_conflict_cap else args.dimension_conflict_cap,
|
| 829 |
+
"cross_check": not args.no_rubric_cross_check,
|
| 830 |
+
"blender_bin": args.blender_bin,
|
| 831 |
+
"use_bpy": not args.no_bpy,
|
| 832 |
+
"anthropic_base_url": args.anthropic_base_url,
|
| 833 |
+
"anthropic_api_key": args.anthropic_api_key,
|
| 834 |
+
"overwrite": args.overwrite,
|
| 835 |
+
"dry_run": args.dry_run,
|
| 836 |
+
"agent_evidence_types": vj.parse_type_set(args.agent_evidence_types),
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
outputs: list[dict[str, Any]] = []
|
| 840 |
+
workers = max(1, int(args.task_concurrency))
|
| 841 |
+
if workers == 1:
|
| 842 |
+
for result in results:
|
| 843 |
+
out = run_one_task(result, cfg)
|
| 844 |
+
if out is not None:
|
| 845 |
+
outputs.append(out)
|
| 846 |
+
else:
|
| 847 |
+
with ThreadPoolExecutor(max_workers=workers) as pool:
|
| 848 |
+
futures = {pool.submit(run_one_task, result, cfg): result for result in results}
|
| 849 |
+
for fut in as_completed(futures):
|
| 850 |
+
try:
|
| 851 |
+
out = fut.result()
|
| 852 |
+
except Exception as exc: # noqa: BLE001
|
| 853 |
+
r = futures[fut]
|
| 854 |
+
out = {"task_dir": str(r.get("task_dir")), "ok": False,
|
| 855 |
+
"error": repr(exc), "rubric_scores": []}
|
| 856 |
+
if out is not None:
|
| 857 |
+
outputs.append(out)
|
| 858 |
+
|
| 859 |
+
outputs.sort(key=lambda o: str(o.get("task_dir")))
|
| 860 |
+
batch_output = Path(args.batch_output) if args.batch_output else rubrics_batch.parent / "judge_agent_batch.json"
|
| 861 |
+
ok_count = sum(1 for item in outputs if item.get("ok"))
|
| 862 |
+
batch = {
|
| 863 |
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
| 864 |
+
"rubrics_batch": str(rubrics_batch),
|
| 865 |
+
"model": args.model,
|
| 866 |
+
"judge_kind": "agent",
|
| 867 |
+
"task_count": len(outputs),
|
| 868 |
+
"ok_count": ok_count,
|
| 869 |
+
"score_summary": vj.build_batch_score_summary(outputs),
|
| 870 |
+
"results": outputs,
|
| 871 |
+
}
|
| 872 |
+
vj.atomic_write_json(batch_output, batch)
|
| 873 |
+
vj.log.info("[agent-judge] wrote batch %s ok=%d/%d", batch_output, ok_count, len(outputs))
|
| 874 |
+
return 0 if ok_count == len(outputs) else 2
|
| 875 |
+
|
| 876 |
+
|
| 877 |
+
if __name__ == "__main__":
|
| 878 |
+
sys.exit(main())
|
bw_0220/tests/blenderworld/evaluators/judge_blender_binary_rubrics.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
bw_0220/tests/blenderworld/harbor_export.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Export the frozen dataset as self-contained Harbor task packages."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import importlib.metadata
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
from .data import RESOURCE_FIELDS, load_tasks, prepare, resolve, sha256, verify, write_json
|
| 11 |
+
from .evaluation import PROTOCOL
|
| 12 |
+
from . import __version__
|
| 13 |
+
from .runtime import RUNTIME_VERSIONS, requirements
|
| 14 |
+
from .submissions import FORMAT, PROJECT
|
| 15 |
+
|
| 16 |
+
HARBOR_VERSION = "0.23.0"
|
| 17 |
+
ASSETS = Path(__file__).with_name("harbor_assets")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _harbor():
|
| 21 |
+
try:
|
| 22 |
+
from harbor.models.dataset.manifest import DatasetManifest
|
| 23 |
+
from harbor.models.task.task import Task
|
| 24 |
+
from harbor.publisher.packager import Packager
|
| 25 |
+
except ImportError as error:
|
| 26 |
+
raise RuntimeError("Harbor export requires Python 3.12+ and pip install 'blenderworld[harbor]'") from error
|
| 27 |
+
if importlib.metadata.version("harbor") != HARBOR_VERSION:
|
| 28 |
+
raise RuntimeError(f"This exporter is validated with harbor=={HARBOR_VERSION}; install the pinned harbor extra")
|
| 29 |
+
return DatasetManifest, Task, Packager
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def _instruction(row):
|
| 33 |
+
resources = []
|
| 34 |
+
for field in ("reference_images", "reference_videos", "attachments"):
|
| 35 |
+
for entry in row[field]:
|
| 36 |
+
resources.append(f"- `{field}`: `/workspace/inputs/{entry['task_relative_path']}`")
|
| 37 |
+
return (f"# BlenderWorld {row['task_id']}\n\n"
|
| 38 |
+
"## Task\n\n" + row["query"] + "\n\n"
|
| 39 |
+
"## Inputs\n\nThe original request is also in `/workspace/inputs/query.txt`.\n\n"
|
| 40 |
+
+ ("\n".join(resources) if resources else "This task has no reference media or declared attachments.")
|
| 41 |
+
+ "\n\nRead the supplied specifications and inspect the reference media before modeling. "
|
| 42 |
+
"Relative filenames in the request refer to the files listed above.\n\n"
|
| 43 |
+
"## Deliverables\n\nSave the editable project as `/workspace/exports/final.blend`. "
|
| 44 |
+
"Put all requested images, videos, model exports, and texture dependencies under "
|
| 45 |
+
"`/workspace/exports/`. Pack textures into the project or keep relative paths inside "
|
| 46 |
+
"this directory so the project can be opened in a fresh environment.\n\n"
|
| 47 |
+
"## Tools\n\nBlender is installed as `blender`. A Blender MCP server is configured "
|
| 48 |
+
"for agents that support task MCP servers; use its advertised tools to inspect the "
|
| 49 |
+
"scene, execute Blender Python, and capture viewport images. The Blender Python CLI "
|
| 50 |
+
"is also available. Use Blender 4.2.10, Node.js 22.17.0, Codex CLI 0.147.0 "
|
| 51 |
+
"or Claude Code 2.1.220; do not upgrade these tools. "
|
| 52 |
+
"Inspect your result and save your work before finishing.\n")
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _config(row, namespace, cpus, memory_mb, gpus, agent_timeout, verifier_timeout):
|
| 56 |
+
quote = json.dumps
|
| 57 |
+
gpu_line = f"gpus = {gpus}\n" if gpus else ""
|
| 58 |
+
return f'''schema_version = "1.3"
|
| 59 |
+
artifacts = ["/workspace/exports"]
|
| 60 |
+
|
| 61 |
+
[task]
|
| 62 |
+
name = {quote(namespace + '/BlenderWorld-' + row['task_id'])}
|
| 63 |
+
description = "BlenderWorld {row['task_id']} ({row['modality']})"
|
| 64 |
+
keywords = ["blender", "3d", "{row['modality']}"]
|
| 65 |
+
|
| 66 |
+
[metadata]
|
| 67 |
+
task_id = "{row['task_id']}"
|
| 68 |
+
modality = "{row['modality']}"
|
| 69 |
+
rubric_count = {row['rubric_count']}
|
| 70 |
+
protocol_version = {PROTOCOL['version']}
|
| 71 |
+
code_version = "{__version__}"
|
| 72 |
+
blender_version = "{RUNTIME_VERSIONS['blender']}"
|
| 73 |
+
node_version = "{RUNTIME_VERSIONS['node']}"
|
| 74 |
+
codex_version = "{RUNTIME_VERSIONS['codex']}"
|
| 75 |
+
claude_code_version = "{RUNTIME_VERSIONS['claude_code']}"
|
| 76 |
+
submission_format = "{FORMAT}"
|
| 77 |
+
submission_project = "{PROJECT}"
|
| 78 |
+
|
| 79 |
+
[agent]
|
| 80 |
+
timeout_sec = {agent_timeout}
|
| 81 |
+
|
| 82 |
+
[environment]
|
| 83 |
+
build_timeout_sec = 3600
|
| 84 |
+
cpus = {cpus}
|
| 85 |
+
memory_mb = {memory_mb}
|
| 86 |
+
storage_mb = 102400
|
| 87 |
+
{gpu_line}workdir = "/workspace"
|
| 88 |
+
|
| 89 |
+
[[environment.mcp_servers]]
|
| 90 |
+
name = "blender"
|
| 91 |
+
transport = "stdio"
|
| 92 |
+
command = "/usr/local/bin/bw-blender-mcp"
|
| 93 |
+
args = []
|
| 94 |
+
|
| 95 |
+
[verifier]
|
| 96 |
+
timeout_sec = {verifier_timeout}
|
| 97 |
+
environment_mode = "separate"
|
| 98 |
+
|
| 99 |
+
[verifier.environment]
|
| 100 |
+
build_timeout_sec = 3600
|
| 101 |
+
cpus = {cpus}
|
| 102 |
+
memory_mb = {memory_mb}
|
| 103 |
+
storage_mb = 102400
|
| 104 |
+
{gpu_line}workdir = "/workspace"
|
| 105 |
+
|
| 106 |
+
[verifier.env]
|
| 107 |
+
ANTHROPIC_BASE_URL = "${{BW_AGENT_JUDGE_ENDPOINT}}"
|
| 108 |
+
ANTHROPIC_API_KEY = "${{BW_AGENT_JUDGE_API_KEY}}"
|
| 109 |
+
JUDGE_API_ENDPOINT = "${{BW_VISION_JUDGE_ENDPOINT}}"
|
| 110 |
+
JUDGE_API_KEY = "${{BW_VISION_JUDGE_API_KEY}}"
|
| 111 |
+
RENDER_AGENT_MODEL = "${{BW_RENDER_MODEL:-gpt-5.6-terra}}"
|
| 112 |
+
AGENT_JUDGE_MODEL = "${{BW_AGENT_JUDGE_MODEL:-gpt-5.6-terra}}"
|
| 113 |
+
JUDGE_MODEL = "${{BW_VISION_JUDGE_MODEL:-gpt-5.6-terra}}"
|
| 114 |
+
'''
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def _copy_dataset_task(dataset, row, destination):
|
| 118 |
+
task_root = destination / "tasks" / row["task_id"]
|
| 119 |
+
task_root.mkdir(parents=True)
|
| 120 |
+
write_json(task_root / "task.json", row)
|
| 121 |
+
for key in ("query_file", "rubric_file"):
|
| 122 |
+
target = resolve(destination, row[key])
|
| 123 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 124 |
+
shutil.copyfile(resolve(dataset, row[key]), target)
|
| 125 |
+
for field in RESOURCE_FIELDS:
|
| 126 |
+
for entry in row[field]:
|
| 127 |
+
target = resolve(destination, entry["path"])
|
| 128 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 129 |
+
shutil.copyfile(resolve(dataset, entry["path"]), target)
|
| 130 |
+
(destination / "dataset.jsonl").write_text(json.dumps(row, ensure_ascii=False) + "\n")
|
| 131 |
+
rubric = json.loads(resolve(dataset, row["rubric_file"]).read_text())
|
| 132 |
+
write_json(destination / "rubrics.json", {"results": [rubric]})
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def export_harbor(dataset, output, namespace="Qwen", task_ids=None, cpus=8,
|
| 136 |
+
memory_mb=16384, gpus=0, agent_timeout=14400, verifier_timeout=28800):
|
| 137 |
+
"""Create a new export; the source dataset and existing task packages are never edited."""
|
| 138 |
+
Manifest, Task, Packager = _harbor()
|
| 139 |
+
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]*", namespace) or ".." in namespace:
|
| 140 |
+
raise ValueError("Invalid Harbor organization namespace")
|
| 141 |
+
if min(cpus, memory_mb, agent_timeout, verifier_timeout) <= 0 or gpus < 0:
|
| 142 |
+
raise ValueError("Resources and timeouts must be positive; GPU count may be zero")
|
| 143 |
+
dataset, output = Path(dataset).resolve(), Path(output).resolve()
|
| 144 |
+
if output == dataset or output.is_relative_to(dataset):
|
| 145 |
+
raise ValueError("Export directory must be outside the frozen dataset")
|
| 146 |
+
verify(dataset)
|
| 147 |
+
rows = load_tasks(dataset)
|
| 148 |
+
if task_ids:
|
| 149 |
+
selected = set(task_ids)
|
| 150 |
+
rows = [r for r in rows if r["task_id"] in selected]
|
| 151 |
+
if {r["task_id"] for r in rows} != selected:
|
| 152 |
+
raise ValueError("Unknown task ID in selection")
|
| 153 |
+
output.mkdir(parents=True, exist_ok=False)
|
| 154 |
+
manifest_tasks, audit_tasks = [], []
|
| 155 |
+
code_root = Path(__file__).parent
|
| 156 |
+
# Only Python runtime files go into the verifier, never into the agent image.
|
| 157 |
+
code_files = sorted(code_root.rglob("*.py"))
|
| 158 |
+
for row in rows:
|
| 159 |
+
task = output / row["task_id"]
|
| 160 |
+
env, tests = task / "environment", task / "tests"
|
| 161 |
+
env.mkdir(parents=True)
|
| 162 |
+
tests.mkdir()
|
| 163 |
+
(task / "instruction.md").write_text(_instruction(row))
|
| 164 |
+
(task / "task.toml").write_text(_config(row, namespace, cpus, memory_mb, gpus,
|
| 165 |
+
agent_timeout, verifier_timeout))
|
| 166 |
+
prepare(dataset, row["task_id"], env / "inputs")
|
| 167 |
+
for name in ("Dockerfile.agent", "mcp_bridge.py", "blender_startup.py", "install_blender.sh", "requirements-tools.txt", "LICENSE"):
|
| 168 |
+
shutil.copyfile(ASSETS / name, env / ("Dockerfile" if name == "Dockerfile.agent" else name))
|
| 169 |
+
for name in ("Dockerfile.verifier", "test.sh", "install_blender.sh", "requirements-verifier.txt", "LICENSE"):
|
| 170 |
+
shutil.copyfile(ASSETS / name, tests / ("Dockerfile" if name == "Dockerfile.verifier" else name))
|
| 171 |
+
(tests / "test.sh").chmod(0o755)
|
| 172 |
+
for path in code_files:
|
| 173 |
+
relative = path.relative_to(code_root)
|
| 174 |
+
if "harbor_assets" in relative.parts:
|
| 175 |
+
continue
|
| 176 |
+
target = tests / "blenderworld" / relative
|
| 177 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 178 |
+
shutil.copyfile(path, target)
|
| 179 |
+
_copy_dataset_task(dataset, row, tests / "dataset")
|
| 180 |
+
Task(task) # Validate with the same schema used by the installed Harbor release.
|
| 181 |
+
digest, files = Packager.compute_content_hash(task)
|
| 182 |
+
manifest_tasks.append({"name": f"{namespace}/BlenderWorld-{row['task_id']}",
|
| 183 |
+
"digest": "sha256:" + digest})
|
| 184 |
+
audit_tasks.append({"task_id": row["task_id"], "modality": row["modality"],
|
| 185 |
+
"digest": "sha256:" + digest, "files": len(files),
|
| 186 |
+
"query_sha256": sha256(env / "inputs/query.txt"),
|
| 187 |
+
"rubric_sha256": sha256(resolve(tests / "dataset", row["rubric_file"]))})
|
| 188 |
+
manifest = Manifest.model_validate({"dataset": {"name": f"{namespace}/BlenderWorld",
|
| 189 |
+
"version": "1.2.0", "description": "BlenderWorld: 3D creation in Blender",
|
| 190 |
+
"keywords": ["blender", "3d", "multimodal", "agent"]},
|
| 191 |
+
"tasks": manifest_tasks})
|
| 192 |
+
(output / "dataset.toml").write_text(manifest.to_toml())
|
| 193 |
+
for name in ("README.md", "verifier.env.example", "LICENSE"):
|
| 194 |
+
shutil.copyfile(ASSETS / name, output / name)
|
| 195 |
+
report = {"format": "blenderworld-harbor-v1", "harbor_version": HARBOR_VERSION,
|
| 196 |
+
"code_version": __version__, "runtime_requirements": requirements(),
|
| 197 |
+
"submission_format": FORMAT,
|
| 198 |
+
"dataset_name": manifest.dataset.name, "task_count": len(rows),
|
| 199 |
+
"dataset_digest": "sha256:" + manifest.compute_content_hash(),
|
| 200 |
+
"source_dataset_sha256": sha256(dataset / "dataset.jsonl"),
|
| 201 |
+
"protocol": PROTOCOL, "tasks": audit_tasks}
|
| 202 |
+
write_json(output / "export_manifest.json", report)
|
| 203 |
+
files = sorted(p for p in output.rglob("*") if p.is_file())
|
| 204 |
+
(output / "SHA256SUMS").write_text("".join(f"{sha256(p)} {p.relative_to(output).as_posix()}\n" for p in files))
|
| 205 |
+
return {k: v for k, v in report.items() if k != "tasks"}
|
bw_0220/tests/blenderworld/harbor_verify.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Harbor verifier entry point, backed by the standalone BlenderWorld evaluator."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import argparse
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import shutil
|
| 8 |
+
import subprocess
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from types import SimpleNamespace
|
| 11 |
+
|
| 12 |
+
from .data import load_tasks, sha256, write_json
|
| 13 |
+
from .evaluation import PROTOCOL, evaluate, tree_hashes
|
| 14 |
+
from .submissions import pack_submission
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def run_verifier(dataset, submission, output):
|
| 18 |
+
dataset, submission, output = map(lambda p: Path(p).resolve(), (dataset, submission, output))
|
| 19 |
+
if output == submission or output.is_relative_to(submission):
|
| 20 |
+
raise ValueError("Verifier output must be outside the submission")
|
| 21 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 22 |
+
reward = {"reward": 0.0, "rubric_score": 0.0, "dimension_score": 0.0}
|
| 23 |
+
# A timeout/crash can never leave a previous successful reward behind.
|
| 24 |
+
write_json(output / "reward.json", reward)
|
| 25 |
+
result = {"ok": False, "status": "running", "score": 0.0, "protocol": PROTOCOL}
|
| 26 |
+
write_json(output / "metrics.json", result)
|
| 27 |
+
try:
|
| 28 |
+
rows = load_tasks(dataset)
|
| 29 |
+
if len(rows) != 1:
|
| 30 |
+
raise ValueError("A Harbor verifier package must contain exactly one task")
|
| 31 |
+
task_id = rows[0]["task_id"]
|
| 32 |
+
result["task_id"] = task_id
|
| 33 |
+
if submission.is_symlink() or any(p.is_symlink() for p in submission.rglob("*")):
|
| 34 |
+
raise ValueError("Submission contains symbolic links")
|
| 35 |
+
before = sha256(submission) if submission.is_file() else tree_hashes(submission)
|
| 36 |
+
staging = output / "submissions"
|
| 37 |
+
staging.mkdir(exist_ok=False)
|
| 38 |
+
if submission.is_dir():
|
| 39 |
+
pack_submission(submission, task_id, staging / (task_id + ".zip"))
|
| 40 |
+
elif submission.is_file():
|
| 41 |
+
shutil.copyfile(submission, staging / (task_id + ".zip"))
|
| 42 |
+
options = SimpleNamespace(
|
| 43 |
+
dataset=str(dataset), submissions=str(staging), output=str(output / "run"),
|
| 44 |
+
task_id=[task_id], dry_run=False, resume=False,
|
| 45 |
+
blender_bin=os.environ.get("BLENDER_BIN", "blender"),
|
| 46 |
+
render_agent_model=os.environ.get("RENDER_AGENT_MODEL", "gpt-5.6-terra"),
|
| 47 |
+
agent_judge_model=os.environ.get("AGENT_JUDGE_MODEL", "gpt-5.6-terra"),
|
| 48 |
+
judge_model=os.environ.get("JUDGE_MODEL", "gpt-5.6-terra"),
|
| 49 |
+
judge_api_endpoint=os.environ.get("JUDGE_API_ENDPOINT", "https://api.openai.com/v1/chat/completions"))
|
| 50 |
+
evaluate(options)
|
| 51 |
+
outcome = json.loads((output / "run/tasks" / task_id / "result.json").read_text())
|
| 52 |
+
after = sha256(submission) if submission.is_file() else tree_hashes(submission)
|
| 53 |
+
if after != before:
|
| 54 |
+
raise ValueError("Original submission changed during verification")
|
| 55 |
+
result.update(outcome, status="scored" if outcome["ok"] else "failed")
|
| 56 |
+
if outcome["ok"]:
|
| 57 |
+
reward = {"reward": outcome["score"] / 100,
|
| 58 |
+
"rubric_score": outcome["rubric_score"] / 100,
|
| 59 |
+
"dimension_score": outcome["dimension_score"] / 100}
|
| 60 |
+
except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
|
| 61 |
+
result.update(ok=False, status="failed", score=0.0, error=str(error))
|
| 62 |
+
write_json(output / "metrics.json", result)
|
| 63 |
+
write_json(output / "reward.json", reward)
|
| 64 |
+
return result
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def main():
|
| 68 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 69 |
+
parser.add_argument("--dataset", default="/tests/dataset")
|
| 70 |
+
parser.add_argument("--submission", default="/workspace/exports",
|
| 71 |
+
help="Harbor exports directory (packaged before scoring), or one submission ZIP")
|
| 72 |
+
parser.add_argument("--output", default="/logs/verifier")
|
| 73 |
+
args = parser.parse_args()
|
| 74 |
+
result = run_verifier(args.dataset, args.submission, args.output)
|
| 75 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 76 |
+
return 0 if result["ok"] else 1
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
if __name__ == "__main__":
|
| 80 |
+
raise SystemExit(main())
|
bw_0220/tests/blenderworld/render_agent.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Adaptive eight-view evidence rendering using a configured coding agent."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import shutil
|
| 7 |
+
import subprocess
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
from PIL import Image
|
| 11 |
+
|
| 12 |
+
from .data import write_json
|
| 13 |
+
from .evaluators.evidence_checks import cli_log_status
|
| 14 |
+
|
| 15 |
+
VIEW_COUNT = 8
|
| 16 |
+
RESOLUTION = 1024
|
| 17 |
+
SAMPLES = 64
|
| 18 |
+
MAX_CORRECTIVE_RERENDERS = 2
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def normalize_blender_path(value):
|
| 22 |
+
"""Resolve caller-relative paths before agents change their working directory.
|
| 23 |
+
|
| 24 |
+
A bare command may stay unresolved during a dry run without Blender installed.
|
| 25 |
+
"""
|
| 26 |
+
requested = os.path.expanduser(str(value))
|
| 27 |
+
found = shutil.which(requested)
|
| 28 |
+
if found:
|
| 29 |
+
return str(Path(found).resolve())
|
| 30 |
+
if os.sep in requested:
|
| 31 |
+
return str(Path(requested).resolve())
|
| 32 |
+
return requested
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def prompt_for(task, blender):
|
| 36 |
+
return f"""You collect rendering evidence for BlenderWorld.
|
| 37 |
+
Open the primary submitted project .eval_workspace/final.blend with {blender}. Read query.txt,
|
| 38 |
+
rubric.json, and references/. These describe the target; they do not prove that the
|
| 39 |
+
submission satisfies it. Render exactly {VIEW_COUNT} complementary views into
|
| 40 |
+
evaluation/multiview/. Start with the submitted camera when it shows the subject,
|
| 41 |
+
then choose different wide views and at least two detail views relevant to the rubrics.
|
| 42 |
+
Use short unique filenames ending in .png. Fit cameras to the subject, ignoring
|
| 43 |
+
large background/floor planes. For interiors, position cameras inside enclosing walls.
|
| 44 |
+
|
| 45 |
+
Every view must use CYCLES, {RESOLUTION}x{RESOLUTION}, {SAMPLES} samples. Prefer OPTIX,
|
| 46 |
+
then CUDA; use CPU if no supported GPU exists. Record the actual device. Retain the
|
| 47 |
+
scene's denoising. Preserve geometry, materials, textures, object visibility, lighting,
|
| 48 |
+
animation, and color management, including exposure and gamma. Never repair the
|
| 49 |
+
submitted scene. Do not save over a .blend or any submitted file. The provided Blender
|
| 50 |
+
wrapper restores missing image paths only from this task's bundled workspace.
|
| 51 |
+
|
| 52 |
+
After each render, open and inspect the PNG. Correct evaluator camera/framing/clipping
|
| 53 |
+
or incorrect evaluator render settings when necessary; allow at most
|
| 54 |
+
{MAX_CORRECTIVE_RERENDERS} corrective re-renders per view (one initial render plus
|
| 55 |
+
two corrections, three total). Reuse the same filename. Dark or oddly colored
|
| 56 |
+
authored scenes must remain that way. Do not alter lights or materials to improve them.
|
| 57 |
+
Keep all Blender calls in the foreground and wait for completion. The runtime logs
|
| 58 |
+
render settings and rejects more than three attempts for the same view.
|
| 59 |
+
|
| 60 |
+
Write evaluation/multiview/render_agent_report.json with:
|
| 61 |
+
{{"ok": true, "view_count": 8, "engine": "CYCLES", "device": "OPTIX|CUDA|CPU",
|
| 62 |
+
"image_files": ["view_01.png", "..."], "notes": "view selection and corrections"}}.
|
| 63 |
+
All PNGs must be newly rendered from this submission. Do not copy author exports or
|
| 64 |
+
reference images into the evaluator views. Do not write outside the task directory.
|
| 65 |
+
|
| 66 |
+
Task query:
|
| 67 |
+
{task['query']}
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def validate_views(task_dir):
|
| 72 |
+
root = Path(task_dir)
|
| 73 |
+
folder = root / "evaluation/multiview"
|
| 74 |
+
images = sorted(folder.glob("*.png"))
|
| 75 |
+
if len(images) != VIEW_COUNT:
|
| 76 |
+
raise ValueError(f"Expected {VIEW_COUNT} fresh evaluator renders, found {len(images)}")
|
| 77 |
+
report = json.loads((folder / "render_agent_report.json").read_text())
|
| 78 |
+
if report.get("ok") is not True or report.get("engine") != "CYCLES" or report.get("view_count") != VIEW_COUNT:
|
| 79 |
+
raise ValueError("Invalid render-agent report")
|
| 80 |
+
if sorted(report.get("image_files", [])) != [p.name for p in images]:
|
| 81 |
+
raise ValueError("Render report does not list the actual views")
|
| 82 |
+
attempts = json.loads((folder / "render_attempts.json").read_text())
|
| 83 |
+
for path in images:
|
| 84 |
+
with Image.open(path) as image:
|
| 85 |
+
if image.size != (RESOLUTION, RESOLUTION):
|
| 86 |
+
raise ValueError(f"Incorrect resolution: {path.name}")
|
| 87 |
+
image.verify()
|
| 88 |
+
history = attempts.get(str(path.resolve()), [])
|
| 89 |
+
if not history or len(history) > 1 + MAX_CORRECTIVE_RERENDERS:
|
| 90 |
+
raise ValueError(f"Missing or excessive render attempts: {path.name}")
|
| 91 |
+
final = history[-1]
|
| 92 |
+
if final.get("engine") != "CYCLES" or final.get("samples") != SAMPLES:
|
| 93 |
+
raise ValueError(f"Incorrect render settings: {path.name}")
|
| 94 |
+
if final.get("completed") is not True:
|
| 95 |
+
raise ValueError(f"No successful Blender render: {path.name}")
|
| 96 |
+
return report
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def run(task, task_dir, blender_bin, model, timeout=5400):
|
| 100 |
+
root = Path(task_dir).resolve()
|
| 101 |
+
folder = root / "evaluation/multiview"
|
| 102 |
+
folder.mkdir(parents=True, exist_ok=False)
|
| 103 |
+
real_blender = shutil.which(normalize_blender_path(blender_bin))
|
| 104 |
+
if not real_blender:
|
| 105 |
+
raise FileNotFoundError(f"Blender not found: {blender_bin}")
|
| 106 |
+
bootstrap = Path(__file__).with_name("blender_runtime.py").resolve()
|
| 107 |
+
wrapper = root / "evaluation/blender"
|
| 108 |
+
wrapper.write_text("#!/usr/bin/env python3\nimport os,sys\nos.execv(" + repr(real_blender)
|
| 109 |
+
+ ", [" + repr(real_blender) + ", '--background', '--python-exit-code', '2', '--python', "
|
| 110 |
+
+ repr(str(bootstrap)) + "] + sys.argv[1:])\n")
|
| 111 |
+
wrapper.chmod(0o755)
|
| 112 |
+
prompt = prompt_for(task, str(wrapper))
|
| 113 |
+
(root / "evaluation/render_prompt.txt").write_text(prompt)
|
| 114 |
+
env = os.environ.copy()
|
| 115 |
+
env.update(BLENDER_EVAL_ASSET_ROOT=str(root), BLENDER_EVAL_VIEW_ROOT=str(folder),
|
| 116 |
+
BLENDER_EVAL_RUNTIME_AUDIT=str(root / "evaluation/blender_runtime.jsonl"),
|
| 117 |
+
DISABLE_AUTOUPDATER="1")
|
| 118 |
+
if model:
|
| 119 |
+
env["ANTHROPIC_MODEL"] = model
|
| 120 |
+
log_path = root / "evaluation/render_agent.jsonl"
|
| 121 |
+
with log_path.open("w") as log:
|
| 122 |
+
result = subprocess.run(["claude", "--verbose", "--output-format", "stream-json",
|
| 123 |
+
"--max-turns", "500", "--allowedTools", "Bash", "Read", "Write",
|
| 124 |
+
"Edit", "Glob", "Grep", "--disallowedTools", "WebFetch", "WebSearch",
|
| 125 |
+
"-p", prompt], cwd=root, env=env, stdout=log, stderr=subprocess.STDOUT,
|
| 126 |
+
timeout=timeout, check=False)
|
| 127 |
+
event, refused = cli_log_status(log_path)
|
| 128 |
+
if result.returncode or refused or not event or event.get("is_error"):
|
| 129 |
+
raise RuntimeError("Render agent failed; see evaluation/render_agent.jsonl")
|
| 130 |
+
return validate_views(root)
|
bw_0220/tests/blenderworld/runtime.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Validate the release runtime before spending evaluator model calls."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
import subprocess
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from .data import sha256
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class RuntimeValidationError(RuntimeError):
|
| 15 |
+
"""An evaluator installation error, not a failed agent submission."""
|
| 16 |
+
|
| 17 |
+
RUNTIME_VERSIONS = {
|
| 18 |
+
"blender": "4.2.10",
|
| 19 |
+
"node": "22.17.0",
|
| 20 |
+
"claude_code": "2.1.220",
|
| 21 |
+
"codex": "0.147.0",
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
BLENDER_PROBE = '''import bpy, json
|
| 25 |
+
backends = []
|
| 26 |
+
prefs = bpy.context.preferences.addons['cycles'].preferences
|
| 27 |
+
for backend in ('OPTIX', 'CUDA'):
|
| 28 |
+
try:
|
| 29 |
+
prefs.compute_device_type = backend
|
| 30 |
+
prefs.get_devices()
|
| 31 |
+
devices = sorted({d.name for d in prefs.devices if d.type == backend})
|
| 32 |
+
if devices:
|
| 33 |
+
backends.append({'backend': backend, 'devices': devices})
|
| 34 |
+
except Exception:
|
| 35 |
+
pass
|
| 36 |
+
build = bpy.app.build_hash
|
| 37 |
+
if isinstance(build, bytes):
|
| 38 |
+
build = build.decode('ascii', errors='replace')
|
| 39 |
+
print('BLENDERWORLD_RUNTIME=' + json.dumps({
|
| 40 |
+
'version': '.'.join(map(str, bpy.app.version)),
|
| 41 |
+
'build_hash': build, 'gpu_backends': backends}))
|
| 42 |
+
'''
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def requirements():
|
| 46 |
+
return {"versions": dict(RUNTIME_VERSIONS),
|
| 47 |
+
"evaluation_tools": ["blender", "node", "claude_code"],
|
| 48 |
+
"generation_tools": ["blender", "node", "codex", "claude_code"]}
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _version(command, name):
|
| 52 |
+
found = shutil.which(str(command))
|
| 53 |
+
if not found:
|
| 54 |
+
raise RuntimeValidationError(f"BlenderWorld runtime requires {name} {RUNTIME_VERSIONS[name]}; executable not found: {command}")
|
| 55 |
+
path = Path(found).resolve()
|
| 56 |
+
try:
|
| 57 |
+
result = subprocess.run([str(path), "--version"], capture_output=True,
|
| 58 |
+
env={**os.environ, "DISABLE_AUTOUPDATER": "1"},
|
| 59 |
+
text=True, timeout=30, check=False)
|
| 60 |
+
except (OSError, subprocess.SubprocessError) as error:
|
| 61 |
+
raise RuntimeValidationError(f"Could not check {name} version: {error}") from error
|
| 62 |
+
text = result.stdout.strip()
|
| 63 |
+
match = re.search(r"\bv?(\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?)\b", text)
|
| 64 |
+
actual = match.group(1) if match else "unknown"
|
| 65 |
+
if result.returncode or actual != RUNTIME_VERSIONS[name]:
|
| 66 |
+
raise RuntimeValidationError(f"BlenderWorld runtime requires {name} {RUNTIME_VERSIONS[name]}, found {actual} at {path}")
|
| 67 |
+
return {"path": str(path), "version": actual,
|
| 68 |
+
"sha256": sha256(path)}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def inspect_runtime(blender_bin="blender"):
|
| 72 |
+
"""Pin evaluator tools; Codex is installed/checked by the rollout image."""
|
| 73 |
+
report = {"requirements": requirements()}
|
| 74 |
+
report["blender"] = _version(blender_bin, "blender")
|
| 75 |
+
report["node"] = _version("node", "node")
|
| 76 |
+
report["claude_code"] = _version("claude", "claude_code")
|
| 77 |
+
try:
|
| 78 |
+
result = subprocess.run([report["blender"]["path"], "--background", "--factory-startup",
|
| 79 |
+
"--python-exit-code", "2", "--python-expr", BLENDER_PROBE],
|
| 80 |
+
capture_output=True, text=True, timeout=90, check=False)
|
| 81 |
+
except (OSError, subprocess.SubprocessError) as error:
|
| 82 |
+
raise RuntimeValidationError(f"Could not inspect Blender's Cycles runtime: {error}") from error
|
| 83 |
+
lines = [s.removeprefix("BLENDERWORLD_RUNTIME=") for s in result.stdout.splitlines()
|
| 84 |
+
if s.startswith("BLENDERWORLD_RUNTIME=")]
|
| 85 |
+
if result.returncode or len(lines) != 1:
|
| 86 |
+
raise RuntimeValidationError("Blender runtime inspection failed; check the Blender installation and GPU driver")
|
| 87 |
+
try:
|
| 88 |
+
details = json.loads(lines[0])
|
| 89 |
+
except ValueError as error:
|
| 90 |
+
raise RuntimeValidationError("Invalid Blender runtime report") from error
|
| 91 |
+
if details.get("version") != RUNTIME_VERSIONS["blender"]:
|
| 92 |
+
raise RuntimeValidationError("Blender executable and bpy runtime versions disagree")
|
| 93 |
+
report["blender"].update(details)
|
| 94 |
+
return report
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def record_runtime(output, report):
|
| 98 |
+
path = Path(output) / "runtime.json"
|
| 99 |
+
if path.exists() and json.loads(path.read_text()) != report:
|
| 100 |
+
raise RuntimeValidationError("Runtime versions, executables, or GPU changed; start a new run")
|
| 101 |
+
if not path.exists():
|
| 102 |
+
path.write_text(json.dumps(report, indent=2) + "\n")
|
bw_0220/tests/blenderworld/submissions.py
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Public submission contract: one ZIP with final.blend at its root per task."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
from contextlib import contextmanager
|
| 5 |
+
import hashlib
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path, PurePosixPath
|
| 9 |
+
import re
|
| 10 |
+
import shutil
|
| 11 |
+
import stat
|
| 12 |
+
import tempfile
|
| 13 |
+
import zipfile
|
| 14 |
+
|
| 15 |
+
from .data import sha256
|
| 16 |
+
|
| 17 |
+
FORMAT = "blenderworld-submission-v1"
|
| 18 |
+
PROJECT = "final.blend"
|
| 19 |
+
MANIFEST = "submission.json"
|
| 20 |
+
MAX_FILES = 100_000
|
| 21 |
+
MAX_BYTES = 20 * 1024**3
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _name(name):
|
| 25 |
+
if not name or "\\" in name or "\0" in name:
|
| 26 |
+
raise ValueError("Invalid archive member path")
|
| 27 |
+
path = PurePosixPath(name)
|
| 28 |
+
if path.is_absolute() or ".." in path.parts or re.match(r"^[A-Za-z]:", name):
|
| 29 |
+
raise ValueError("Archive member escapes its root")
|
| 30 |
+
return path.as_posix().rstrip("/")
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _copy(source, destination, limit):
|
| 34 |
+
total = 0
|
| 35 |
+
while block := source.read(1024 * 1024):
|
| 36 |
+
total += len(block)
|
| 37 |
+
if total > limit:
|
| 38 |
+
raise ValueError("Submission file exceeds its declared size or size limit")
|
| 39 |
+
destination.write(block)
|
| 40 |
+
return total
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@contextmanager
|
| 44 |
+
def _archive(source):
|
| 45 |
+
"""Validate paths and file types before reading submitted files."""
|
| 46 |
+
try:
|
| 47 |
+
with zipfile.ZipFile(source) as archive:
|
| 48 |
+
members = archive.infolist()
|
| 49 |
+
if len(members) > MAX_FILES:
|
| 50 |
+
raise ValueError("Too many archive members")
|
| 51 |
+
names, files, total = set(), {}, 0
|
| 52 |
+
for member in members:
|
| 53 |
+
name = _name(member.orig_filename)
|
| 54 |
+
directory = member.is_dir()
|
| 55 |
+
if name == "." and directory:
|
| 56 |
+
continue
|
| 57 |
+
if name in names:
|
| 58 |
+
raise ValueError("Duplicate archive member")
|
| 59 |
+
names.add(name)
|
| 60 |
+
kind = stat.S_IFMT(member.external_attr >> 16)
|
| 61 |
+
if kind not in (0, stat.S_IFDIR if directory else stat.S_IFREG):
|
| 62 |
+
raise ValueError("Archive links and special files are not supported")
|
| 63 |
+
if not directory:
|
| 64 |
+
total += member.file_size
|
| 65 |
+
if member.file_size < 0 or total > MAX_BYTES:
|
| 66 |
+
raise ValueError("Archive exceeds the uncompressed size limit")
|
| 67 |
+
files[name] = (member.file_size, member)
|
| 68 |
+
for name in names:
|
| 69 |
+
if any(p.as_posix() in files for p in PurePosixPath(name).parents if p.as_posix() != "."):
|
| 70 |
+
raise ValueError("Archive contains a file/directory path conflict")
|
| 71 |
+
yield files, lambda name: archive.open(files[name][1])
|
| 72 |
+
except (zipfile.BadZipFile, EOFError, RuntimeError, NotImplementedError) as error:
|
| 73 |
+
raise ValueError(f"Invalid submission ZIP: {type(error).__name__}") from error
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@contextmanager
|
| 77 |
+
def _directory(source):
|
| 78 |
+
files, total = {}, 0
|
| 79 |
+
for path in sorted(source.rglob("*")):
|
| 80 |
+
if path.is_symlink():
|
| 81 |
+
raise ValueError("Submission contains a symbolic link")
|
| 82 |
+
if path.is_dir():
|
| 83 |
+
continue
|
| 84 |
+
if not path.is_file():
|
| 85 |
+
raise ValueError("Submission contains a special file")
|
| 86 |
+
size = path.stat().st_size
|
| 87 |
+
total += size
|
| 88 |
+
if total > MAX_BYTES or len(files) >= MAX_FILES:
|
| 89 |
+
raise ValueError("Submission exceeds the size or file-count limit")
|
| 90 |
+
files[_name(path.relative_to(source).as_posix())] = (size, path)
|
| 91 |
+
yield files, lambda name: files[name][1].open("rb")
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def _check_manifest(files, read, task_id):
|
| 95 |
+
if MANIFEST not in files:
|
| 96 |
+
return None
|
| 97 |
+
if files[MANIFEST][0] > 16 * 1024**2:
|
| 98 |
+
raise ValueError("Submission manifest is too large")
|
| 99 |
+
with read(MANIFEST) as stream:
|
| 100 |
+
manifest = json.load(stream)
|
| 101 |
+
if not isinstance(manifest, dict) or manifest.get("format") != FORMAT or manifest.get("task_id") != task_id:
|
| 102 |
+
raise ValueError("Submission manifest format or task_id does not match")
|
| 103 |
+
expected = manifest.get("files")
|
| 104 |
+
if not isinstance(expected, dict) or any(not isinstance(k, str) or not isinstance(v, str)
|
| 105 |
+
or not re.fullmatch(r"[0-9a-f]{64}", v) for k, v in expected.items()):
|
| 106 |
+
raise ValueError("Invalid submission file checksums")
|
| 107 |
+
if set(expected) != set(files) - {MANIFEST}:
|
| 108 |
+
raise ValueError("Submission manifest does not cover the delivered files")
|
| 109 |
+
return expected
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
@contextmanager
|
| 113 |
+
def _payload(source, task_id):
|
| 114 |
+
source = Path(source)
|
| 115 |
+
if source.is_symlink():
|
| 116 |
+
raise ValueError("Submission source must not be a symbolic link")
|
| 117 |
+
if not source.is_dir() and not source.is_file():
|
| 118 |
+
raise ValueError("Submission source does not exist")
|
| 119 |
+
reader = _directory(source) if source.is_dir() else _archive(source)
|
| 120 |
+
with reader as (files, read):
|
| 121 |
+
if PROJECT not in files:
|
| 122 |
+
raise ValueError("Expected final.blend at the submission root; package the output directory's contents without a wrapping folder")
|
| 123 |
+
if not files[PROJECT][0]:
|
| 124 |
+
raise ValueError("Submitted final.blend is empty")
|
| 125 |
+
expected = _check_manifest(files, read, task_id)
|
| 126 |
+
selected = {n: info for n, info in files.items() if n != MANIFEST}
|
| 127 |
+
yield selected, read, expected
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _task_id(task_id):
|
| 131 |
+
if not re.fullmatch(r"bw_\d{4}", task_id):
|
| 132 |
+
raise ValueError("Use the dataset's bw_XXXX task ID")
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def pack_submission(source, task_id, output):
|
| 136 |
+
"""Package a model's output directory (or standard ZIP) with checksums."""
|
| 137 |
+
_task_id(task_id)
|
| 138 |
+
source, output = Path(source), Path(output).absolute()
|
| 139 |
+
if source.is_symlink():
|
| 140 |
+
raise ValueError("Submission source must not be a symbolic link")
|
| 141 |
+
source = source.resolve()
|
| 142 |
+
if output.suffix.lower() != ".zip" or output.exists():
|
| 143 |
+
raise ValueError("Output must be a new .zip file")
|
| 144 |
+
if source.is_dir() and output.resolve().is_relative_to(source):
|
| 145 |
+
raise ValueError("Write the submission ZIP outside the source directory")
|
| 146 |
+
output.parent.mkdir(parents=True, exist_ok=True)
|
| 147 |
+
with tempfile.NamedTemporaryFile(dir=output.parent, suffix=".zip", delete=False) as temporary:
|
| 148 |
+
temp = Path(temporary.name)
|
| 149 |
+
try:
|
| 150 |
+
with _payload(source, task_id) as (files, read, expected):
|
| 151 |
+
hashes = {}
|
| 152 |
+
with zipfile.ZipFile(temp, "w", zipfile.ZIP_DEFLATED, compresslevel=6) as archive:
|
| 153 |
+
for name, (size, _) in sorted(files.items()):
|
| 154 |
+
digest = hashlib.sha256()
|
| 155 |
+
with read(name) as stream, archive.open(name, "w", force_zip64=True) as target:
|
| 156 |
+
written = 0
|
| 157 |
+
while block := stream.read(1024 * 1024):
|
| 158 |
+
written += len(block)
|
| 159 |
+
if written > size:
|
| 160 |
+
raise ValueError("Source changed while packaging")
|
| 161 |
+
digest.update(block)
|
| 162 |
+
target.write(block)
|
| 163 |
+
if written != size:
|
| 164 |
+
raise ValueError("Truncated delivered file")
|
| 165 |
+
hashes[name] = digest.hexdigest()
|
| 166 |
+
if expected is not None and hashes != expected:
|
| 167 |
+
raise ValueError("Submission checksum mismatch")
|
| 168 |
+
archive.writestr(MANIFEST, json.dumps({"format": FORMAT, "task_id": task_id,
|
| 169 |
+
"files": hashes}, indent=2) + "\n")
|
| 170 |
+
inspect_submission(temp, task_id)
|
| 171 |
+
# Publish atomically without overwriting another completed submission.
|
| 172 |
+
os.link(temp, output)
|
| 173 |
+
return {"task_id": task_id, "output": str(output), "format": FORMAT,
|
| 174 |
+
"project": PROJECT, "files": len(hashes), "sha256": sha256(output)}
|
| 175 |
+
finally:
|
| 176 |
+
temp.unlink(missing_ok=True)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def inspect_submission(archive, task_id):
|
| 180 |
+
_task_id(task_id)
|
| 181 |
+
archive = Path(archive)
|
| 182 |
+
if archive.is_symlink() or not archive.is_file():
|
| 183 |
+
raise ValueError("Expected a per-task submission ZIP")
|
| 184 |
+
with _payload(archive, task_id) as (files, _, expected):
|
| 185 |
+
return {"format": FORMAT, "project": PROJECT, "manifest_present": expected is not None,
|
| 186 |
+
"files": len(files), "bytes": sum(size for size, _ in files.values()),
|
| 187 |
+
"blend_files": sorted(n for n in files if n.lower().endswith(".blend"))}
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def unpack_submission(archive, task_id, destination):
|
| 191 |
+
"""Extract submitted files into an evaluator-owned copy, preserving paths."""
|
| 192 |
+
archive, destination = Path(archive), Path(destination)
|
| 193 |
+
details = inspect_submission(archive, task_id)
|
| 194 |
+
destination.mkdir(parents=True, exist_ok=False)
|
| 195 |
+
hashes = {}
|
| 196 |
+
try:
|
| 197 |
+
with _payload(archive, task_id) as (files, read, expected):
|
| 198 |
+
for name, (size, _) in sorted(files.items()):
|
| 199 |
+
path = destination / name
|
| 200 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 201 |
+
with read(name) as source, path.open("xb") as target:
|
| 202 |
+
written = _copy(source, target, size)
|
| 203 |
+
if written != size:
|
| 204 |
+
raise ValueError("Truncated delivered file")
|
| 205 |
+
hashes[name] = sha256(path)
|
| 206 |
+
if expected is not None and hashes != expected:
|
| 207 |
+
raise ValueError("Submission checksum mismatch")
|
| 208 |
+
return {**details, "archive_sha256": sha256(archive), "file_sha256": hashes}
|
| 209 |
+
except BaseException:
|
| 210 |
+
shutil.rmtree(destination)
|
| 211 |
+
raise
|
bw_0220/tests/dataset/dataset.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"schema_version": 1, "task_id": "bw_0220", "modality": "video", "query": "I'm a teacher preparing a skateboarding lesson, and I need a previz from this reference to review framing with students and try other angles later. Recreate the seaside concrete bowl, with coastline and spectators visible above the rim, then fully rig and animate the skater descending the curved surface, turning, and riding up the wall on the reference timing. The priority is matching the skater’s turning line across the bowl’s curvature; camera framing and movement should match the source. Keep materials, lighting and atmosphere faithful, but use your judgment on details. Deliver an H.264 .mp4 at 3840×2160, 30 fps, matching the clip’s roughly 2.7-second duration, plus the .blend project.", "query_file": "tasks/bw_0220/query.txt", "rubric_file": "tasks/bw_0220/rubric.json", "rubric_count": 19, "rubric_prompt_matches_query": true, "annotation_status": "ready", "attachments": [], "supplemental_attachments": [], "reference_images": [], "reference_videos": [{"path": "tasks/bw_0220/references/video_01.mp4", "task_relative_path": "references/video_01.mp4", "bytes": 10879207, "sha256": "c303fbccfd11403ec2eef3a1ce56d85cb2f02bf833e83b03fdcf5b89eaf50d75"}], "rubric_reference_images": [], "metadata": {"lang": "en", "category": "Art & Animation", "subcategory": "Animation, Motion & Art", "domain": "skateboard_bowl", "persona": "intermediate", "length": "detailed", "complexity": "very_hard", "ref_style": "recreate", "input_form": "video+text", "use_case": "video_storyboard", "visual_focus": ["滑板者沿碗池曲面的转弯线路"], "category_short": "Animation", "subcategory_short": "Motion art", "taxonomy_version": "taxonomy_223"}}
|
bw_0220/tests/dataset/rubrics.json
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"results": [
|
| 3 |
+
{
|
| 4 |
+
"task_id": "bw_0220",
|
| 5 |
+
"prompt": "I'm a teacher preparing a skateboarding lesson, and I need a previz from this reference to review framing with students and try other angles later. Recreate the seaside concrete bowl, with coastline and spectators visible above the rim, then fully rig and animate the skater descending the curved surface, turning, and riding up the wall on the reference timing. The priority is matching the skater’s turning line across the bowl’s curvature; camera framing and movement should match the source. Keep materials, lighting and atmosphere faithful, but use your judgment on details. Deliver an H.264 .mp4 at 3840×2160, 30 fps, matching the clip’s roughly 2.7-second duration, plus the .blend project.",
|
| 6 |
+
"lang": "en",
|
| 7 |
+
"mode": "prompt_image",
|
| 8 |
+
"attachments": [
|
| 9 |
+
{
|
| 10 |
+
"file": "references/video_01.mp4"
|
| 11 |
+
}
|
| 12 |
+
],
|
| 13 |
+
"image_file": null,
|
| 14 |
+
"rubric_count": 19,
|
| 15 |
+
"rubrics": [
|
| 16 |
+
{
|
| 17 |
+
"id": "R01",
|
| 18 |
+
"category": "geometry",
|
| 19 |
+
"importance": "major",
|
| 20 |
+
"subject": "Primary skate bowl",
|
| 21 |
+
"requirement_source": "prompt_explicit",
|
| 22 |
+
"evidence_type": "render",
|
| 23 |
+
"criterion": "The primary environment is a recognizable seaside concrete bowl with the reference's deep irregular continuous geometry.",
|
| 24 |
+
"pass_condition": "The video clearly shows a concrete bowl in a seaside setting, with a broad lower riding area, steep upper walls, and smooth concave transitions forming a deep irregular reference-like basin.",
|
| 25 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 26 |
+
"category_v2": "geometry",
|
| 27 |
+
"importance_weight": 3,
|
| 28 |
+
"score_type": "binary",
|
| 29 |
+
"score_values": [
|
| 30 |
+
0,
|
| 31 |
+
1
|
| 32 |
+
]
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"id": "R02",
|
| 36 |
+
"category": "presence",
|
| 37 |
+
"importance": "major",
|
| 38 |
+
"subject": "Skater and skateboard",
|
| 39 |
+
"requirement_source": "prompt_explicit",
|
| 40 |
+
"evidence_type": "render",
|
| 41 |
+
"criterion": "A recognizable human skater riding a recognizable skateboard is the principal animated subject.",
|
| 42 |
+
"pass_condition": "The delivered video clearly presents a human rider and skateboard as the main moving subject.",
|
| 43 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 44 |
+
"category_v2": "presence",
|
| 45 |
+
"importance_weight": 3,
|
| 46 |
+
"score_type": "binary",
|
| 47 |
+
"score_values": [
|
| 48 |
+
0,
|
| 49 |
+
1
|
| 50 |
+
]
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"id": "R03",
|
| 54 |
+
"category": "count",
|
| 55 |
+
"importance": "secondary",
|
| 56 |
+
"subject": "Spectators above the rim",
|
| 57 |
+
"requirement_source": "prompt_explicit",
|
| 58 |
+
"evidence_type": "render",
|
| 59 |
+
"criterion": "Multiple spectators are visibly gathered on the deck above the bowl rim.",
|
| 60 |
+
"pass_condition": "A visibly plural group of human spectators can be seen on the upper deck above and beyond the rim.",
|
| 61 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 62 |
+
"category_v2": "count",
|
| 63 |
+
"importance_weight": 2,
|
| 64 |
+
"score_type": "binary",
|
| 65 |
+
"score_values": [
|
| 66 |
+
0,
|
| 67 |
+
1
|
| 68 |
+
]
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"id": "R04",
|
| 72 |
+
"category": "space_layout",
|
| 73 |
+
"importance": "secondary",
|
| 74 |
+
"subject": "Seaside background",
|
| 75 |
+
"requirement_source": "prompt_explicit",
|
| 76 |
+
"evidence_type": "render",
|
| 77 |
+
"criterion": "The background visibly establishes the sandy coastline, ocean, and distant horizon.",
|
| 78 |
+
"pass_condition": "Sandy beach, open sea, and a distant horizon are identifiable beyond the skatepark.",
|
| 79 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 80 |
+
"category_v2": "space_layout",
|
| 81 |
+
"importance_weight": 2,
|
| 82 |
+
"score_type": "binary",
|
| 83 |
+
"score_values": [
|
| 84 |
+
0,
|
| 85 |
+
1
|
| 86 |
+
]
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"id": "R05",
|
| 90 |
+
"category": "geometry",
|
| 91 |
+
"importance": "detail",
|
| 92 |
+
"subject": "Adjacent skatepark terrain",
|
| 93 |
+
"requirement_source": "reference_visible",
|
| 94 |
+
"evidence_type": "render",
|
| 95 |
+
"criterion": "The visible upper-deck setting includes reference-like adjacent rounded concrete skate terrain.",
|
| 96 |
+
"pass_condition": "Beyond the main rim, the visible deck includes simplified or detailed rounded concrete bowl or mound forms that preserve the reference setting.",
|
| 97 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 98 |
+
"category_v2": "geometry",
|
| 99 |
+
"importance_weight": 1,
|
| 100 |
+
"score_type": "binary",
|
| 101 |
+
"score_values": [
|
| 102 |
+
0,
|
| 103 |
+
1
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"id": "R06",
|
| 108 |
+
"category": "layout",
|
| 109 |
+
"importance": "major",
|
| 110 |
+
"subject": "Foreground-to-background layering",
|
| 111 |
+
"requirement_source": "reference_visible",
|
| 112 |
+
"evidence_type": "render",
|
| 113 |
+
"criterion": "The bowl, rim deck, spectators, beach, and ocean follow the reference's layered spatial arrangement.",
|
| 114 |
+
"pass_condition": "The bowl occupies the foreground, spectators stand above it on the elevated rim deck, and beach and ocean remain beyond that deck.",
|
| 115 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 116 |
+
"category_v2": "layout",
|
| 117 |
+
"importance_weight": 3,
|
| 118 |
+
"score_type": "binary",
|
| 119 |
+
"score_values": [
|
| 120 |
+
0,
|
| 121 |
+
1
|
| 122 |
+
]
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"id": "R07",
|
| 126 |
+
"category": "scale",
|
| 127 |
+
"importance": "secondary",
|
| 128 |
+
"subject": "Human-relative scene scale",
|
| 129 |
+
"requirement_source": "holistic",
|
| 130 |
+
"evidence_type": "render",
|
| 131 |
+
"criterion": "The bowl, deck, people, and skateboard maintain mutually credible human-scale proportions.",
|
| 132 |
+
"pass_condition": "The rider and spectators plausibly fit the deck and bowl, and the skateboard has a credible size relative to the rider and riding surface.",
|
| 133 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 134 |
+
"category_v2": "scale",
|
| 135 |
+
"importance_weight": 2,
|
| 136 |
+
"score_type": "binary",
|
| 137 |
+
"score_values": [
|
| 138 |
+
0,
|
| 139 |
+
1
|
| 140 |
+
]
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"id": "R08",
|
| 144 |
+
"category": "material",
|
| 145 |
+
"importance": "secondary",
|
| 146 |
+
"subject": "Bowl concrete",
|
| 147 |
+
"requirement_source": "reference_visible",
|
| 148 |
+
"evidence_type": "render",
|
| 149 |
+
"criterion": "The bowl reads as weathered gray concrete with reference-like variation between sunlit and shaded surfaces.",
|
| 150 |
+
"pass_condition": "Sunlit surfaces appear pale to medium gray and subtly varied, while shaded steep walls are distinctly darker yet still read as concrete.",
|
| 151 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 152 |
+
"category_v2": "material",
|
| 153 |
+
"importance_weight": 2,
|
| 154 |
+
"score_type": "binary",
|
| 155 |
+
"score_values": [
|
| 156 |
+
0,
|
| 157 |
+
1
|
| 158 |
+
]
|
| 159 |
+
},
|
| 160 |
+
{
|
| 161 |
+
"id": "R09",
|
| 162 |
+
"category": "material",
|
| 163 |
+
"importance": "detail",
|
| 164 |
+
"subject": "Bowl rim treatment",
|
| 165 |
+
"requirement_source": "reference_visible",
|
| 166 |
+
"evidence_type": "render",
|
| 167 |
+
"criterion": "A narrow pale segmented coping or tile band visibly follows the upper bowl edge.",
|
| 168 |
+
"pass_condition": "A contrasting light-colored strip with readable repeated segmentation follows the curved rim in the delivered video; exact segment count and construction are unrestricted.",
|
| 169 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 170 |
+
"category_v2": "material",
|
| 171 |
+
"importance_weight": 1,
|
| 172 |
+
"score_type": "binary",
|
| 173 |
+
"score_values": [
|
| 174 |
+
0,
|
| 175 |
+
1
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"id": "R10",
|
| 180 |
+
"category": "lighting",
|
| 181 |
+
"importance": "secondary",
|
| 182 |
+
"subject": "Coastal daylight and atmosphere",
|
| 183 |
+
"requirement_source": "prompt_explicit",
|
| 184 |
+
"evidence_type": "render",
|
| 185 |
+
"criterion": "Lighting and atmosphere reproduce the bright, clear, high-contrast coastal daylight of the reference.",
|
| 186 |
+
"pass_condition": "The video shows a bright blue sky and coastal atmosphere with crisp directional shadows and strong but readable sunlit-to-shaded contrast.",
|
| 187 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 188 |
+
"category_v2": "lighting",
|
| 189 |
+
"importance_weight": 2,
|
| 190 |
+
"score_type": "binary",
|
| 191 |
+
"score_values": [
|
| 192 |
+
0,
|
| 193 |
+
1
|
| 194 |
+
]
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"id": "R11",
|
| 198 |
+
"category": "function",
|
| 199 |
+
"importance": "major",
|
| 200 |
+
"subject": "Skater rig",
|
| 201 |
+
"requirement_source": "prompt_explicit",
|
| 202 |
+
"evidence_type": "scene_summary",
|
| 203 |
+
"criterion": "The skater is controlled by a genuine articulated rig used by the delivered animation.",
|
| 204 |
+
"pass_condition": "The .blend contains an armature or equivalent articulated control system bound to the skater, with animation data driving the displayed body poses.",
|
| 205 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 206 |
+
"category_v2": "function",
|
| 207 |
+
"importance_weight": 3,
|
| 208 |
+
"score_type": "binary",
|
| 209 |
+
"score_values": [
|
| 210 |
+
0,
|
| 211 |
+
1
|
| 212 |
+
]
|
| 213 |
+
},
|
| 214 |
+
{
|
| 215 |
+
"id": "R12",
|
| 216 |
+
"category": "physics",
|
| 217 |
+
"importance": "major",
|
| 218 |
+
"subject": "Initial descent and cross-bowl line",
|
| 219 |
+
"requirement_source": "prompt_explicit",
|
| 220 |
+
"evidence_type": "render",
|
| 221 |
+
"criterion": "The skater begins on the left transition and follows a continuous curved turning line across the bowl toward the right wall.",
|
| 222 |
+
"pass_condition": "Early playback shows the skater descending from the left curved wall into the lower bowl and continuing along a connected, visibly curved trajectory toward the opposite right transition.",
|
| 223 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 224 |
+
"category_v2": "physics",
|
| 225 |
+
"importance_weight": 3,
|
| 226 |
+
"score_type": "binary",
|
| 227 |
+
"score_values": [
|
| 228 |
+
0,
|
| 229 |
+
1
|
| 230 |
+
]
|
| 231 |
+
},
|
| 232 |
+
{
|
| 233 |
+
"id": "R13",
|
| 234 |
+
"category": "physics",
|
| 235 |
+
"importance": "major",
|
| 236 |
+
"subject": "Right-wall climb",
|
| 237 |
+
"requirement_source": "prompt_explicit",
|
| 238 |
+
"evidence_type": "render",
|
| 239 |
+
"criterion": "Around mid-clip, the skater rides high up the right curved wall toward the rim.",
|
| 240 |
+
"pass_condition": "The skateboard visibly climbs the right transition and reaches a high point near its upper edge at approximately the reference phase.",
|
| 241 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 242 |
+
"category_v2": "physics",
|
| 243 |
+
"importance_weight": 3,
|
| 244 |
+
"score_type": "binary",
|
| 245 |
+
"score_values": [
|
| 246 |
+
0,
|
| 247 |
+
1
|
| 248 |
+
]
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"id": "R14",
|
| 252 |
+
"category": "physics",
|
| 253 |
+
"importance": "major",
|
| 254 |
+
"subject": "High-wall turn and return",
|
| 255 |
+
"requirement_source": "reference_visible",
|
| 256 |
+
"evidence_type": "render",
|
| 257 |
+
"criterion": "After the right-wall high point, the skater turns, descends into the bowl, and moves leftward.",
|
| 258 |
+
"pass_condition": "Late playback clearly shows direction reversal on the high right transition followed by renewed descent and leftward movement by the end.",
|
| 259 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 260 |
+
"category_v2": "physics",
|
| 261 |
+
"importance_weight": 3,
|
| 262 |
+
"score_type": "binary",
|
| 263 |
+
"score_values": [
|
| 264 |
+
0,
|
| 265 |
+
1
|
| 266 |
+
]
|
| 267 |
+
},
|
| 268 |
+
{
|
| 269 |
+
"id": "R15",
|
| 270 |
+
"category": "physics",
|
| 271 |
+
"importance": "major",
|
| 272 |
+
"subject": "Rider and board coherence",
|
| 273 |
+
"requirement_source": "inferred_physics",
|
| 274 |
+
"evidence_type": "render",
|
| 275 |
+
"criterion": "Articulated rider poses, board placement, and surface contact remain physically coherent throughout the maneuver.",
|
| 276 |
+
"pass_condition": "The rider uses articulated poses and orientation changes that credibly support the maneuver, while the board remains plausibly under the feet and follows the curved concrete without obvious hovering, penetration, or uncontrolled sliding.",
|
| 277 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 278 |
+
"category_v2": "physics",
|
| 279 |
+
"importance_weight": 3,
|
| 280 |
+
"score_type": "binary",
|
| 281 |
+
"score_values": [
|
| 282 |
+
0,
|
| 283 |
+
1
|
| 284 |
+
]
|
| 285 |
+
},
|
| 286 |
+
{
|
| 287 |
+
"id": "R16",
|
| 288 |
+
"category": "function",
|
| 289 |
+
"importance": "major",
|
| 290 |
+
"subject": "Action timing",
|
| 291 |
+
"requirement_source": "prompt_explicit",
|
| 292 |
+
"evidence_type": "render",
|
| 293 |
+
"criterion": "The maneuver follows the reference's event order and approximate phase timing.",
|
| 294 |
+
"pass_condition": "Across the roughly 2.7-second playback, phases occur in order—initial descent, cross-bowl travel, high right-wall approach and turn, then descent back left—with broadly reference-like pacing.",
|
| 295 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 296 |
+
"category_v2": "function",
|
| 297 |
+
"importance_weight": 3,
|
| 298 |
+
"score_type": "binary",
|
| 299 |
+
"score_values": [
|
| 300 |
+
0,
|
| 301 |
+
1
|
| 302 |
+
]
|
| 303 |
+
},
|
| 304 |
+
{
|
| 305 |
+
"id": "R17",
|
| 306 |
+
"category": "composition",
|
| 307 |
+
"importance": "major",
|
| 308 |
+
"subject": "Camera framing and movement",
|
| 309 |
+
"requirement_source": "prompt_explicit",
|
| 310 |
+
"evidence_type": "render",
|
| 311 |
+
"criterion": "The camera uses the reference's elevated wide composition and restrained lateral reframing while preserving action and environment readability.",
|
| 312 |
+
"pass_condition": "Most of the bowl remains readable, the skater stays visible, the rim, spectators, beach, ocean, and horizon remain across the upper frame, and the stable elevated view shifts laterally with the skater without a dramatic orbit or zoom.",
|
| 313 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 314 |
+
"category_v2": "composition",
|
| 315 |
+
"importance_weight": 3,
|
| 316 |
+
"score_type": "binary",
|
| 317 |
+
"score_values": [
|
| 318 |
+
0,
|
| 319 |
+
1
|
| 320 |
+
]
|
| 321 |
+
},
|
| 322 |
+
{
|
| 323 |
+
"id": "R18",
|
| 324 |
+
"category": "function",
|
| 325 |
+
"importance": "major",
|
| 326 |
+
"subject": "Delivered video file",
|
| 327 |
+
"requirement_source": "prompt_explicit",
|
| 328 |
+
"evidence_type": "scene_summary",
|
| 329 |
+
"criterion": "The delivered video has the specified container, codec, dimensions, frame rate, and approximate duration.",
|
| 330 |
+
"pass_condition": "Decoded metadata confirms an H.264-encoded .mp4 at 3840×2160 and 30 fps, with duration approximately matching 2.7 seconds.",
|
| 331 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 332 |
+
"category_v2": "function",
|
| 333 |
+
"importance_weight": 3,
|
| 334 |
+
"score_type": "binary",
|
| 335 |
+
"score_values": [
|
| 336 |
+
0,
|
| 337 |
+
1
|
| 338 |
+
]
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
"id": "R19",
|
| 342 |
+
"category": "function",
|
| 343 |
+
"importance": "major",
|
| 344 |
+
"subject": "Delivered Blender project",
|
| 345 |
+
"requirement_source": "prompt_explicit",
|
| 346 |
+
"evidence_type": "scene_summary",
|
| 347 |
+
"criterion": "An openable .blend project contains the substantive editable scene systems required for the recreated previz.",
|
| 348 |
+
"pass_condition": "The delivered .blend opens and contains substantive bowl and skater geometry, the articulated skater rig and animation, an active camera, assigned materials, and active lighting.",
|
| 349 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 350 |
+
"category_v2": "function",
|
| 351 |
+
"importance_weight": 3,
|
| 352 |
+
"score_type": "binary",
|
| 353 |
+
"score_values": [
|
| 354 |
+
0,
|
| 355 |
+
1
|
| 356 |
+
]
|
| 357 |
+
}
|
| 358 |
+
]
|
| 359 |
+
}
|
| 360 |
+
]
|
| 361 |
+
}
|
bw_0220/tests/dataset/tasks/bw_0220/query.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
I'm a teacher preparing a skateboarding lesson, and I need a previz from this reference to review framing with students and try other angles later. Recreate the seaside concrete bowl, with coastline and spectators visible above the rim, then fully rig and animate the skater descending the curved surface, turning, and riding up the wall on the reference timing. The priority is matching the skater’s turning line across the bowl’s curvature; camera framing and movement should match the source. Keep materials, lighting and atmosphere faithful, but use your judgment on details. Deliver an H.264 .mp4 at 3840×2160, 30 fps, matching the clip’s roughly 2.7-second duration, plus the .blend project.
|
bw_0220/tests/dataset/tasks/bw_0220/references/video_01.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c303fbccfd11403ec2eef3a1ce56d85cb2f02bf833e83b03fdcf5b89eaf50d75
|
| 3 |
+
size 10879207
|
bw_0220/tests/dataset/tasks/bw_0220/rubric.json
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "bw_0220",
|
| 3 |
+
"prompt": "I'm a teacher preparing a skateboarding lesson, and I need a previz from this reference to review framing with students and try other angles later. Recreate the seaside concrete bowl, with coastline and spectators visible above the rim, then fully rig and animate the skater descending the curved surface, turning, and riding up the wall on the reference timing. The priority is matching the skater’s turning line across the bowl’s curvature; camera framing and movement should match the source. Keep materials, lighting and atmosphere faithful, but use your judgment on details. Deliver an H.264 .mp4 at 3840×2160, 30 fps, matching the clip’s roughly 2.7-second duration, plus the .blend project.",
|
| 4 |
+
"lang": "en",
|
| 5 |
+
"mode": "prompt_image",
|
| 6 |
+
"attachments": [
|
| 7 |
+
{
|
| 8 |
+
"file": "references/video_01.mp4"
|
| 9 |
+
}
|
| 10 |
+
],
|
| 11 |
+
"image_file": null,
|
| 12 |
+
"rubric_count": 19,
|
| 13 |
+
"rubrics": [
|
| 14 |
+
{
|
| 15 |
+
"id": "R01",
|
| 16 |
+
"category": "geometry",
|
| 17 |
+
"importance": "major",
|
| 18 |
+
"subject": "Primary skate bowl",
|
| 19 |
+
"requirement_source": "prompt_explicit",
|
| 20 |
+
"evidence_type": "render",
|
| 21 |
+
"criterion": "The primary environment is a recognizable seaside concrete bowl with the reference's deep irregular continuous geometry.",
|
| 22 |
+
"pass_condition": "The video clearly shows a concrete bowl in a seaside setting, with a broad lower riding area, steep upper walls, and smooth concave transitions forming a deep irregular reference-like basin.",
|
| 23 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 24 |
+
"category_v2": "geometry",
|
| 25 |
+
"importance_weight": 3,
|
| 26 |
+
"score_type": "binary",
|
| 27 |
+
"score_values": [
|
| 28 |
+
0,
|
| 29 |
+
1
|
| 30 |
+
]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"id": "R02",
|
| 34 |
+
"category": "presence",
|
| 35 |
+
"importance": "major",
|
| 36 |
+
"subject": "Skater and skateboard",
|
| 37 |
+
"requirement_source": "prompt_explicit",
|
| 38 |
+
"evidence_type": "render",
|
| 39 |
+
"criterion": "A recognizable human skater riding a recognizable skateboard is the principal animated subject.",
|
| 40 |
+
"pass_condition": "The delivered video clearly presents a human rider and skateboard as the main moving subject.",
|
| 41 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 42 |
+
"category_v2": "presence",
|
| 43 |
+
"importance_weight": 3,
|
| 44 |
+
"score_type": "binary",
|
| 45 |
+
"score_values": [
|
| 46 |
+
0,
|
| 47 |
+
1
|
| 48 |
+
]
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"id": "R03",
|
| 52 |
+
"category": "count",
|
| 53 |
+
"importance": "secondary",
|
| 54 |
+
"subject": "Spectators above the rim",
|
| 55 |
+
"requirement_source": "prompt_explicit",
|
| 56 |
+
"evidence_type": "render",
|
| 57 |
+
"criterion": "Multiple spectators are visibly gathered on the deck above the bowl rim.",
|
| 58 |
+
"pass_condition": "A visibly plural group of human spectators can be seen on the upper deck above and beyond the rim.",
|
| 59 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 60 |
+
"category_v2": "count",
|
| 61 |
+
"importance_weight": 2,
|
| 62 |
+
"score_type": "binary",
|
| 63 |
+
"score_values": [
|
| 64 |
+
0,
|
| 65 |
+
1
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"id": "R04",
|
| 70 |
+
"category": "space_layout",
|
| 71 |
+
"importance": "secondary",
|
| 72 |
+
"subject": "Seaside background",
|
| 73 |
+
"requirement_source": "prompt_explicit",
|
| 74 |
+
"evidence_type": "render",
|
| 75 |
+
"criterion": "The background visibly establishes the sandy coastline, ocean, and distant horizon.",
|
| 76 |
+
"pass_condition": "Sandy beach, open sea, and a distant horizon are identifiable beyond the skatepark.",
|
| 77 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 78 |
+
"category_v2": "space_layout",
|
| 79 |
+
"importance_weight": 2,
|
| 80 |
+
"score_type": "binary",
|
| 81 |
+
"score_values": [
|
| 82 |
+
0,
|
| 83 |
+
1
|
| 84 |
+
]
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"id": "R05",
|
| 88 |
+
"category": "geometry",
|
| 89 |
+
"importance": "detail",
|
| 90 |
+
"subject": "Adjacent skatepark terrain",
|
| 91 |
+
"requirement_source": "reference_visible",
|
| 92 |
+
"evidence_type": "render",
|
| 93 |
+
"criterion": "The visible upper-deck setting includes reference-like adjacent rounded concrete skate terrain.",
|
| 94 |
+
"pass_condition": "Beyond the main rim, the visible deck includes simplified or detailed rounded concrete bowl or mound forms that preserve the reference setting.",
|
| 95 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 96 |
+
"category_v2": "geometry",
|
| 97 |
+
"importance_weight": 1,
|
| 98 |
+
"score_type": "binary",
|
| 99 |
+
"score_values": [
|
| 100 |
+
0,
|
| 101 |
+
1
|
| 102 |
+
]
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"id": "R06",
|
| 106 |
+
"category": "layout",
|
| 107 |
+
"importance": "major",
|
| 108 |
+
"subject": "Foreground-to-background layering",
|
| 109 |
+
"requirement_source": "reference_visible",
|
| 110 |
+
"evidence_type": "render",
|
| 111 |
+
"criterion": "The bowl, rim deck, spectators, beach, and ocean follow the reference's layered spatial arrangement.",
|
| 112 |
+
"pass_condition": "The bowl occupies the foreground, spectators stand above it on the elevated rim deck, and beach and ocean remain beyond that deck.",
|
| 113 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 114 |
+
"category_v2": "layout",
|
| 115 |
+
"importance_weight": 3,
|
| 116 |
+
"score_type": "binary",
|
| 117 |
+
"score_values": [
|
| 118 |
+
0,
|
| 119 |
+
1
|
| 120 |
+
]
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"id": "R07",
|
| 124 |
+
"category": "scale",
|
| 125 |
+
"importance": "secondary",
|
| 126 |
+
"subject": "Human-relative scene scale",
|
| 127 |
+
"requirement_source": "holistic",
|
| 128 |
+
"evidence_type": "render",
|
| 129 |
+
"criterion": "The bowl, deck, people, and skateboard maintain mutually credible human-scale proportions.",
|
| 130 |
+
"pass_condition": "The rider and spectators plausibly fit the deck and bowl, and the skateboard has a credible size relative to the rider and riding surface.",
|
| 131 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 132 |
+
"category_v2": "scale",
|
| 133 |
+
"importance_weight": 2,
|
| 134 |
+
"score_type": "binary",
|
| 135 |
+
"score_values": [
|
| 136 |
+
0,
|
| 137 |
+
1
|
| 138 |
+
]
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"id": "R08",
|
| 142 |
+
"category": "material",
|
| 143 |
+
"importance": "secondary",
|
| 144 |
+
"subject": "Bowl concrete",
|
| 145 |
+
"requirement_source": "reference_visible",
|
| 146 |
+
"evidence_type": "render",
|
| 147 |
+
"criterion": "The bowl reads as weathered gray concrete with reference-like variation between sunlit and shaded surfaces.",
|
| 148 |
+
"pass_condition": "Sunlit surfaces appear pale to medium gray and subtly varied, while shaded steep walls are distinctly darker yet still read as concrete.",
|
| 149 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 150 |
+
"category_v2": "material",
|
| 151 |
+
"importance_weight": 2,
|
| 152 |
+
"score_type": "binary",
|
| 153 |
+
"score_values": [
|
| 154 |
+
0,
|
| 155 |
+
1
|
| 156 |
+
]
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"id": "R09",
|
| 160 |
+
"category": "material",
|
| 161 |
+
"importance": "detail",
|
| 162 |
+
"subject": "Bowl rim treatment",
|
| 163 |
+
"requirement_source": "reference_visible",
|
| 164 |
+
"evidence_type": "render",
|
| 165 |
+
"criterion": "A narrow pale segmented coping or tile band visibly follows the upper bowl edge.",
|
| 166 |
+
"pass_condition": "A contrasting light-colored strip with readable repeated segmentation follows the curved rim in the delivered video; exact segment count and construction are unrestricted.",
|
| 167 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 168 |
+
"category_v2": "material",
|
| 169 |
+
"importance_weight": 1,
|
| 170 |
+
"score_type": "binary",
|
| 171 |
+
"score_values": [
|
| 172 |
+
0,
|
| 173 |
+
1
|
| 174 |
+
]
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"id": "R10",
|
| 178 |
+
"category": "lighting",
|
| 179 |
+
"importance": "secondary",
|
| 180 |
+
"subject": "Coastal daylight and atmosphere",
|
| 181 |
+
"requirement_source": "prompt_explicit",
|
| 182 |
+
"evidence_type": "render",
|
| 183 |
+
"criterion": "Lighting and atmosphere reproduce the bright, clear, high-contrast coastal daylight of the reference.",
|
| 184 |
+
"pass_condition": "The video shows a bright blue sky and coastal atmosphere with crisp directional shadows and strong but readable sunlit-to-shaded contrast.",
|
| 185 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 186 |
+
"category_v2": "lighting",
|
| 187 |
+
"importance_weight": 2,
|
| 188 |
+
"score_type": "binary",
|
| 189 |
+
"score_values": [
|
| 190 |
+
0,
|
| 191 |
+
1
|
| 192 |
+
]
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"id": "R11",
|
| 196 |
+
"category": "function",
|
| 197 |
+
"importance": "major",
|
| 198 |
+
"subject": "Skater rig",
|
| 199 |
+
"requirement_source": "prompt_explicit",
|
| 200 |
+
"evidence_type": "scene_summary",
|
| 201 |
+
"criterion": "The skater is controlled by a genuine articulated rig used by the delivered animation.",
|
| 202 |
+
"pass_condition": "The .blend contains an armature or equivalent articulated control system bound to the skater, with animation data driving the displayed body poses.",
|
| 203 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 204 |
+
"category_v2": "function",
|
| 205 |
+
"importance_weight": 3,
|
| 206 |
+
"score_type": "binary",
|
| 207 |
+
"score_values": [
|
| 208 |
+
0,
|
| 209 |
+
1
|
| 210 |
+
]
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"id": "R12",
|
| 214 |
+
"category": "physics",
|
| 215 |
+
"importance": "major",
|
| 216 |
+
"subject": "Initial descent and cross-bowl line",
|
| 217 |
+
"requirement_source": "prompt_explicit",
|
| 218 |
+
"evidence_type": "render",
|
| 219 |
+
"criterion": "The skater begins on the left transition and follows a continuous curved turning line across the bowl toward the right wall.",
|
| 220 |
+
"pass_condition": "Early playback shows the skater descending from the left curved wall into the lower bowl and continuing along a connected, visibly curved trajectory toward the opposite right transition.",
|
| 221 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 222 |
+
"category_v2": "physics",
|
| 223 |
+
"importance_weight": 3,
|
| 224 |
+
"score_type": "binary",
|
| 225 |
+
"score_values": [
|
| 226 |
+
0,
|
| 227 |
+
1
|
| 228 |
+
]
|
| 229 |
+
},
|
| 230 |
+
{
|
| 231 |
+
"id": "R13",
|
| 232 |
+
"category": "physics",
|
| 233 |
+
"importance": "major",
|
| 234 |
+
"subject": "Right-wall climb",
|
| 235 |
+
"requirement_source": "prompt_explicit",
|
| 236 |
+
"evidence_type": "render",
|
| 237 |
+
"criterion": "Around mid-clip, the skater rides high up the right curved wall toward the rim.",
|
| 238 |
+
"pass_condition": "The skateboard visibly climbs the right transition and reaches a high point near its upper edge at approximately the reference phase.",
|
| 239 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 240 |
+
"category_v2": "physics",
|
| 241 |
+
"importance_weight": 3,
|
| 242 |
+
"score_type": "binary",
|
| 243 |
+
"score_values": [
|
| 244 |
+
0,
|
| 245 |
+
1
|
| 246 |
+
]
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"id": "R14",
|
| 250 |
+
"category": "physics",
|
| 251 |
+
"importance": "major",
|
| 252 |
+
"subject": "High-wall turn and return",
|
| 253 |
+
"requirement_source": "reference_visible",
|
| 254 |
+
"evidence_type": "render",
|
| 255 |
+
"criterion": "After the right-wall high point, the skater turns, descends into the bowl, and moves leftward.",
|
| 256 |
+
"pass_condition": "Late playback clearly shows direction reversal on the high right transition followed by renewed descent and leftward movement by the end.",
|
| 257 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 258 |
+
"category_v2": "physics",
|
| 259 |
+
"importance_weight": 3,
|
| 260 |
+
"score_type": "binary",
|
| 261 |
+
"score_values": [
|
| 262 |
+
0,
|
| 263 |
+
1
|
| 264 |
+
]
|
| 265 |
+
},
|
| 266 |
+
{
|
| 267 |
+
"id": "R15",
|
| 268 |
+
"category": "physics",
|
| 269 |
+
"importance": "major",
|
| 270 |
+
"subject": "Rider and board coherence",
|
| 271 |
+
"requirement_source": "inferred_physics",
|
| 272 |
+
"evidence_type": "render",
|
| 273 |
+
"criterion": "Articulated rider poses, board placement, and surface contact remain physically coherent throughout the maneuver.",
|
| 274 |
+
"pass_condition": "The rider uses articulated poses and orientation changes that credibly support the maneuver, while the board remains plausibly under the feet and follows the curved concrete without obvious hovering, penetration, or uncontrolled sliding.",
|
| 275 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 276 |
+
"category_v2": "physics",
|
| 277 |
+
"importance_weight": 3,
|
| 278 |
+
"score_type": "binary",
|
| 279 |
+
"score_values": [
|
| 280 |
+
0,
|
| 281 |
+
1
|
| 282 |
+
]
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"id": "R16",
|
| 286 |
+
"category": "function",
|
| 287 |
+
"importance": "major",
|
| 288 |
+
"subject": "Action timing",
|
| 289 |
+
"requirement_source": "prompt_explicit",
|
| 290 |
+
"evidence_type": "render",
|
| 291 |
+
"criterion": "The maneuver follows the reference's event order and approximate phase timing.",
|
| 292 |
+
"pass_condition": "Across the roughly 2.7-second playback, phases occur in order—initial descent, cross-bowl travel, high right-wall approach and turn, then descent back left—with broadly reference-like pacing.",
|
| 293 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 294 |
+
"category_v2": "function",
|
| 295 |
+
"importance_weight": 3,
|
| 296 |
+
"score_type": "binary",
|
| 297 |
+
"score_values": [
|
| 298 |
+
0,
|
| 299 |
+
1
|
| 300 |
+
]
|
| 301 |
+
},
|
| 302 |
+
{
|
| 303 |
+
"id": "R17",
|
| 304 |
+
"category": "composition",
|
| 305 |
+
"importance": "major",
|
| 306 |
+
"subject": "Camera framing and movement",
|
| 307 |
+
"requirement_source": "prompt_explicit",
|
| 308 |
+
"evidence_type": "render",
|
| 309 |
+
"criterion": "The camera uses the reference's elevated wide composition and restrained lateral reframing while preserving action and environment readability.",
|
| 310 |
+
"pass_condition": "Most of the bowl remains readable, the skater stays visible, the rim, spectators, beach, ocean, and horizon remain across the upper frame, and the stable elevated view shifts laterally with the skater without a dramatic orbit or zoom.",
|
| 311 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 312 |
+
"category_v2": "composition",
|
| 313 |
+
"importance_weight": 3,
|
| 314 |
+
"score_type": "binary",
|
| 315 |
+
"score_values": [
|
| 316 |
+
0,
|
| 317 |
+
1
|
| 318 |
+
]
|
| 319 |
+
},
|
| 320 |
+
{
|
| 321 |
+
"id": "R18",
|
| 322 |
+
"category": "function",
|
| 323 |
+
"importance": "major",
|
| 324 |
+
"subject": "Delivered video file",
|
| 325 |
+
"requirement_source": "prompt_explicit",
|
| 326 |
+
"evidence_type": "scene_summary",
|
| 327 |
+
"criterion": "The delivered video has the specified container, codec, dimensions, frame rate, and approximate duration.",
|
| 328 |
+
"pass_condition": "Decoded metadata confirms an H.264-encoded .mp4 at 3840×2160 and 30 fps, with duration approximately matching 2.7 seconds.",
|
| 329 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 330 |
+
"category_v2": "function",
|
| 331 |
+
"importance_weight": 3,
|
| 332 |
+
"score_type": "binary",
|
| 333 |
+
"score_values": [
|
| 334 |
+
0,
|
| 335 |
+
1
|
| 336 |
+
]
|
| 337 |
+
},
|
| 338 |
+
{
|
| 339 |
+
"id": "R19",
|
| 340 |
+
"category": "function",
|
| 341 |
+
"importance": "major",
|
| 342 |
+
"subject": "Delivered Blender project",
|
| 343 |
+
"requirement_source": "prompt_explicit",
|
| 344 |
+
"evidence_type": "scene_summary",
|
| 345 |
+
"criterion": "An openable .blend project contains the substantive editable scene systems required for the recreated previz.",
|
| 346 |
+
"pass_condition": "The delivered .blend opens and contains substantive bowl and skater geometry, the articulated skater rig and animation, an active camera, assigned materials, and active lighting.",
|
| 347 |
+
"fail_condition": "The pass condition is not fully satisfied.",
|
| 348 |
+
"category_v2": "function",
|
| 349 |
+
"importance_weight": 3,
|
| 350 |
+
"score_type": "binary",
|
| 351 |
+
"score_values": [
|
| 352 |
+
0,
|
| 353 |
+
1
|
| 354 |
+
]
|
| 355 |
+
}
|
| 356 |
+
]
|
| 357 |
+
}
|
bw_0220/tests/dataset/tasks/bw_0220/task.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": 1,
|
| 3 |
+
"task_id": "bw_0220",
|
| 4 |
+
"modality": "video",
|
| 5 |
+
"query": "I'm a teacher preparing a skateboarding lesson, and I need a previz from this reference to review framing with students and try other angles later. Recreate the seaside concrete bowl, with coastline and spectators visible above the rim, then fully rig and animate the skater descending the curved surface, turning, and riding up the wall on the reference timing. The priority is matching the skater’s turning line across the bowl’s curvature; camera framing and movement should match the source. Keep materials, lighting and atmosphere faithful, but use your judgment on details. Deliver an H.264 .mp4 at 3840×2160, 30 fps, matching the clip’s roughly 2.7-second duration, plus the .blend project.",
|
| 6 |
+
"query_file": "tasks/bw_0220/query.txt",
|
| 7 |
+
"rubric_file": "tasks/bw_0220/rubric.json",
|
| 8 |
+
"rubric_count": 19,
|
| 9 |
+
"rubric_prompt_matches_query": true,
|
| 10 |
+
"annotation_status": "ready",
|
| 11 |
+
"attachments": [],
|
| 12 |
+
"supplemental_attachments": [],
|
| 13 |
+
"reference_images": [],
|
| 14 |
+
"reference_videos": [
|
| 15 |
+
{
|
| 16 |
+
"path": "tasks/bw_0220/references/video_01.mp4",
|
| 17 |
+
"task_relative_path": "references/video_01.mp4",
|
| 18 |
+
"bytes": 10879207,
|
| 19 |
+
"sha256": "c303fbccfd11403ec2eef3a1ce56d85cb2f02bf833e83b03fdcf5b89eaf50d75"
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"rubric_reference_images": [],
|
| 23 |
+
"metadata": {
|
| 24 |
+
"lang": "en",
|
| 25 |
+
"category": "Art & Animation",
|
| 26 |
+
"subcategory": "Animation, Motion & Art",
|
| 27 |
+
"domain": "skateboard_bowl",
|
| 28 |
+
"persona": "intermediate",
|
| 29 |
+
"length": "detailed",
|
| 30 |
+
"complexity": "very_hard",
|
| 31 |
+
"ref_style": "recreate",
|
| 32 |
+
"input_form": "video+text",
|
| 33 |
+
"use_case": "video_storyboard",
|
| 34 |
+
"visual_focus": [
|
| 35 |
+
"滑板者沿碗池曲面的转弯线路"
|
| 36 |
+
],
|
| 37 |
+
"category_short": "Animation",
|
| 38 |
+
"subcategory_short": "Motion art",
|
| 39 |
+
"taxonomy_version": "taxonomy_223"
|
| 40 |
+
}
|
| 41 |
+
}
|
bw_0220/tests/install_blender.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
version=4.2.10
|
| 4 |
+
filename="blender-${version}-linux-x64.tar.xz"
|
| 5 |
+
base_url="https://download.blender.org/release/Blender4.2"
|
| 6 |
+
checksum=7b888b36cf5bd7e35d495eb9717f7a9b645ea5f2fb4fe9850991800b8f08d531
|
| 7 |
+
curl --fail --location --retry 3 "${base_url}/${filename}" -o "/tmp/${filename}" || \
|
| 8 |
+
curl --fail --location --retry 3 "https://mirrors.ocf.berkeley.edu/blender/release/Blender4.2/${filename}" -o "/tmp/${filename}"
|
| 9 |
+
cd /tmp
|
| 10 |
+
printf '%s %s\n' "$checksum" "$filename" | sha256sum --check -
|
| 11 |
+
mkdir -p /opt/blender
|
| 12 |
+
tar -xJf "$filename" --strip-components=1 -C /opt/blender
|
| 13 |
+
/opt/blender/4.2/python/bin/python3.11 -m ensurepip
|
| 14 |
+
/opt/blender/4.2/python/bin/python3.11 -m pip install --no-cache-dir requests==2.32.5
|
| 15 |
+
rm "/tmp/${filename}"
|
| 16 |
+
/opt/blender/blender --background --factory-startup --python-exit-code 2 --python-expr 'import bpy, requests; assert bpy.app.version == (4, 2, 10), bpy.app.version_string; print(bpy.app.version_string)'
|
bw_0220/tests/requirements-verifier.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
requests==2.32.5
|
| 2 |
+
Pillow==11.3.0
|
| 3 |
+
json-repair==0.50.1
|
| 4 |
+
huggingface-hub==0.35.3
|
bw_0220/tests/test.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
exec python -m blenderworld.harbor_verify \
|
| 4 |
+
--dataset "${BW_HARBOR_DATASET:-/tests/dataset}" \
|
| 5 |
+
--submission "${BW_HARBOR_SUBMISSION:-/workspace/exports}" \
|
| 6 |
+
--output "${BW_HARBOR_OUTPUT:-/logs/verifier}"
|
bw_0221/environment/Dockerfile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:22.17.0-bookworm-slim AS node
|
| 2 |
+
FROM python:3.12-slim-bookworm
|
| 3 |
+
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
+
BLENDER_BIN=/opt/blender/blender \
|
| 6 |
+
BLENDER_MCP_ADDON_PATH=/opt/bw-mcp/addon.py \
|
| 7 |
+
BLENDERMCP_NO_UPDATE_CHECK=1 \
|
| 8 |
+
DISABLE_AUTOUPDATER=1 \
|
| 9 |
+
PATH=/opt/blender:/usr/local/bin:/usr/bin:/bin
|
| 10 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
+
bash ca-certificates curl xz-utils ffmpeg xvfb xauth procps \
|
| 12 |
+
libx11-6 libxi6 libxfixes3 libxrender1 libxxf86vm1 libxkbcommon0 \
|
| 13 |
+
libgl1 libegl1 libsm6 libice6 libdbus-1-3 libgomp1 libfontconfig1 \
|
| 14 |
+
fonts-dejavu-core && rm -rf /var/lib/apt/lists/*
|
| 15 |
+
COPY install_blender.sh /opt/install_blender.sh
|
| 16 |
+
RUN bash /opt/install_blender.sh
|
| 17 |
+
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
| 18 |
+
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
|
| 19 |
+
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
|
| 20 |
+
&& ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
|
| 21 |
+
&& npm install --global @openai/codex@0.147.0 @anthropic-ai/claude-code@2.1.220 \
|
| 22 |
+
&& test "$(node --version)" = "v22.17.0" \
|
| 23 |
+
&& test "$(codex --version)" = "codex-cli 0.147.0" \
|
| 24 |
+
&& test "$(claude --version)" = "2.1.220 (Claude Code)"
|
| 25 |
+
COPY requirements-tools.txt /opt/requirements-tools.txt
|
| 26 |
+
RUN python -m pip install --no-cache-dir -r /opt/requirements-tools.txt
|
| 27 |
+
RUN python -m venv /opt/bw-mcp \
|
| 28 |
+
&& /opt/bw-mcp/bin/pip install --no-cache-dir mcp-for-blender==2.1.3 mcp==1.30.0 \
|
| 29 |
+
&& /opt/bw-mcp/bin/python -c "from importlib.resources import files; from pathlib import Path; Path('/opt/bw-mcp/addon.py').write_bytes(files('blender_mcp').joinpath('bundled/addon.py').read_bytes())"
|
| 30 |
+
COPY mcp_bridge.py /usr/local/bin/bw-blender-mcp
|
| 31 |
+
COPY blender_startup.py /usr/local/bin/blender_startup.py
|
| 32 |
+
COPY LICENSE /usr/local/share/licenses/BlenderWorld/LICENSE
|
| 33 |
+
RUN chmod 755 /usr/local/bin/bw-blender-mcp \
|
| 34 |
+
&& mkdir -p /workspace/exports /logs/artifacts
|
| 35 |
+
COPY inputs/ /workspace/inputs/
|
| 36 |
+
WORKDIR /workspace
|
| 37 |
+
CMD ["sleep", "infinity"]
|
bw_0221/environment/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 BlenderWorld contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
bw_0221/environment/blender_startup.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Start the bundled, versioned MCP addon in an interactive Blender session."""
|
| 2 |
+
import importlib.util
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
import bpy
|
| 7 |
+
|
| 8 |
+
if bpy.app.version != (4, 2, 10):
|
| 9 |
+
raise RuntimeError("BlenderWorld requires Blender 4.2.10")
|
| 10 |
+
|
| 11 |
+
os.environ["BLENDERMCP_NO_UPDATE_CHECK"] = "1"
|
| 12 |
+
path = os.environ.get("BLENDER_MCP_ADDON_PATH", "/opt/bw-mcp/addon.py")
|
| 13 |
+
spec = importlib.util.spec_from_file_location("blendermcp", path)
|
| 14 |
+
addon = importlib.util.module_from_spec(spec)
|
| 15 |
+
sys.modules[spec.name] = addon
|
| 16 |
+
spec.loader.exec_module(addon)
|
| 17 |
+
addon.register()
|
| 18 |
+
bpy.context.scene.blendermcp_port = int(os.environ["BLENDER_PORT"])
|
| 19 |
+
bpy.context.scene.blendermcp_auto_start_server = True
|
| 20 |
+
bpy.context.scene.blendermcp_use_polyhaven = True
|
| 21 |
+
print("BlenderWorld MCP addon registered", flush=True)
|
bw_0221/environment/inputs/input.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "bw_0221",
|
| 3 |
+
"query_file": "query.txt",
|
| 4 |
+
"files": [
|
| 5 |
+
"references/video_01.mp4",
|
| 6 |
+
"instruction.html",
|
| 7 |
+
"reference_images.base64.json"
|
| 8 |
+
]
|
| 9 |
+
}
|
bw_0221/environment/inputs/instruction.html
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>BlenderWorld · bw_0221</title><style>
|
| 3 |
+
:root{color-scheme:light;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans CJK SC",sans-serif;color:#153b43;background:#f3f7f5}
|
| 4 |
+
*{box-sizing:border-box}body{margin:0}main{max-width:1150px;margin:32px auto;padding:0 20px 45px}header{margin:0 0 23px}h1{font-size:28px;line-height:1.4;margin:7px 0}h2{font-size:19px;margin:0 0 16px}p{line-height:1.7}.label,.muted{font-size:12px;color:#58777c}.label{letter-spacing:2px}section{background:#fff;border:1px solid #dce8e2;border-radius:13px;padding:24px;margin:18px 0}pre{white-space:pre-wrap;overflow-wrap:anywhere;font:14px/1.8 inherit;margin:0}figure{margin:0 0 20px}figure img{display:block;width:100%;max-height:780px;object-fit:contain;background:#f5f7f5;border:1px solid #e2eae6;border-radius:9px}figcaption{font-size:12px;color:#58777c;margin-top:8px;overflow-wrap:anywhere}a{color:#086c62;text-underline-offset:3px;overflow-wrap:anywhere}video{max-width:100%;max-height:600px;display:block}details{border-top:1px solid #e2eae6;padding:13px 0}summary{cursor:pointer;font-weight:600}details pre{margin-top:14px;font-size:12px}code{overflow-wrap:anywhere}input,select{font:inherit;padding:10px;border:1px solid #b9cdc4;border-radius:8px;background:#fff;color:inherit}.filters{display:flex;gap:10px;margin:20px 0}input{flex:1;min-width:0}table{width:100%;border-collapse:collapse;text-align:left;background:#fff}th,td{border-bottom:1px solid #e2eae6;padding:13px;font-size:13px}th{color:#58777c;font-size:12px}td:first-child{white-space:nowrap}.table{overflow:auto;border:1px solid #dce8e2;border-radius:10px}.hidden{display:none}@media(max-width:640px){main{margin-top:19px;padding:0 13px 25px}h1{font-size:22px}section{padding:17px}pre{font-size:13px}.filters{flex-wrap:wrap}input{flex-basis:100%}th,td{padding:10px}}
|
| 5 |
+
</style></head><body><main><header><div class="label">BLENDERWORLD · EMBEDDED IMAGE VIEW</div><h1>BW_0221</h1><p class="muted">video · 参考图片已以 Base64 内嵌,可离线查看。</p><p class="muted">Art & Animation / Animation, Motion & Art</p></header><section><h2>Query · 原始任务</h2><pre id="query">I'm making a short animation previz for a class project and need this reference rebuilt to check framing before changing angles. Reproduce the white snow slope, the black-helmeted snowboarder in black clothing, the snowboard, and the powder spray. Use an editable rig and animate the continuous edge changes and turns to match the clip's timing, camera framing, and movement. The priority is believable edge-driven carving, weight shifts, and powder kicked up by the board's tail. Match the clip's materials and lighting; use your judgment on the overall feel. Deliver an H.264 .mp4 at 1920x1080, 30fps, matching the reference's roughly 2.2-second length, plus the editable Blender .blend project.</pre></section><section><h2>参考视频</h2><p class="muted">视频保留为包内 MP4 文件,使用相对路径播放。</p><figure><video controls preload="metadata" src="references/video_01.mp4"></video><figcaption><a href="references/video_01.mp4">references/video_01.mp4</a></figcaption></figure></section><p class="muted">查看用页面。Harbor 入口为任务目录中的 instruction.md;评分标准仅保留在 tests/,不进入生成输入。</p></main></body></html>
|
bw_0221/environment/inputs/query.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
I'm making a short animation previz for a class project and need this reference rebuilt to check framing before changing angles. Reproduce the white snow slope, the black-helmeted snowboarder in black clothing, the snowboard, and the powder spray. Use an editable rig and animate the continuous edge changes and turns to match the clip's timing, camera framing, and movement. The priority is believable edge-driven carving, weight shifts, and powder kicked up by the board's tail. Match the clip's materials and lighting; use your judgment on the overall feel. Deliver an H.264 .mp4 at 1920x1080, 30fps, matching the reference's roughly 2.2-second length, plus the editable Blender .blend project.
|
bw_0221/environment/inputs/reference_images.base64.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": 1,
|
| 3 |
+
"encoding": "data-uri-base64",
|
| 4 |
+
"task_id": "bw_0221",
|
| 5 |
+
"images": []
|
| 6 |
+
}
|
bw_0221/environment/inputs/references/video_01.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70b736ac29e7c97c9850c55f05bdad13288fb2ecee7136e3511c753f8fc4207f
|
| 3 |
+
size 6990674
|
bw_0221/environment/install_blender.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
version=4.2.10
|
| 4 |
+
filename="blender-${version}-linux-x64.tar.xz"
|
| 5 |
+
base_url="https://download.blender.org/release/Blender4.2"
|
| 6 |
+
checksum=7b888b36cf5bd7e35d495eb9717f7a9b645ea5f2fb4fe9850991800b8f08d531
|
| 7 |
+
curl --fail --location --retry 3 "${base_url}/${filename}" -o "/tmp/${filename}" || \
|
| 8 |
+
curl --fail --location --retry 3 "https://mirrors.ocf.berkeley.edu/blender/release/Blender4.2/${filename}" -o "/tmp/${filename}"
|
| 9 |
+
cd /tmp
|
| 10 |
+
printf '%s %s\n' "$checksum" "$filename" | sha256sum --check -
|
| 11 |
+
mkdir -p /opt/blender
|
| 12 |
+
tar -xJf "$filename" --strip-components=1 -C /opt/blender
|
| 13 |
+
/opt/blender/4.2/python/bin/python3.11 -m ensurepip
|
| 14 |
+
/opt/blender/4.2/python/bin/python3.11 -m pip install --no-cache-dir requests==2.32.5
|
| 15 |
+
rm "/tmp/${filename}"
|
| 16 |
+
/opt/blender/blender --background --factory-startup --python-exit-code 2 --python-expr 'import bpy, requests; assert bpy.app.version == (4, 2, 10), bpy.app.version_string; print(bpy.app.version_string)'
|
bw_0221/environment/mcp_bridge.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/local/bin/python
|
| 2 |
+
"""Own a Blender session and expose its MCP server over clean stdio."""
|
| 3 |
+
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import signal
|
| 6 |
+
import socket
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def main():
|
| 13 |
+
env = os.environ.copy()
|
| 14 |
+
env.setdefault("PATH", "/opt/blender:/usr/local/bin:/usr/bin:/bin")
|
| 15 |
+
env["BLENDERMCP_NO_UPDATE_CHECK"] = "1"
|
| 16 |
+
env["BLENDER_MCP_DISABLE_TELEMETRY"] = "1"
|
| 17 |
+
env.setdefault("BLENDER_MCP_ADDON_PATH", "/opt/bw-mcp/addon.py")
|
| 18 |
+
# Separate ports allow multiple MCP clients without borrowing another client's scene.
|
| 19 |
+
with socket.socket() as reservation:
|
| 20 |
+
reservation.bind(("127.0.0.1", 0))
|
| 21 |
+
port = reservation.getsockname()[1]
|
| 22 |
+
env.update(BLENDER_HOST="127.0.0.1", BLENDER_PORT=str(port))
|
| 23 |
+
log = Path(env.get("BW_BLENDER_LOG", "/logs/artifacts/blender-mcp.log"))
|
| 24 |
+
log.parent.mkdir(parents=True, exist_ok=True)
|
| 25 |
+
blender = None
|
| 26 |
+
server = None
|
| 27 |
+
|
| 28 |
+
def interrupted(signum, _frame):
|
| 29 |
+
raise SystemExit(128 + signum)
|
| 30 |
+
|
| 31 |
+
for sig in (signal.SIGINT, signal.SIGTERM):
|
| 32 |
+
signal.signal(sig, interrupted)
|
| 33 |
+
try:
|
| 34 |
+
with log.open("a") as stream:
|
| 35 |
+
blender = subprocess.Popen(
|
| 36 |
+
["xvfb-run", "-a", env.get("BLENDER_BIN", "/opt/blender/blender"),
|
| 37 |
+
"--factory-startup", "--python-exit-code", "1", "--python",
|
| 38 |
+
str(Path(__file__).resolve().with_name("blender_startup.py"))],
|
| 39 |
+
env=env, stdout=stream, stderr=subprocess.STDOUT, start_new_session=True)
|
| 40 |
+
deadline = time.monotonic() + float(env.get("BW_MCP_STARTUP_TIMEOUT", "120"))
|
| 41 |
+
while True:
|
| 42 |
+
if blender.poll() is not None:
|
| 43 |
+
raise RuntimeError(f"Blender exited during startup; see {log}")
|
| 44 |
+
try:
|
| 45 |
+
with socket.create_connection(("127.0.0.1", port), timeout=0.25):
|
| 46 |
+
break
|
| 47 |
+
except OSError:
|
| 48 |
+
if time.monotonic() >= deadline:
|
| 49 |
+
raise RuntimeError(f"Blender MCP startup timed out; see {log}")
|
| 50 |
+
time.sleep(0.2)
|
| 51 |
+
# stdin stays connected to the MCP client. Only this process writes to stdout.
|
| 52 |
+
server = subprocess.Popen([env.get("BW_MCP_COMMAND", "/opt/bw-mcp/bin/mcp-for-blender")],
|
| 53 |
+
env=env, stdin=sys.stdin, stdout=sys.stdout,
|
| 54 |
+
stderr=sys.stderr, start_new_session=True)
|
| 55 |
+
return server.wait()
|
| 56 |
+
finally:
|
| 57 |
+
for process in (server, blender):
|
| 58 |
+
if process is None:
|
| 59 |
+
continue
|
| 60 |
+
# xvfb-run may exit before its descendants; terminate the owned process group.
|
| 61 |
+
try:
|
| 62 |
+
os.killpg(process.pid, signal.SIGTERM)
|
| 63 |
+
except ProcessLookupError:
|
| 64 |
+
pass
|
| 65 |
+
try:
|
| 66 |
+
process.wait(timeout=5)
|
| 67 |
+
except subprocess.TimeoutExpired:
|
| 68 |
+
try:
|
| 69 |
+
os.killpg(process.pid, signal.SIGKILL)
|
| 70 |
+
except ProcessLookupError:
|
| 71 |
+
pass
|
| 72 |
+
process.wait()
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
try:
|
| 77 |
+
raise SystemExit(main())
|
| 78 |
+
except (OSError, RuntimeError) as error:
|
| 79 |
+
print(f"BlenderWorld MCP: {error}", file=sys.stderr)
|
| 80 |
+
raise SystemExit(1)
|
bw_0221/environment/requirements-tools.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Supporting tools from Appendix D.2. These package versions are release pins;
|
| 2 |
+
# the paper specifies the tools but does not prescribe these package versions.
|
| 3 |
+
numpy==2.2.6
|
| 4 |
+
Pillow==11.3.0
|
| 5 |
+
scipy==1.15.3
|
| 6 |
+
imageio==2.37.0
|
bw_0221/instruction.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# BlenderWorld bw_0221
|
| 2 |
+
|
| 3 |
+
## Task
|
| 4 |
+
|
| 5 |
+
I'm making a short animation previz for a class project and need this reference rebuilt to check framing before changing angles. Reproduce the white snow slope, the black-helmeted snowboarder in black clothing, the snowboard, and the powder spray. Use an editable rig and animate the continuous edge changes and turns to match the clip's timing, camera framing, and movement. The priority is believable edge-driven carving, weight shifts, and powder kicked up by the board's tail. Match the clip's materials and lighting; use your judgment on the overall feel. Deliver an H.264 .mp4 at 1920x1080, 30fps, matching the reference's roughly 2.2-second length, plus the editable Blender .blend project.
|
| 6 |
+
|
| 7 |
+
## Inputs
|
| 8 |
+
|
| 9 |
+
The original request is also in `/workspace/inputs/query.txt`.
|
| 10 |
+
|
| 11 |
+
- `reference_videos`: `/workspace/inputs/references/video_01.mp4`
|
| 12 |
+
|
| 13 |
+
Read the supplied specifications and inspect the reference media before modeling. Relative filenames in the request refer to the files listed above.
|
| 14 |
+
|
| 15 |
+
## Deliverables
|
| 16 |
+
|
| 17 |
+
Save the editable project as `/workspace/exports/final.blend`. Put all requested images, videos, model exports, and texture dependencies under `/workspace/exports/`. Pack textures into the project or keep relative paths inside this directory so the project can be opened in a fresh environment.
|
| 18 |
+
|
| 19 |
+
## Tools
|
| 20 |
+
|
| 21 |
+
Blender is installed as `blender`. A Blender MCP server is configured for agents that support task MCP servers; use its advertised tools to inspect the scene, execute Blender Python, and capture viewport images. The Blender Python CLI is also available. Use Blender 4.2.10, Node.js 22.17.0, Codex CLI 0.147.0 or Claude Code 2.1.220; do not upgrade these tools. Inspect your result and save your work before finishing.
|
| 22 |
+
|
| 23 |
+
## Offline task preview
|
| 24 |
+
|
| 25 |
+
An HTML view of the task with embedded reference images is available at `/workspace/inputs/instruction.html`. Inspect the original reference image files listed under Inputs when modeling.
|
bw_0221/task.toml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
schema_version = "1.3"
|
| 2 |
+
artifacts = ["/workspace/exports"]
|
| 3 |
+
|
| 4 |
+
[task]
|
| 5 |
+
name = "Qwen/BlenderWorld-bw_0221"
|
| 6 |
+
description = "BlenderWorld bw_0221 (video)"
|
| 7 |
+
keywords = ["blender", "3d", "video"]
|
| 8 |
+
|
| 9 |
+
[metadata]
|
| 10 |
+
category = "Art & Animation"
|
| 11 |
+
subcategory = "Animation, Motion & Art"
|
| 12 |
+
category_short = "Animation"
|
| 13 |
+
subcategory_short = "Motion art"
|
| 14 |
+
taxonomy_version = "taxonomy_223"
|
| 15 |
+
task_id = "bw_0221"
|
| 16 |
+
modality = "video"
|
| 17 |
+
rubric_count = 19
|
| 18 |
+
protocol_version = 1
|
| 19 |
+
code_version = "0.3.0"
|
| 20 |
+
blender_version = "4.2.10"
|
| 21 |
+
node_version = "22.17.0"
|
| 22 |
+
codex_version = "0.147.0"
|
| 23 |
+
claude_code_version = "2.1.220"
|
| 24 |
+
submission_format = "blenderworld-submission-v1"
|
| 25 |
+
submission_project = "final.blend"
|
| 26 |
+
|
| 27 |
+
[agent]
|
| 28 |
+
timeout_sec = 28800
|
| 29 |
+
|
| 30 |
+
[environment]
|
| 31 |
+
build_timeout_sec = 3600
|
| 32 |
+
cpus = 8
|
| 33 |
+
memory_mb = 16384
|
| 34 |
+
storage_mb = 102400
|
| 35 |
+
gpus = 1
|
| 36 |
+
workdir = "/workspace"
|
| 37 |
+
|
| 38 |
+
[[environment.mcp_servers]]
|
| 39 |
+
name = "blender"
|
| 40 |
+
transport = "stdio"
|
| 41 |
+
command = "/usr/local/bin/bw-blender-mcp"
|
| 42 |
+
args = []
|
| 43 |
+
|
| 44 |
+
[verifier]
|
| 45 |
+
timeout_sec = 28800
|
| 46 |
+
environment_mode = "separate"
|
| 47 |
+
|
| 48 |
+
[verifier.environment]
|
| 49 |
+
build_timeout_sec = 3600
|
| 50 |
+
cpus = 8
|
| 51 |
+
memory_mb = 16384
|
| 52 |
+
storage_mb = 102400
|
| 53 |
+
gpus = 1
|
| 54 |
+
workdir = "/workspace"
|
| 55 |
+
|
| 56 |
+
[verifier.env]
|
| 57 |
+
ANTHROPIC_BASE_URL = "${BW_AGENT_JUDGE_ENDPOINT}"
|
| 58 |
+
ANTHROPIC_API_KEY = "${BW_AGENT_JUDGE_API_KEY}"
|
| 59 |
+
JUDGE_API_ENDPOINT = "${BW_VISION_JUDGE_ENDPOINT}"
|
| 60 |
+
JUDGE_API_KEY = "${BW_VISION_JUDGE_API_KEY}"
|
| 61 |
+
RENDER_AGENT_MODEL = "${BW_RENDER_MODEL:-gpt-5.6-terra}"
|
| 62 |
+
AGENT_JUDGE_MODEL = "${BW_AGENT_JUDGE_MODEL:-gpt-5.6-terra}"
|
| 63 |
+
JUDGE_MODEL = "${BW_VISION_JUDGE_MODEL:-gpt-5.6-terra}"
|
bw_0221/tests/Dockerfile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:22.17.0-bookworm-slim AS node
|
| 2 |
+
FROM python:3.12-slim-bookworm
|
| 3 |
+
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
+
BLENDER_BIN=/opt/blender/blender \
|
| 6 |
+
PYTHONPATH=/opt/blenderworld \
|
| 7 |
+
PATH=/opt/blender:/usr/local/bin:/usr/bin:/bin \
|
| 8 |
+
DISABLE_AUTOUPDATER=1
|
| 9 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
+
bash ca-certificates curl xz-utils ffmpeg xvfb xauth procps \
|
| 11 |
+
libx11-6 libxi6 libxfixes3 libxrender1 libxxf86vm1 libxkbcommon0 \
|
| 12 |
+
libgl1 libegl1 libsm6 libice6 libdbus-1-3 libgomp1 libfontconfig1 \
|
| 13 |
+
fonts-dejavu-core && rm -rf /var/lib/apt/lists/*
|
| 14 |
+
COPY install_blender.sh /opt/install_blender.sh
|
| 15 |
+
RUN bash /opt/install_blender.sh
|
| 16 |
+
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
| 17 |
+
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
|
| 18 |
+
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
|
| 19 |
+
&& ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
|
| 20 |
+
&& npm install --global @anthropic-ai/claude-code@2.1.220 \
|
| 21 |
+
&& test "$(node --version)" = "v22.17.0" \
|
| 22 |
+
&& test "$(claude --version)" = "2.1.220 (Claude Code)"
|
| 23 |
+
COPY requirements-verifier.txt /opt/requirements-verifier.txt
|
| 24 |
+
RUN python -m pip install --no-cache-dir -r /opt/requirements-verifier.txt
|
| 25 |
+
COPY blenderworld/ /opt/blenderworld/blenderworld/
|
| 26 |
+
COPY test.sh /tests/test.sh
|
| 27 |
+
COPY LICENSE /usr/local/share/licenses/BlenderWorld/LICENSE
|
| 28 |
+
RUN chmod 755 /tests/test.sh && mkdir -p /workspace /logs/verifier
|
| 29 |
+
COPY dataset/ /tests/dataset/
|
| 30 |
+
WORKDIR /workspace
|
| 31 |
+
CMD ["sleep", "infinity"]
|
bw_0221/tests/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 BlenderWorld contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
bw_0221/tests/blenderworld/__init__.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""BlenderWorld task preparation and evaluation."""
|
| 2 |
+
__version__ = "0.3.0"
|
bw_0221/tests/blenderworld/__main__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .cli import main
|
| 2 |
+
|
| 3 |
+
raise SystemExit(main())
|
bw_0221/tests/blenderworld/blender_runtime.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Loaded by Blender before the render agent's script; records real render attempts."""
|
| 2 |
+
import fcntl
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
import bpy
|
| 9 |
+
from bpy.app.handlers import persistent
|
| 10 |
+
|
| 11 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent / "evaluators"))
|
| 12 |
+
import asset_paths
|
| 13 |
+
|
| 14 |
+
if bpy.app.version != (4, 2, 10):
|
| 15 |
+
raise RuntimeError("BlenderWorld evaluation requires Blender 4.2.10")
|
| 16 |
+
|
| 17 |
+
asset_paths.register()
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def update_attempt(scene, completed=False):
|
| 21 |
+
folder = Path(os.environ["BLENDER_EVAL_VIEW_ROOT"]).resolve()
|
| 22 |
+
target = Path(bpy.path.abspath(scene.render.filepath)).resolve()
|
| 23 |
+
if not target.suffix and scene.render.use_file_extension:
|
| 24 |
+
target = target.with_suffix(".png")
|
| 25 |
+
if not target.is_relative_to(folder) or target.suffix.lower() != ".png":
|
| 26 |
+
raise RuntimeError("Evaluator renders must be PNGs inside evaluation/multiview")
|
| 27 |
+
state_path = folder / "render_attempts.json"
|
| 28 |
+
with (folder / ".render.lock").open("a") as lock:
|
| 29 |
+
fcntl.flock(lock, fcntl.LOCK_EX)
|
| 30 |
+
state = json.loads(state_path.read_text()) if state_path.exists() else {}
|
| 31 |
+
history = state.setdefault(str(target), [])
|
| 32 |
+
if completed:
|
| 33 |
+
if history:
|
| 34 |
+
history[-1]["completed"] = True
|
| 35 |
+
else:
|
| 36 |
+
if len(history) >= 3:
|
| 37 |
+
raise RuntimeError("Two corrective re-renders per view exhausted")
|
| 38 |
+
if (scene.render.engine != "CYCLES" or scene.cycles.samples != 64
|
| 39 |
+
or scene.render.resolution_x != 1024 or scene.render.resolution_y != 1024
|
| 40 |
+
or scene.render.resolution_percentage != 100):
|
| 41 |
+
raise RuntimeError("Required: Cycles, 64 samples, 1024x1024 at 100%")
|
| 42 |
+
history.append({"engine": scene.render.engine, "samples": scene.cycles.samples,
|
| 43 |
+
"device": scene.cycles.device, "completed": False})
|
| 44 |
+
temp = state_path.with_suffix(".tmp")
|
| 45 |
+
temp.write_text(json.dumps(state, indent=2))
|
| 46 |
+
temp.replace(state_path)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
@persistent
|
| 50 |
+
def before(scene, *_):
|
| 51 |
+
try:
|
| 52 |
+
update_attempt(scene)
|
| 53 |
+
except Exception as error:
|
| 54 |
+
# Blender ignores ordinary handler exceptions; abort this render subprocess.
|
| 55 |
+
print("BLENDERWORLD_RENDER_REJECTED", str(error), flush=True)
|
| 56 |
+
os._exit(2)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
@persistent
|
| 60 |
+
def after(scene, *_):
|
| 61 |
+
update_attempt(scene, completed=True)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
bpy.app.handlers.render_pre.append(before)
|
| 65 |
+
bpy.app.handlers.render_write.append(after)
|
bw_0221/tests/blenderworld/cli.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Command line interface for local task preparation and evaluation."""
|
| 2 |
+
import argparse
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from .data import load_tasks, prepare, verify
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def main():
|
| 11 |
+
parser = argparse.ArgumentParser(prog="bw", description="BlenderWorld benchmark tools")
|
| 12 |
+
commands = parser.add_subparsers(dest="command", required=True)
|
| 13 |
+
download = commands.add_parser("download", help="Download the frozen dataset from Hugging Face")
|
| 14 |
+
download.add_argument("--repo-id", default="Qwen/BlenderWorld")
|
| 15 |
+
download.add_argument("--revision", default="main")
|
| 16 |
+
download.add_argument("--output", default="data/BlenderWorld")
|
| 17 |
+
check = commands.add_parser("verify", help="Verify task content, paths and checksums")
|
| 18 |
+
check.add_argument("dataset")
|
| 19 |
+
listing = commands.add_parser("list", help="List tasks")
|
| 20 |
+
listing.add_argument("dataset")
|
| 21 |
+
listing.add_argument("--modality", choices=["text", "image", "video"])
|
| 22 |
+
staging = commands.add_parser("prepare", help="Stage a task's generator-visible inputs")
|
| 23 |
+
staging.add_argument("--dataset", required=True)
|
| 24 |
+
staging.add_argument("--task-id", required=True)
|
| 25 |
+
staging.add_argument("--output", required=True)
|
| 26 |
+
packing = commands.add_parser("pack-submission", help="Package model outputs as one submission ZIP")
|
| 27 |
+
packing.add_argument("--source", required=True, help="Output directory or ZIP with final.blend at its root")
|
| 28 |
+
packing.add_argument("--task-id", required=True)
|
| 29 |
+
packing.add_argument("--output", required=True, help="New submissions/bw_XXXX.zip")
|
| 30 |
+
harbor = commands.add_parser("export-harbor", help="Export self-contained Harbor tasks (Python 3.12+)")
|
| 31 |
+
harbor.add_argument("--dataset", required=True)
|
| 32 |
+
harbor.add_argument("--output", required=True)
|
| 33 |
+
harbor.add_argument("--namespace", default="Qwen")
|
| 34 |
+
harbor.add_argument("--task-id", action="append")
|
| 35 |
+
harbor.add_argument("--cpus", type=int, default=8)
|
| 36 |
+
harbor.add_argument("--memory-mb", type=int, default=16384)
|
| 37 |
+
harbor.add_argument("--gpus", type=int, default=0)
|
| 38 |
+
harbor.add_argument("--agent-timeout", type=int, default=14400)
|
| 39 |
+
harbor.add_argument("--verifier-timeout", type=int, default=28800)
|
| 40 |
+
scoring = commands.add_parser("evaluate", help="Render and judge per-task BlenderWorld submission ZIPs")
|
| 41 |
+
scoring.add_argument("--dataset", required=True)
|
| 42 |
+
scoring.add_argument("--submissions", "--submission", dest="submissions", required=True,
|
| 43 |
+
help="Directory of bw_XXXX.zip files, or a single task ZIP")
|
| 44 |
+
scoring.add_argument("--output", required=True)
|
| 45 |
+
scoring.add_argument("--task-id", action="append")
|
| 46 |
+
scoring.add_argument("--dry-run", action="store_true")
|
| 47 |
+
scoring.add_argument("--resume", action="store_true")
|
| 48 |
+
scoring.add_argument("--blender-bin", default=os.environ.get("BLENDER_BIN", "blender"))
|
| 49 |
+
scoring.add_argument("--render-agent-model", default=os.environ.get("RENDER_AGENT_MODEL", "gpt-5.6-terra"))
|
| 50 |
+
scoring.add_argument("--agent-judge-model", default=os.environ.get("AGENT_JUDGE_MODEL", "gpt-5.6-terra"))
|
| 51 |
+
scoring.add_argument("--judge-model", default=os.environ.get("JUDGE_MODEL", "gpt-5.6-terra"))
|
| 52 |
+
scoring.add_argument("--judge-api-endpoint", default=os.environ.get("JUDGE_API_ENDPOINT", "https://api.openai.com/v1/chat/completions"))
|
| 53 |
+
args = parser.parse_args()
|
| 54 |
+
try:
|
| 55 |
+
if args.command == "download":
|
| 56 |
+
from huggingface_hub import snapshot_download
|
| 57 |
+
snapshot_download(args.repo_id, repo_type="dataset", revision=args.revision, local_dir=args.output)
|
| 58 |
+
result = verify(args.output)
|
| 59 |
+
elif args.command == "verify":
|
| 60 |
+
result = verify(args.dataset)
|
| 61 |
+
elif args.command == "prepare":
|
| 62 |
+
result = prepare(args.dataset, args.task_id, args.output)
|
| 63 |
+
elif args.command == "pack-submission":
|
| 64 |
+
from .submissions import pack_submission
|
| 65 |
+
result = pack_submission(args.source, args.task_id, args.output)
|
| 66 |
+
elif args.command == "list":
|
| 67 |
+
result = [{"task_id": r["task_id"], "modality": r["modality"], "rubric_count": r["rubric_count"]}
|
| 68 |
+
for r in load_tasks(args.dataset) if not args.modality or r["modality"] == args.modality]
|
| 69 |
+
elif args.command == "export-harbor":
|
| 70 |
+
from .harbor_export import export_harbor
|
| 71 |
+
result = export_harbor(args.dataset, args.output, args.namespace, args.task_id,
|
| 72 |
+
args.cpus, args.memory_mb, args.gpus,
|
| 73 |
+
args.agent_timeout, args.verifier_timeout)
|
| 74 |
+
else:
|
| 75 |
+
from .evaluation import evaluate
|
| 76 |
+
result = evaluate(args)
|
| 77 |
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
| 78 |
+
if args.command == "evaluate" and not args.dry_run and result["overall"]["succeeded"] != result["overall"]["task_count"]:
|
| 79 |
+
return 2
|
| 80 |
+
return 0
|
| 81 |
+
except (OSError, ValueError, RuntimeError) as error:
|
| 82 |
+
parser.exit(2, f"bw: {error}\n")
|
bw_0221/tests/blenderworld/data.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Load and verify the portable dataset without a model service."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
from collections import Counter
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
RESOURCE_FIELDS = ("attachments", "supplemental_attachments", "reference_images",
|
| 12 |
+
"reference_videos", "rubric_reference_images")
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def sha256(path):
|
| 16 |
+
h = hashlib.sha256()
|
| 17 |
+
with Path(path).open("rb") as stream:
|
| 18 |
+
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
| 19 |
+
h.update(chunk)
|
| 20 |
+
return h.hexdigest()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def write_json(path, obj):
|
| 24 |
+
path = Path(path)
|
| 25 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 26 |
+
temporary = path.with_suffix(path.suffix + ".tmp")
|
| 27 |
+
temporary.write_text(json.dumps(obj, ensure_ascii=False, indent=2) + "\n")
|
| 28 |
+
temporary.replace(path)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def resolve(root, relative):
|
| 32 |
+
root = Path(root).resolve()
|
| 33 |
+
path = root / relative
|
| 34 |
+
if Path(relative).is_absolute() or not path.resolve().is_relative_to(root):
|
| 35 |
+
raise ValueError(f"Path escapes dataset: {relative}")
|
| 36 |
+
return path
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def load_tasks(root):
|
| 40 |
+
rows = [json.loads(s) for s in (Path(root) / "dataset.jsonl").read_text().splitlines() if s.strip()]
|
| 41 |
+
ids = [r["task_id"] for r in rows]
|
| 42 |
+
if len(set(ids)) != len(ids) or not all(re.fullmatch(r"bw_\d{4}", s) for s in ids):
|
| 43 |
+
raise ValueError("Task IDs must be unique neutral identifiers")
|
| 44 |
+
return rows
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def verify(root):
|
| 48 |
+
root = Path(root)
|
| 49 |
+
rows = load_tasks(root)
|
| 50 |
+
modalities = Counter(r["modality"] for r in rows)
|
| 51 |
+
if modalities != {"text": 78, "image": 130, "video": 15}:
|
| 52 |
+
raise ValueError(f"Unexpected benchmark task counts: {modalities}")
|
| 53 |
+
bundled = json.loads((root / "rubrics.json").read_text())["results"]
|
| 54 |
+
combined = {r["task_id"]: r for r in bundled}
|
| 55 |
+
if len(combined) != 223 or len(bundled) != 223:
|
| 56 |
+
raise ValueError("Combined rubric index must have 223 unique tasks")
|
| 57 |
+
criteria, resources = 0, 0
|
| 58 |
+
for row in rows:
|
| 59 |
+
task_root = root / "tasks" / row["task_id"]
|
| 60 |
+
if json.loads((task_root / "task.json").read_text()) != row:
|
| 61 |
+
raise ValueError(f"Task/index mismatch: {row['task_id']}")
|
| 62 |
+
if resolve(root, row["query_file"]).read_text() != row["query"]:
|
| 63 |
+
raise ValueError(f"Query mismatch: {row['task_id']}")
|
| 64 |
+
rubric = json.loads(resolve(root, row["rubric_file"]).read_text())
|
| 65 |
+
if rubric != combined[row["task_id"]] or rubric["prompt"] != row["query"]:
|
| 66 |
+
raise ValueError(f"Rubric/query/index mismatch: {row['task_id']}")
|
| 67 |
+
ids = [r["id"] for r in rubric["rubrics"]]
|
| 68 |
+
if len(set(ids)) != len(ids) or len(ids) != row["rubric_count"]:
|
| 69 |
+
raise ValueError(f"Invalid criterion IDs: {row['task_id']}")
|
| 70 |
+
for criterion in rubric["rubrics"]:
|
| 71 |
+
if criterion["score_values"] != [0, 1] or criterion["importance_weight"] not in (1, 2, 3):
|
| 72 |
+
raise ValueError("Invalid binary criterion/importance weight")
|
| 73 |
+
if criterion["evidence_type"] not in {"scene_summary", "render", "either"}:
|
| 74 |
+
raise ValueError("Unknown evidence route")
|
| 75 |
+
for attachment in rubric["attachments"]:
|
| 76 |
+
if not resolve(task_root, attachment["file"]).is_file():
|
| 77 |
+
raise ValueError(f"Missing rubric attachment: {attachment['file']}")
|
| 78 |
+
if rubric.get("image_file") and not resolve(task_root, rubric["image_file"]).is_file():
|
| 79 |
+
raise ValueError(f"Missing rubric image: {rubric['image_file']}")
|
| 80 |
+
for field in RESOURCE_FIELDS:
|
| 81 |
+
for entry in row[field]:
|
| 82 |
+
path = resolve(root, entry["path"])
|
| 83 |
+
if path != resolve(task_root, entry["task_relative_path"]):
|
| 84 |
+
raise ValueError("Resource path aliases disagree")
|
| 85 |
+
if path.stat().st_size != entry["bytes"] or sha256(path) != entry["sha256"]:
|
| 86 |
+
raise ValueError(f"Resource checksum mismatch: {entry['path']}")
|
| 87 |
+
resources += 1
|
| 88 |
+
criteria += len(ids)
|
| 89 |
+
if criteria != 2651:
|
| 90 |
+
raise ValueError(f"Expected 2651 criteria, got {criteria}")
|
| 91 |
+
checksums = root / "SHA256SUMS"
|
| 92 |
+
if not checksums.is_file():
|
| 93 |
+
raise ValueError("Missing release SHA256SUMS")
|
| 94 |
+
checksum_paths = set()
|
| 95 |
+
for line in checksums.read_text().splitlines():
|
| 96 |
+
checksum, relative = line.split(" ", 1)
|
| 97 |
+
if relative in checksum_paths or sha256(resolve(root, relative)) != checksum:
|
| 98 |
+
raise ValueError(f"Duplicate or incorrect checksum: {relative}")
|
| 99 |
+
checksum_paths.add(relative)
|
| 100 |
+
actual_paths = {p.relative_to(root).as_posix() for p in root.rglob("*") if p.is_file()
|
| 101 |
+
and not any(part in {".git", ".cache"} for part in p.relative_to(root).parts)}
|
| 102 |
+
if actual_paths != checksum_paths | {"SHA256SUMS"}:
|
| 103 |
+
raise ValueError("Release checksum inventory does not cover the complete file tree")
|
| 104 |
+
manifest = json.loads((root / "manifest.json").read_text())
|
| 105 |
+
if {r["path"] for r in manifest["files"]} != actual_paths - {"manifest.json", "SHA256SUMS"}:
|
| 106 |
+
raise ValueError("Manifest does not cover the complete release payload")
|
| 107 |
+
return {"tasks": len(rows), "modalities": dict(modalities), "criteria": criteria,
|
| 108 |
+
"resources": resources, "checksums_verified": checksums.exists()}
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def prepare(root, task_id, output):
|
| 112 |
+
"""Stage only generator-visible inputs; evaluation rubrics remain in the dataset."""
|
| 113 |
+
root, output = Path(root), Path(output)
|
| 114 |
+
row = next((r for r in load_tasks(root) if r["task_id"] == task_id), None)
|
| 115 |
+
if row is None:
|
| 116 |
+
raise ValueError(f"Unknown task: {task_id}")
|
| 117 |
+
output.mkdir(parents=True, exist_ok=False)
|
| 118 |
+
(output / "query.txt").write_text(row["query"])
|
| 119 |
+
inputs = []
|
| 120 |
+
for field in ("attachments", "reference_images", "reference_videos"):
|
| 121 |
+
for entry in row[field]:
|
| 122 |
+
target = resolve(output, entry["task_relative_path"])
|
| 123 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 124 |
+
shutil.copyfile(resolve(root, entry["path"]), target)
|
| 125 |
+
inputs.append(entry["task_relative_path"])
|
| 126 |
+
write_json(output / "input.json", {"task_id": task_id, "query_file": "query.txt", "files": inputs})
|
| 127 |
+
return {"task_id": task_id, "output": str(output), "input_files": len(inputs)}
|
bw_0221/tests/blenderworld/evaluation.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Local evidence preparation, rendering, judging, and benchmark aggregation."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import csv
|
| 5 |
+
import fcntl
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
import shutil
|
| 9 |
+
import subprocess
|
| 10 |
+
import sys
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
from . import render_agent
|
| 14 |
+
from .data import RESOURCE_FIELDS, load_tasks, resolve, sha256, write_json
|
| 15 |
+
from .evaluators import judge_blender_binary_rubrics as vision
|
| 16 |
+
from .evaluators.evidence_checks import cli_log_status
|
| 17 |
+
from .runtime import RuntimeValidationError, inspect_runtime, record_runtime, requirements
|
| 18 |
+
from .submissions import FORMAT, inspect_submission, unpack_submission
|
| 19 |
+
|
| 20 |
+
PROTOCOL = {"version": 1, "views": 8, "resolution": 1024, "samples": 64,
|
| 21 |
+
"engine": "CYCLES", "max_corrective_rerenders": 2,
|
| 22 |
+
"dimension_weight": 0.5, "score_cap": None,
|
| 23 |
+
"structural_evidence": ["scene_summary"], "visual_evidence": ["render", "either"]}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def tree_hashes(root):
|
| 27 |
+
root = Path(root)
|
| 28 |
+
return {p.relative_to(root).as_posix(): sha256(p) for p in sorted(root.rglob("*")) if p.is_file()}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def sample_video(source, destination, count):
|
| 32 |
+
destination.mkdir(parents=True, exist_ok=True)
|
| 33 |
+
probe = subprocess.run(["ffprobe", "-v", "error", "-show_entries", "format=duration",
|
| 34 |
+
"-of", "json", str(source)], check=True, capture_output=True, text=True, timeout=60)
|
| 35 |
+
duration = float(json.loads(probe.stdout)["format"]["duration"])
|
| 36 |
+
if duration <= 0:
|
| 37 |
+
raise ValueError(f"Video has no positive duration: {source.name}")
|
| 38 |
+
# Sample across the whole clip, including both ends without seeking past its last frame.
|
| 39 |
+
for i in range(count):
|
| 40 |
+
timestamp = max(0, duration - min(0.1, duration / count)) * i / max(1, count - 1)
|
| 41 |
+
subprocess.run(["ffmpeg", "-v", "error", "-y", "-ss", str(timestamp), "-i", str(source),
|
| 42 |
+
"-frames:v", "1", str(destination / f"frame_{i:03d}.png")],
|
| 43 |
+
check=True, capture_output=True, timeout=120)
|
| 44 |
+
if len(list(destination.glob("*.png"))) != count:
|
| 45 |
+
raise ValueError(f"Incomplete video sampling: {source.name}")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def prepare_evaluation(dataset, row, submission, task_dir):
|
| 49 |
+
task_dir.mkdir(parents=True, exist_ok=False)
|
| 50 |
+
snapshot = task_dir / ".eval_workspace"
|
| 51 |
+
# The public ZIP contract is independent of the model's generation harness.
|
| 52 |
+
manifest = unpack_submission(submission, row["task_id"], snapshot)
|
| 53 |
+
write_json(task_dir / "submission_archive.json", manifest)
|
| 54 |
+
(task_dir / "query.txt").write_text(row["query"])
|
| 55 |
+
rubric = json.loads(resolve(dataset, row["rubric_file"]).read_text())
|
| 56 |
+
write_json(task_dir / "rubric.json", rubric)
|
| 57 |
+
input_hashes = {entry["sha256"] for field in RESOURCE_FIELDS for entry in row[field]}
|
| 58 |
+
write_json(task_dir / "input_media_sha256.json", sorted(input_hashes))
|
| 59 |
+
for field in RESOURCE_FIELDS:
|
| 60 |
+
for entry in row[field]:
|
| 61 |
+
path = resolve(task_dir, entry["task_relative_path"])
|
| 62 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 63 |
+
shutil.copyfile(resolve(dataset, entry["path"]), path)
|
| 64 |
+
judge_refs = task_dir / "image_assets"
|
| 65 |
+
judge_refs.mkdir()
|
| 66 |
+
image_entries = row["rubric_reference_images"] or row["reference_images"]
|
| 67 |
+
for entry in image_entries:
|
| 68 |
+
shutil.copyfile(resolve(dataset, entry["path"]), judge_refs / Path(entry["path"]).name)
|
| 69 |
+
for i, entry in enumerate(row["reference_videos"]):
|
| 70 |
+
sample_video(resolve(dataset, entry["path"]), judge_refs / f"video_{i:02d}", 4)
|
| 71 |
+
for i, video in enumerate(sorted(snapshot.rglob("*"))):
|
| 72 |
+
if (video.is_file() and video.suffix.lower() in {".mp4", ".mov", ".mkv", ".webm"}
|
| 73 |
+
and sha256(video) not in input_hashes):
|
| 74 |
+
sample_video(video, task_dir / "animation_frames" / f"clip_{i:03d}", 16)
|
| 75 |
+
write_json(task_dir / "submission_sha256.json", tree_hashes(snapshot))
|
| 76 |
+
write_json(task_dir / "rubrics_batch.json", {"results": [{**rubric, "task_dir": str(task_dir.resolve())}]})
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def run_module(module, args, log):
|
| 80 |
+
with log.open("w") as stream:
|
| 81 |
+
completed = subprocess.run([sys.executable, "-m", "blenderworld.evaluators." + module, *args],
|
| 82 |
+
env={**os.environ, "DISABLE_AUTOUPDATER": "1"},
|
| 83 |
+
stdout=stream, stderr=subprocess.STDOUT, check=False)
|
| 84 |
+
if completed.returncode:
|
| 85 |
+
raise RuntimeError(f"{module} failed ({completed.returncode}); see {log.name}")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def validate_score(row, rubric, result):
|
| 89 |
+
if result.get("ok") is not True or result.get("dry_run"):
|
| 90 |
+
raise ValueError("Judge did not produce a successful scored result")
|
| 91 |
+
if result.get("cap_applied") or not result.get("rendered_image_files"):
|
| 92 |
+
raise ValueError("Result does not follow the public scoring protocol")
|
| 93 |
+
scores = result.get("rubric_scores", [])
|
| 94 |
+
expected = {r["id"] for r in rubric["rubrics"]}
|
| 95 |
+
if {r["id"] for r in scores} != expected or len(scores) != len(expected):
|
| 96 |
+
raise ValueError("Incomplete or duplicate rubric scores")
|
| 97 |
+
if any(type(r.get("score")) is not int or r["score"] not in (0, 1) for r in scores):
|
| 98 |
+
raise ValueError("Rubric scores must be binary integers")
|
| 99 |
+
dimensions = result.get("dimension_scores", [])
|
| 100 |
+
expected_dims = {r["id"] for r in vision.DIMENSIONS}
|
| 101 |
+
if {r["id"] for r in dimensions} != expected_dims or len(dimensions) != len(expected_dims):
|
| 102 |
+
raise ValueError("Incomplete or duplicate dimension scores")
|
| 103 |
+
if any(type(r.get("score")) is not int or not 1 <= r["score"] <= 10 for r in dimensions):
|
| 104 |
+
raise ValueError("Dimension scores must be integers from 1 to 10")
|
| 105 |
+
rubric_score = vision.build_score_summary(rubric["rubrics"], scores)["weighted_score_0_100"]
|
| 106 |
+
dimension_score = 10 * sum(d["score"] for d in dimensions) / len(dimensions)
|
| 107 |
+
fused = 0.5 * (rubric_score + dimension_score)
|
| 108 |
+
if abs(fused - result["fused_score_0_100"]) > 1e-6:
|
| 109 |
+
raise ValueError("Fused score differs from the paper's uncapped 1:1 formula")
|
| 110 |
+
return {"task_id": row["task_id"], "modality": row["modality"], "ok": True,
|
| 111 |
+
"score": fused, "rubric_score": rubric_score, "dimension_score": dimension_score,
|
| 112 |
+
"error": ""}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def score_task(row, task_dir, options):
|
| 116 |
+
common = ["--rubrics-batch", str(task_dir / "rubrics_batch.json"),
|
| 117 |
+
"--image-glob", "evaluation/multiview/*.png", "--max-images", "8",
|
| 118 |
+
"--reference-image-glob", "image_assets/**/*", "--max-reference-images", "4",
|
| 119 |
+
"--extra-image-glob", ".eval_workspace/**/*.png,.eval_workspace/**/*.jpg,.eval_workspace/**/*.jpeg,.eval_workspace/**/*.webp"]
|
| 120 |
+
rubric = json.loads((task_dir / "rubric.json").read_text())
|
| 121 |
+
if any(r["evidence_type"] == "scene_summary" for r in rubric["rubrics"]):
|
| 122 |
+
run_module("judge_blender_agent", common + ["--agent-evidence-types", "scene_summary",
|
| 123 |
+
"--no-dimension-pass", "--blender-bin", options.blender_bin,
|
| 124 |
+
"--model", options.agent_judge_model, "--task-concurrency", "1",
|
| 125 |
+
"--batch-output", str(task_dir / "agent_batch.json")], task_dir / "agent_judge.log")
|
| 126 |
+
folder = task_dir / "evaluation/agent_judge_multiview_eval"
|
| 127 |
+
agent_result = json.loads((folder / "judgement.json").read_text())
|
| 128 |
+
if agent_result.get("agent_returncode") != 0:
|
| 129 |
+
raise ValueError("Structural judge did not exit successfully")
|
| 130 |
+
expected_logs = [folder / "agent_judge_stdout.jsonl"] + [
|
| 131 |
+
folder / f"agent_judge_stdout.attempt{i}.jsonl"
|
| 132 |
+
for i in range(2, agent_result.get("agent_attempts", 1) + 1)]
|
| 133 |
+
if any(not p.is_file() for p in expected_logs):
|
| 134 |
+
raise ValueError("Structural judge attempt logs are incomplete")
|
| 135 |
+
for log in folder.glob("agent_judge_stdout*.jsonl"):
|
| 136 |
+
terminal, refused = cli_log_status(log)
|
| 137 |
+
if refused:
|
| 138 |
+
raise ValueError("Structural judge encountered an upstream content refusal")
|
| 139 |
+
terminal, refused = cli_log_status(resolve(task_dir, agent_result["agent_stdout_path"]))
|
| 140 |
+
if not terminal or terminal.get("is_error"):
|
| 141 |
+
raise ValueError("Structural judge did not terminate successfully")
|
| 142 |
+
for key in ("agent_raw_path", "bpy_dump_path"):
|
| 143 |
+
if not json.loads(resolve(task_dir, agent_result[key]).read_text()):
|
| 144 |
+
raise ValueError("Structural judge has no inspectable raw evidence")
|
| 145 |
+
run_module("judge_blender_binary_rubrics", common + ["--evidence-routing",
|
| 146 |
+
"--model", options.judge_model, "--api-endpoint", options.judge_api_endpoint,
|
| 147 |
+
"--anim-frame-glob", "animation_frames/**/*.png", "--max-anim-frames", "16",
|
| 148 |
+
"--task-concurrency", "1", "--batch-output", str(task_dir / "vision_batch.json")],
|
| 149 |
+
task_dir / "vision_judge.log")
|
| 150 |
+
result = json.loads((task_dir / "evaluation/judge_vlm/judgement.json").read_text())
|
| 151 |
+
if tree_hashes(task_dir / ".eval_workspace") != json.loads((task_dir / "submission_sha256.json").read_text()):
|
| 152 |
+
raise ValueError("Evaluator modified the submitted workspace")
|
| 153 |
+
return validate_score(row, rubric, result)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def summarize(rows, records):
|
| 157 |
+
def aggregate(selected):
|
| 158 |
+
count = len(selected)
|
| 159 |
+
known = [records[r["task_id"]] for r in selected if r["task_id"] in records]
|
| 160 |
+
return {"task_count": count, "completed": len(known), "succeeded": sum(r["ok"] for r in known),
|
| 161 |
+
"mean_score": sum(r["score"] for r in known) / count if count else None}
|
| 162 |
+
return {"complete": len(records) == len(rows), "overall": aggregate(rows),
|
| 163 |
+
"text": aggregate([r for r in rows if r["modality"] == "text"]),
|
| 164 |
+
"multimodal": aggregate([r for r in rows if r["modality"] != "text"]),
|
| 165 |
+
"results": [records[r["task_id"]] for r in rows if r["task_id"] in records]}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def evaluate(options):
|
| 169 |
+
dataset, submissions, output = map(lambda p: Path(p).resolve(), (options.dataset, options.submissions, options.output))
|
| 170 |
+
options.blender_bin = render_agent.normalize_blender_path(getattr(options, "blender_bin", "blender"))
|
| 171 |
+
rows = load_tasks(dataset)
|
| 172 |
+
single_zip = submissions.suffix.lower() == ".zip" and not submissions.is_dir()
|
| 173 |
+
if single_zip and not options.task_id:
|
| 174 |
+
options.task_id = [submissions.stem]
|
| 175 |
+
if options.task_id:
|
| 176 |
+
requested = set(options.task_id)
|
| 177 |
+
rows = [r for r in rows if r["task_id"] in requested]
|
| 178 |
+
if {r["task_id"] for r in rows} != requested:
|
| 179 |
+
raise ValueError("Unknown task ID in selection")
|
| 180 |
+
if single_zip and len(rows) != 1:
|
| 181 |
+
raise ValueError("A single submission ZIP must select exactly one task")
|
| 182 |
+
if output == submissions or (submissions.is_dir() and output.is_relative_to(submissions)):
|
| 183 |
+
raise ValueError("Evaluation output must be outside the submissions directory")
|
| 184 |
+
archives = {r["task_id"]: submissions if single_zip else submissions / (r["task_id"] + ".zip") for r in rows}
|
| 185 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 186 |
+
# A run has one owner. A live owner must never be mistaken for a stopped run.
|
| 187 |
+
with (output / ".run.lock").open("a") as lock:
|
| 188 |
+
try:
|
| 189 |
+
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
| 190 |
+
except BlockingIOError as error:
|
| 191 |
+
raise RuntimeError("This run is already active") from error
|
| 192 |
+
plan = {"dataset_sha256": sha256(dataset / "dataset.jsonl"),
|
| 193 |
+
"rubrics_sha256": sha256(dataset / "rubrics.json"),
|
| 194 |
+
"code_sha256": {str(p.relative_to(Path(__file__).parent)): sha256(p)
|
| 195 |
+
for p in sorted(Path(__file__).parent.rglob("*.py"))},
|
| 196 |
+
"task_ids": [r["task_id"] for r in rows], "protocol": PROTOCOL,
|
| 197 |
+
"models": {"render": options.render_agent_model, "agent": options.agent_judge_model,
|
| 198 |
+
"vision": options.judge_model}, "submissions": str(submissions),
|
| 199 |
+
"endpoints": {"vision": getattr(options, "judge_api_endpoint", ""),
|
| 200 |
+
"agent": os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com")},
|
| 201 |
+
"blender_bin": getattr(options, "blender_bin", "blender"),
|
| 202 |
+
"submission_format": FORMAT, "runtime_requirements": requirements(),
|
| 203 |
+
"submission_hashes": {tid: sha256(path) if path.is_file() and not path.is_symlink() else None
|
| 204 |
+
for tid, path in archives.items()}}
|
| 205 |
+
plan_file = output / "plan.json"
|
| 206 |
+
if plan_file.exists():
|
| 207 |
+
if not options.resume:
|
| 208 |
+
raise ValueError("Run exists; use --resume or choose a new output directory")
|
| 209 |
+
if json.loads(plan_file.read_text()) != plan:
|
| 210 |
+
raise ValueError("Inputs, models, code, or protocol changed; start a new run")
|
| 211 |
+
else:
|
| 212 |
+
write_json(plan_file, plan)
|
| 213 |
+
if options.dry_run:
|
| 214 |
+
inventory, errors = {}, {}
|
| 215 |
+
for task_id, path in archives.items():
|
| 216 |
+
try:
|
| 217 |
+
inventory[task_id] = inspect_submission(path, task_id)
|
| 218 |
+
except (OSError, ValueError) as error:
|
| 219 |
+
errors[task_id] = str(error)
|
| 220 |
+
return {"dry_run": True, "tasks": len(rows), "plan": str(plan_file),
|
| 221 |
+
"missing_submissions": [tid for tid, path in archives.items() if not path.is_file()],
|
| 222 |
+
"submission_inventory": inventory, "submission_errors": errors}
|
| 223 |
+
runtime_checked = False
|
| 224 |
+
records = {}
|
| 225 |
+
for row in rows:
|
| 226 |
+
task_id = row["task_id"]
|
| 227 |
+
task_dir = output / "tasks" / task_id
|
| 228 |
+
outcome = task_dir / "result.json"
|
| 229 |
+
if outcome.exists():
|
| 230 |
+
records[task_id] = json.loads(outcome.read_text())
|
| 231 |
+
continue
|
| 232 |
+
if task_dir.exists():
|
| 233 |
+
# Preserve incomplete evidence; resume in a new attempt directory.
|
| 234 |
+
n = 1
|
| 235 |
+
while (output / "incomplete" / f"{task_id}.{n}").exists():
|
| 236 |
+
n += 1
|
| 237 |
+
saved = output / "incomplete" / f"{task_id}.{n}"
|
| 238 |
+
saved.parent.mkdir(parents=True, exist_ok=True)
|
| 239 |
+
task_dir.rename(saved)
|
| 240 |
+
print(f"Evaluating {task_id}", flush=True)
|
| 241 |
+
try:
|
| 242 |
+
submission = archives[task_id]
|
| 243 |
+
if not submission.is_file():
|
| 244 |
+
raise ValueError("Missing submission ZIP: " + task_id + ".zip")
|
| 245 |
+
if sha256(submission) != plan["submission_hashes"][task_id]:
|
| 246 |
+
raise ValueError("Submission ZIP changed after planning")
|
| 247 |
+
prepare_evaluation(dataset, row, submission, task_dir)
|
| 248 |
+
if not runtime_checked:
|
| 249 |
+
record_runtime(output, inspect_runtime(options.blender_bin))
|
| 250 |
+
runtime_checked = True
|
| 251 |
+
render_agent.run(row, task_dir, options.blender_bin, options.render_agent_model)
|
| 252 |
+
result = score_task(row, task_dir, options)
|
| 253 |
+
if sha256(submission) != plan["submission_hashes"][task_id]:
|
| 254 |
+
raise ValueError("Original submission ZIP changed during evaluation")
|
| 255 |
+
except RuntimeValidationError:
|
| 256 |
+
# A wrong evaluator runtime must not become 223 failed agent scores.
|
| 257 |
+
raise
|
| 258 |
+
except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
|
| 259 |
+
result = {"task_id": task_id, "modality": row["modality"], "ok": False,
|
| 260 |
+
"score": 0.0, "rubric_score": None, "dimension_score": None, "error": str(error)}
|
| 261 |
+
write_json(outcome, result)
|
| 262 |
+
records[task_id] = result
|
| 263 |
+
write_json(output / "summary.json", summarize(rows, records))
|
| 264 |
+
summary = summarize(rows, records)
|
| 265 |
+
write_json(output / "summary.json", summary)
|
| 266 |
+
with (output / "results.csv").open("w", newline="") as stream:
|
| 267 |
+
writer = csv.DictWriter(stream, fieldnames=["task_id", "modality", "ok", "score", "rubric_score", "dimension_score", "error"])
|
| 268 |
+
writer.writeheader()
|
| 269 |
+
writer.writerows(summary["results"])
|
| 270 |
+
return {k: v for k, v in summary.items() if k != "results"}
|
bw_0221/tests/blenderworld/evaluators/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Evidence-routed BlenderWorld judges."""
|
bw_0221/tests/blenderworld/evaluators/asset_paths.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Restore bundled image paths in memory when Blender opens an archived project.
|
| 2 |
+
|
| 3 |
+
The saved project is never rewritten. Ambiguous filenames remain unresolved;
|
| 4 |
+
an evaluator must not silently substitute another task's texture.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path, PurePosixPath
|
| 12 |
+
|
| 13 |
+
_handler = None
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def workspace_for(blend_path, root):
|
| 17 |
+
root = Path(root).resolve()
|
| 18 |
+
blend = Path(blend_path).resolve()
|
| 19 |
+
if not blend.is_relative_to(root):
|
| 20 |
+
return None
|
| 21 |
+
for parent in blend.parents:
|
| 22 |
+
if not parent.is_relative_to(root):
|
| 23 |
+
break
|
| 24 |
+
if parent.name == ".eval_workspace":
|
| 25 |
+
return parent
|
| 26 |
+
candidate = parent / ".eval_workspace"
|
| 27 |
+
if candidate.is_dir():
|
| 28 |
+
return candidate
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def find_asset(saved_path, workspace):
|
| 33 |
+
"""Prefer the longest matching archived suffix; never pick an ambiguous name."""
|
| 34 |
+
workspace = Path(workspace).resolve()
|
| 35 |
+
parts = PurePosixPath(str(saved_path).replace("\\", "/")).parts
|
| 36 |
+
if not parts or ".." in parts:
|
| 37 |
+
return None
|
| 38 |
+
files = [
|
| 39 |
+
p
|
| 40 |
+
for p in workspace.rglob(parts[-1])
|
| 41 |
+
if p.is_file() and p.resolve().is_relative_to(workspace)
|
| 42 |
+
]
|
| 43 |
+
# Glob metacharacters in a legitimate filename must not select another file.
|
| 44 |
+
files = [p for p in files if p.name == parts[-1]]
|
| 45 |
+
for count in range(len(parts), 0, -1):
|
| 46 |
+
suffix = parts[-count:]
|
| 47 |
+
matches = [p for p in files if p.relative_to(workspace).parts[-count:] == suffix]
|
| 48 |
+
if len(matches) == 1:
|
| 49 |
+
return matches[0]
|
| 50 |
+
if matches:
|
| 51 |
+
return None
|
| 52 |
+
return None
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def restore_images(bpy, root):
|
| 56 |
+
if not bpy.data.filepath:
|
| 57 |
+
return []
|
| 58 |
+
workspace = workspace_for(bpy.data.filepath, root)
|
| 59 |
+
if workspace is None:
|
| 60 |
+
return []
|
| 61 |
+
changes = []
|
| 62 |
+
for image in bpy.data.images:
|
| 63 |
+
if image.source != "FILE" or image.packed_file or not image.filepath:
|
| 64 |
+
continue
|
| 65 |
+
old = image.filepath
|
| 66 |
+
if Path(bpy.path.abspath(old, library=image.library)).is_file():
|
| 67 |
+
continue
|
| 68 |
+
replacement = find_asset(old, workspace)
|
| 69 |
+
if replacement is None:
|
| 70 |
+
changes.append({"action": "unresolved_image", "image": image.name, "path": old})
|
| 71 |
+
continue
|
| 72 |
+
image.filepath = str(replacement)
|
| 73 |
+
try:
|
| 74 |
+
image.reload()
|
| 75 |
+
if not all(image.size):
|
| 76 |
+
raise RuntimeError("image has no readable pixels")
|
| 77 |
+
except (RuntimeError, OSError, ValueError) as exc:
|
| 78 |
+
image.filepath = old
|
| 79 |
+
changes.append(
|
| 80 |
+
{
|
| 81 |
+
"action": "image_reload_failed",
|
| 82 |
+
"image": image.name,
|
| 83 |
+
"path": old,
|
| 84 |
+
"error": str(exc),
|
| 85 |
+
}
|
| 86 |
+
)
|
| 87 |
+
else:
|
| 88 |
+
changes.append(
|
| 89 |
+
{
|
| 90 |
+
"action": "restored_image",
|
| 91 |
+
"image": image.name,
|
| 92 |
+
"from": old,
|
| 93 |
+
"to": str(replacement),
|
| 94 |
+
}
|
| 95 |
+
)
|
| 96 |
+
return changes
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def compatible_denoising(scenes):
|
| 100 |
+
changes = []
|
| 101 |
+
for scene in scenes:
|
| 102 |
+
cycles = scene.cycles
|
| 103 |
+
if cycles.use_denoising and cycles.denoiser == "OPTIX":
|
| 104 |
+
# OptiX rendering can work even when its denoiser cannot initialize.
|
| 105 |
+
# OIDN on CPU preserves denoising without changing render samples.
|
| 106 |
+
cycles.denoiser = "OPENIMAGEDENOISE"
|
| 107 |
+
if hasattr(cycles, "denoising_use_gpu"):
|
| 108 |
+
cycles.denoising_use_gpu = False
|
| 109 |
+
changes.append(
|
| 110 |
+
{
|
| 111 |
+
"action": "denoiser_compatibility",
|
| 112 |
+
"scene": scene.name,
|
| 113 |
+
"from": "OPTIX",
|
| 114 |
+
"to": "OPENIMAGEDENOISE",
|
| 115 |
+
}
|
| 116 |
+
)
|
| 117 |
+
return changes
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def apply_runtime(bpy):
|
| 121 |
+
root = os.environ.get("BLENDER_EVAL_ASSET_ROOT")
|
| 122 |
+
if not root or not getattr(bpy.data, "filepath", ""):
|
| 123 |
+
return
|
| 124 |
+
if workspace_for(bpy.data.filepath, root) is None:
|
| 125 |
+
return
|
| 126 |
+
changes = restore_images(bpy, root) + compatible_denoising(bpy.data.scenes)
|
| 127 |
+
if not changes:
|
| 128 |
+
return
|
| 129 |
+
event = {"blend": bpy.data.filepath, "changes": changes}
|
| 130 |
+
line = json.dumps(event, ensure_ascii=False)
|
| 131 |
+
print("BLENDER_EVAL_RUNTIME " + line, flush=True)
|
| 132 |
+
audit = os.environ.get("BLENDER_EVAL_RUNTIME_AUDIT")
|
| 133 |
+
if audit:
|
| 134 |
+
with Path(audit).open("a", encoding="utf-8") as stream:
|
| 135 |
+
stream.write(line + "\n")
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def register():
|
| 139 |
+
import bpy
|
| 140 |
+
from bpy.app.handlers import persistent
|
| 141 |
+
|
| 142 |
+
global _handler
|
| 143 |
+
if _handler is not None:
|
| 144 |
+
return
|
| 145 |
+
|
| 146 |
+
@persistent
|
| 147 |
+
def on_load_or_render(*_args):
|
| 148 |
+
apply_runtime(bpy)
|
| 149 |
+
|
| 150 |
+
# Both hooks are needed: scripts may select another image or scene after load.
|
| 151 |
+
bpy.app.handlers.load_post.append(on_load_or_render)
|
| 152 |
+
bpy.app.handlers.render_pre.append(on_load_or_render)
|
| 153 |
+
_handler = on_load_or_render
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def unregister():
|
| 157 |
+
import bpy
|
| 158 |
+
|
| 159 |
+
global _handler
|
| 160 |
+
for handlers in (bpy.app.handlers.load_post, bpy.app.handlers.render_pre):
|
| 161 |
+
if _handler in handlers:
|
| 162 |
+
handlers.remove(_handler)
|
| 163 |
+
_handler = None
|
bw_0221/tests/blenderworld/evaluators/evidence_checks.py
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Read-only evidence helpers; no task IDs or verdict overrides.
|
| 3 |
+
|
| 4 |
+
Normal Python: --inventory-root <materialized submission> --output <json>
|
| 5 |
+
Blender: open the original with --disable-autoexec, then --python this_file --
|
| 6 |
+
--output <json> [--uv-layer <name>]. No scene is saved or rendered.
|
| 7 |
+
"""
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
import argparse
|
| 10 |
+
import hashlib
|
| 11 |
+
import json
|
| 12 |
+
import math
|
| 13 |
+
import re
|
| 14 |
+
import struct
|
| 15 |
+
import sys
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def cli_event_content_refusal(event):
|
| 20 |
+
"""Recognize provider errors, never a prompt merely mentioning filtering."""
|
| 21 |
+
if not isinstance(event, dict):
|
| 22 |
+
return False
|
| 23 |
+
kind = event.get('type')
|
| 24 |
+
status = event.get('api_error_status')
|
| 25 |
+
if kind == 'result' and event.get('is_error') is True:
|
| 26 |
+
text = str(event.get('result', ''))
|
| 27 |
+
elif kind == 'assistant' and event.get('error'):
|
| 28 |
+
message = event.get('message', {})
|
| 29 |
+
content = message.get('content', []) if isinstance(message, dict) else []
|
| 30 |
+
text = '\n'.join(str(block.get('text', '')) for block in content
|
| 31 |
+
if isinstance(block, dict) and block.get('type') == 'text')
|
| 32 |
+
elif kind == 'system' and event.get('subtype') == 'api_error':
|
| 33 |
+
error = event.get('error', {})
|
| 34 |
+
if not isinstance(error, dict):
|
| 35 |
+
return False
|
| 36 |
+
status = error.get('status', error.get('status_code', status))
|
| 37 |
+
text = str(error.get('message', ''))
|
| 38 |
+
elif kind == 'system' and event.get('subtype') in {'task_updated', 'task_notification'}:
|
| 39 |
+
details = event.get('patch', {}) if event['subtype'] == 'task_updated' else event
|
| 40 |
+
if not isinstance(details, dict) or details.get('status') != 'failed':
|
| 41 |
+
return False
|
| 42 |
+
text = str(details.get('error', details.get('summary', '')))
|
| 43 |
+
prefix = 'Agent terminated early due to an API error: '
|
| 44 |
+
if not text.startswith(prefix):
|
| 45 |
+
return False
|
| 46 |
+
text = text[len(prefix):]
|
| 47 |
+
elif kind == 'user' and isinstance(event.get('tool_use_result'), str):
|
| 48 |
+
# Claude Code emits this metadata for failed child tasks, alongside
|
| 49 |
+
# system task notifications. Ordinary user messages have no such field.
|
| 50 |
+
prefix = 'Error: Agent terminated early due to an API error: '
|
| 51 |
+
if not event['tool_use_result'].startswith(prefix):
|
| 52 |
+
return False
|
| 53 |
+
content = event.get('message', {}).get('content', [])
|
| 54 |
+
if not isinstance(content, list) or not any(
|
| 55 |
+
isinstance(block, dict) and block.get('type') == 'tool_result'
|
| 56 |
+
and block.get('is_error') is True for block in content
|
| 57 |
+
):
|
| 58 |
+
return False
|
| 59 |
+
text = event['tool_use_result'][len(prefix):]
|
| 60 |
+
else:
|
| 61 |
+
return False
|
| 62 |
+
return bool(
|
| 63 |
+
(status == 400 or re.match(r'\s*API Error:\s*400\b', text))
|
| 64 |
+
and re.search(r'\b(?:content_policy_violation|content_filter)\b', text)
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def cli_log_status(path):
|
| 69 |
+
"""Inspect every CLI event, including child errors before parent success."""
|
| 70 |
+
terminal, refused = None, False
|
| 71 |
+
for line in Path(path).read_text(encoding='utf-8', errors='replace').splitlines():
|
| 72 |
+
try:
|
| 73 |
+
event = json.loads(line)
|
| 74 |
+
except ValueError:
|
| 75 |
+
continue
|
| 76 |
+
refused = refused or cli_event_content_refusal(event)
|
| 77 |
+
if isinstance(event, dict) and event.get('type') == 'result':
|
| 78 |
+
terminal = event
|
| 79 |
+
return terminal, refused
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def png_metadata(path):
|
| 83 |
+
with Path(path).open('rb') as f:
|
| 84 |
+
header = f.read(33)
|
| 85 |
+
if len(header) != 33 or header[:8] != b'\x89PNG\r\n\x1a\n' or header[12:16] != b'IHDR':
|
| 86 |
+
raise ValueError('Invalid PNG IHDR')
|
| 87 |
+
width, height, bits, color = struct.unpack('>IIBB', header[16:26])
|
| 88 |
+
result = {'format': 'PNG', 'width': width, 'height': height,
|
| 89 |
+
'bits_per_channel': bits, 'png_color_type': color,
|
| 90 |
+
'has_alpha_channel': color in (4, 6)}
|
| 91 |
+
if color in (4, 6):
|
| 92 |
+
try:
|
| 93 |
+
from PIL import Image
|
| 94 |
+
with Image.open(path) as image:
|
| 95 |
+
# Pillow downconverts RGB(A)16 for display; alpha extrema here are
|
| 96 |
+
# display-scale values, NOT a claim about native file bit depth.
|
| 97 |
+
alpha = image.convert('RGBA').getchannel('A')
|
| 98 |
+
lo, hi = alpha.getextrema()
|
| 99 |
+
result['alpha_display_range_0_255'] = [lo, hi]
|
| 100 |
+
result['has_visible_transparency'] = lo < 255
|
| 101 |
+
except (ImportError, OSError, ValueError) as exc:
|
| 102 |
+
result['alpha_probe_error'] = type(exc).__name__
|
| 103 |
+
return result
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def file_inventory(root):
|
| 107 |
+
root = Path(root).resolve()
|
| 108 |
+
rows = []
|
| 109 |
+
for folder in ('exports', 'output'):
|
| 110 |
+
base = root / folder
|
| 111 |
+
if not base.is_dir():
|
| 112 |
+
continue
|
| 113 |
+
for path in sorted(base.rglob('*')):
|
| 114 |
+
if not path.is_file() or not path.resolve().is_relative_to(root):
|
| 115 |
+
continue
|
| 116 |
+
row = {'path': str(path.relative_to(root)), 'bytes': path.stat().st_size,
|
| 117 |
+
'provenance': 'author_submission', 'suffix': path.suffix.lower()}
|
| 118 |
+
try:
|
| 119 |
+
if path.suffix.lower() == '.png':
|
| 120 |
+
row.update(png_metadata(path))
|
| 121 |
+
elif path.suffix.lower() in ('.jpg', '.jpeg', '.webp'):
|
| 122 |
+
from PIL import Image
|
| 123 |
+
with Image.open(path) as im:
|
| 124 |
+
row.update(format=im.format, width=im.width, height=im.height)
|
| 125 |
+
except (ImportError, OSError, ValueError) as exc:
|
| 126 |
+
row['metadata_error'] = type(exc).__name__
|
| 127 |
+
rows.append(row)
|
| 128 |
+
return {'root': str(root), 'provenance': 'original files materialized from workspace_snapshot',
|
| 129 |
+
'file_count': len(rows), 'files': rows,
|
| 130 |
+
'note': 'Includes auxiliary textures and previews. Presence alone does not identify the final deliverable.'}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def polygon_area(points):
|
| 134 |
+
if len(points) < 3:
|
| 135 |
+
return 0.0
|
| 136 |
+
return abs(sum(a[0]*b[1]-b[0]*a[1] for a,b in zip(points, points[1:]+points[:1]))) * .5
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def triangle_intersection_area(subject, triangle):
|
| 140 |
+
def cross(a,b,c):
|
| 141 |
+
return (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])
|
| 142 |
+
if cross(*triangle) < 0:
|
| 143 |
+
triangle = triangle[::-1]
|
| 144 |
+
output = list(subject)
|
| 145 |
+
for a,b in zip(triangle, triangle[1:]+triangle[:1]):
|
| 146 |
+
source, output = output, []
|
| 147 |
+
if not source:
|
| 148 |
+
break
|
| 149 |
+
prev = source[-1]; dp = cross(a,b,prev)
|
| 150 |
+
for cur in source:
|
| 151 |
+
dc = cross(a,b,cur)
|
| 152 |
+
if (dp >= 0) != (dc >= 0):
|
| 153 |
+
t = dp/(dp-dc)
|
| 154 |
+
output.append((prev[0]+t*(cur[0]-prev[0]), prev[1]+t*(cur[1]-prev[1])))
|
| 155 |
+
if dc >= 0:
|
| 156 |
+
output.append(cur)
|
| 157 |
+
prev, dp = cur, dc
|
| 158 |
+
return polygon_area(output)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def find_uv_overlap(triangles, max_pairs=2_000_000):
|
| 162 |
+
"""Positive-area overlap within one mesh; shared edges do not count.
|
| 163 |
+
|
| 164 |
+
A bounded sweep returns incomplete/unknown when its budget is exhausted;
|
| 165 |
+
an incomplete scan must never be used to assert no overlap.
|
| 166 |
+
"""
|
| 167 |
+
boxes = []
|
| 168 |
+
degenerate = 0
|
| 169 |
+
for i,t in enumerate(triangles):
|
| 170 |
+
if polygon_area(t) <= 1e-12:
|
| 171 |
+
degenerate += 1
|
| 172 |
+
continue
|
| 173 |
+
boxes.append((min(p[0] for p in t), max(p[0] for p in t),
|
| 174 |
+
min(p[1] for p in t), max(p[1] for p in t), i))
|
| 175 |
+
boxes.sort()
|
| 176 |
+
active = []; checked = 0
|
| 177 |
+
for box in boxes:
|
| 178 |
+
xmin,xmax,ymin,ymax,i = box
|
| 179 |
+
active = [b for b in active if b[1] > xmin]
|
| 180 |
+
for b in active:
|
| 181 |
+
checked += 1
|
| 182 |
+
if checked > max_pairs:
|
| 183 |
+
return {'complete': False, 'overlap': None, 'pairs_checked': checked-1,
|
| 184 |
+
'reason': 'candidate pair budget exceeded', 'degenerate_triangles': degenerate}
|
| 185 |
+
if b[3] <= ymin or ymax <= b[2]:
|
| 186 |
+
continue
|
| 187 |
+
area = triangle_intersection_area(triangles[b[4]], triangles[i])
|
| 188 |
+
if area > 1e-10:
|
| 189 |
+
return {'complete': True, 'overlap': True, 'triangle_indices': [b[4],i],
|
| 190 |
+
'intersection_area': area, 'pairs_checked': checked,
|
| 191 |
+
'degenerate_triangles': degenerate}
|
| 192 |
+
active.append(box)
|
| 193 |
+
return {'complete': True, 'overlap': False, 'pairs_checked': checked,
|
| 194 |
+
'degenerate_triangles': degenerate}
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def scene_facts(uv_layer=None):
|
| 198 |
+
import bpy
|
| 199 |
+
from mathutils import Vector
|
| 200 |
+
scene = bpy.context.scene
|
| 201 |
+
fps = scene.render.fps / scene.render.fps_base
|
| 202 |
+
result = {'blender_version': bpy.app.version_string, 'blend_file': bpy.data.filepath,
|
| 203 |
+
'engine': scene.render.engine, 'effective_fps': fps, 'cameras': []}
|
| 204 |
+
world = scene.rigidbody_world
|
| 205 |
+
if world:
|
| 206 |
+
result['rigid_body_world'] = {
|
| 207 |
+
'substeps_per_frame': world.substeps_per_frame,
|
| 208 |
+
'steps_per_second_at_scene_fps': world.substeps_per_frame * fps,
|
| 209 |
+
'solver_iterations': world.solver_iterations, 'time_scale': world.time_scale}
|
| 210 |
+
for camera in (o for o in scene.objects if o.type == 'CAMERA'):
|
| 211 |
+
direction = camera.matrix_world.to_quaternion() @ Vector((0,0,-1))
|
| 212 |
+
result['cameras'].append({'name': camera.name, 'active': camera == scene.camera,
|
| 213 |
+
'world_z': camera.matrix_world.translation.z,
|
| 214 |
+
'look_direction_world': list(direction),
|
| 215 |
+
'down_pitch_from_horizontal_degrees': math.degrees(math.atan2(-direction.z, math.hypot(direction.x,direction.y))),
|
| 216 |
+
'lens_mm': camera.data.lens, 'dof_enabled': camera.data.dof.use_dof,
|
| 217 |
+
'fstop': camera.data.dof.aperture_fstop})
|
| 218 |
+
if uv_layer:
|
| 219 |
+
result['uv_checks'] = []
|
| 220 |
+
for obj in scene.objects:
|
| 221 |
+
if obj.type != 'MESH':
|
| 222 |
+
continue
|
| 223 |
+
mesh = obj.data
|
| 224 |
+
row = {'object': obj.name, 'collections': [c.name for c in obj.users_collection],
|
| 225 |
+
'hide_render': obj.hide_render, 'layer': uv_layer}
|
| 226 |
+
uv = mesh.uv_layers.get(uv_layer)
|
| 227 |
+
if uv is None:
|
| 228 |
+
row.update(layer_present=False)
|
| 229 |
+
else:
|
| 230 |
+
mesh.calc_loop_triangles()
|
| 231 |
+
triangles = [[tuple(uv.data[i].uv) for i in t.loops] for t in mesh.loop_triangles]
|
| 232 |
+
row.update(layer_present=True, triangle_count=len(triangles), **find_uv_overlap(triangles))
|
| 233 |
+
result['uv_checks'].append(row)
|
| 234 |
+
return result
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def main():
|
| 238 |
+
parser = argparse.ArgumentParser()
|
| 239 |
+
parser.add_argument('--inventory-root')
|
| 240 |
+
parser.add_argument('--output', required=True)
|
| 241 |
+
parser.add_argument('--uv-layer')
|
| 242 |
+
argv = sys.argv[sys.argv.index('--')+1:] if '--' in sys.argv else sys.argv[1:]
|
| 243 |
+
args = parser.parse_args(argv)
|
| 244 |
+
data = file_inventory(args.inventory_root) if args.inventory_root else scene_facts(args.uv_layer)
|
| 245 |
+
dest = Path(args.output); dest.parent.mkdir(parents=True, exist_ok=True)
|
| 246 |
+
dest.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding='utf-8')
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
if __name__ == '__main__':
|
| 250 |
+
main()
|
bw_0221/tests/blenderworld/evaluators/judge_blender_agent.py
ADDED
|
@@ -0,0 +1,878 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""Agent-as-Judge for Blender trajectory eval (runs in parallel with the GPT-5.6-terra vision judge).
|
| 4 |
+
|
| 5 |
+
Unlike ``judge_blender_binary_rubrics.py`` (a pure-vision pass that can only score what a
|
| 6 |
+
static render shows), this judge spawns a coding agent per task -- by default the same
|
| 7 |
+
GPT-5.6-terra model the render agent already uses, via the ``claude`` CLI pointed at the
|
| 8 |
+
configured Anthropic-compatible endpoint -- that can OPEN THE SUBMITTED ``.blend`` WITH ``bpy``.
|
| 9 |
+
This lets it verify rubrics whose ``evidence_type`` is ``scene_summary`` / ``either``
|
| 10 |
+
(shape keys, drivers, Geometry-Nodes params, triangle budgets, UV layout, material node
|
| 11 |
+
graphs, ``scene.unit_settings`` / ``render.engine`` / ``cycles.samples``, exact mm
|
| 12 |
+
dimensions, physics setup) that the vision judge structurally cannot check, while still
|
| 13 |
+
using the rendered PNGs for ``render``-type (visual) rubrics.
|
| 14 |
+
|
| 15 |
+
The agent emits, per rubric, two cross-check sub-verdicts (``bpy_check`` for the .blend internals
|
| 16 |
+
and ``visual_check`` for its own renders, each pass/fail/na) + method + evidence, and per dimension a
|
| 17 |
+
1-10 impression plus a ``render_conflict`` flag. ALL scoring arithmetic (weighted rubric pass-rate,
|
| 18 |
+
dimension score, the ``0.5*dim + 0.5*rubric`` fusion, and the uncapped fusion) is done here
|
| 19 |
+
in Python, reusing the exact helpers from ``judge_blender_binary_rubrics.py``. Two worst-of-both
|
| 20 |
+
rules make the visible render authoritative: a rubric passes only if EVERY applicable sub-verdict
|
| 21 |
+
passes (so a correct bpy value cannot rescue a wrong-looking render), and any dimension the agent
|
| 22 |
+
flags with ``render_conflict`` is clamped into the low band. Both are backward-compatible (agent
|
| 23 |
+
outputs lacking the new fields score exactly as before) and can be disabled via CLI. The top-level
|
| 24 |
+
per-task ``judgement.json`` and batch schema stay IDENTICAL to the vision judge (the new fields are
|
| 25 |
+
additive inside each ``rubric_scores``/``dimension_scores`` entry; the final per-rubric ``score`` is
|
| 26 |
+
still integer 0/1), so the Stage-7 aggregate in ``main.sh`` and downstream comparisons are unchanged.
|
| 27 |
+
|
| 28 |
+
Audit trail: the agent is required to persist ``agent_bpy_dump.json`` (the bpy query script
|
| 29 |
+
+ its raw output) and ``agent_judgement_raw.json`` next to the judgement, so every
|
| 30 |
+
scene-metadata verdict is checkable after the fact.
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
from __future__ import annotations
|
| 34 |
+
|
| 35 |
+
import argparse
|
| 36 |
+
import json
|
| 37 |
+
import os
|
| 38 |
+
import subprocess
|
| 39 |
+
import sys
|
| 40 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 41 |
+
from datetime import datetime, timezone
|
| 42 |
+
from pathlib import Path
|
| 43 |
+
from typing import Any
|
| 44 |
+
|
| 45 |
+
# Reuse the vision judge's pure, model-agnostic helpers so the output schema and scoring
|
| 46 |
+
# math stay bit-for-bit consistent between the two judges.
|
| 47 |
+
from . import judge_blender_binary_rubrics as vj
|
| 48 |
+
from . import evidence_checks
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
from json_repair import repair_json
|
| 52 |
+
except Exception: # noqa: BLE001
|
| 53 |
+
def repair_json(s: str) -> str:
|
| 54 |
+
return s
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
DEFAULT_OUTPUT_DIR = "evaluation/agent_judge_multiview_eval"
|
| 58 |
+
DEFAULT_IMAGE_GLOB = "evaluation/multiview/*.png"
|
| 59 |
+
RAW_NAME = "agent_judgement_raw.json"
|
| 60 |
+
BPY_DUMP_NAME = "agent_bpy_dump.json"
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
# --------------------------------------------------------------------------------------
|
| 64 |
+
# Agent output parsing
|
| 65 |
+
# --------------------------------------------------------------------------------------
|
| 66 |
+
def cli_api_error(path: Path) -> str:
|
| 67 |
+
"""Read the CLI's terminal API failure before attempting JSON output repair."""
|
| 68 |
+
if not path.exists():
|
| 69 |
+
return ""
|
| 70 |
+
event, refused = evidence_checks.cli_log_status(path)
|
| 71 |
+
if refused:
|
| 72 |
+
return "agent_judge_upstream_content_policy_violation"
|
| 73 |
+
if event:
|
| 74 |
+
status = event.get("api_error_status")
|
| 75 |
+
if event.get("is_error") is True and status:
|
| 76 |
+
return f"agent judge API error {status}"
|
| 77 |
+
return ""
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _coerce_binary(value: Any) -> int | None:
|
| 81 |
+
if value in (0, "0", "0.0", False):
|
| 82 |
+
return 0
|
| 83 |
+
if value in (1, "1", "1.0", True):
|
| 84 |
+
return 1
|
| 85 |
+
return None
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _coerce_check(value: Any) -> str:
|
| 89 |
+
"""Normalize a per-rubric sub-verdict to ``pass`` / ``fail`` / ``na``.
|
| 90 |
+
|
| 91 |
+
Missing or unrecognized values collapse to ``na`` (not applicable), which makes the
|
| 92 |
+
cross-check enforcement a no-op for that source and lets old outputs (with no ``bpy_check`` /
|
| 93 |
+
``visual_check`` keys) fall back to the model's self-reported ``score`` unchanged."""
|
| 94 |
+
if value is None:
|
| 95 |
+
return "na"
|
| 96 |
+
s = str(value).strip().lower()
|
| 97 |
+
if s in ("pass", "passed", "ok", "yes", "true", "1", "1.0"):
|
| 98 |
+
return "pass"
|
| 99 |
+
if s in ("fail", "failed", "no", "false", "0", "0.0"):
|
| 100 |
+
return "fail"
|
| 101 |
+
return "na" # na / n/a / not_applicable / unknown / "" / anything else
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _truthy(value: Any) -> bool:
|
| 105 |
+
"""Loose truthiness for a model-emitted boolean flag (accepts true/1/yes/'true'...)."""
|
| 106 |
+
if isinstance(value, bool):
|
| 107 |
+
return value
|
| 108 |
+
if value is None:
|
| 109 |
+
return False
|
| 110 |
+
if isinstance(value, (int, float)):
|
| 111 |
+
return value != 0
|
| 112 |
+
return str(value).strip().lower() in ("true", "1", "1.0", "yes", "y")
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def normalize_agent_rubrics(
|
| 116 |
+
obj: dict[str, Any] | None,
|
| 117 |
+
rubrics: list[dict[str, Any]],
|
| 118 |
+
*,
|
| 119 |
+
enforce_cross_check: bool = True,
|
| 120 |
+
) -> tuple[bool, list[dict[str, Any]], str]:
|
| 121 |
+
"""Map the agent's per-rubric verdicts onto the canonical rubric_scores shape.
|
| 122 |
+
|
| 123 |
+
Mirrors ``vj.normalize_scores`` (id/score/evidence/source_views/confidence) and adds a
|
| 124 |
+
``method`` field (bpy|visual). Returns (ok, scores, error); ok is False if any rubric id
|
| 125 |
+
is unanswered (build_score_summary still counts those as 0, matching the vision judge).
|
| 126 |
+
|
| 127 |
+
Cross-check enforcement (``enforce_cross_check``, default True): each verdict may carry two
|
| 128 |
+
sub-verdicts, ``bpy_check`` (does the requirement hold in the .blend internals) and
|
| 129 |
+
``visual_check`` (does it hold in the agent's own renders), each ``pass``/``fail``/``na``. The
|
| 130 |
+
final ``score`` is derived as 1 iff EVERY applicable (non-``na``) sub-verdict passes -- so a
|
| 131 |
+
correct bpy value can never rescue a rubric whose render contradicts it (and vice-versa). When
|
| 132 |
+
neither sub-verdict applies (both ``na``, or the keys are absent), we fall back to the model's
|
| 133 |
+
self-reported ``score`` -- keeping old agent outputs bit-for-bit identical. The final ``score``
|
| 134 |
+
stays an integer 0/1 (relied on by ``vj.build_score_summary`` / ``vj.is_complete_judgement``);
|
| 135 |
+
the sub-verdicts + ``model_score`` + ``cross_check_applied`` are stored as an audit trail."""
|
| 136 |
+
if not obj:
|
| 137 |
+
return False, [], "agent output was not valid JSON"
|
| 138 |
+
raw_scores = obj.get("rubric_scores")
|
| 139 |
+
if not isinstance(raw_scores, list):
|
| 140 |
+
return False, [], "missing rubric_scores list"
|
| 141 |
+
|
| 142 |
+
by_id: dict[str, dict[str, Any]] = {}
|
| 143 |
+
for item in raw_scores:
|
| 144 |
+
if not isinstance(item, dict):
|
| 145 |
+
continue
|
| 146 |
+
rid = str(item.get("id", "")).strip()
|
| 147 |
+
if not rid:
|
| 148 |
+
continue
|
| 149 |
+
model_score = _coerce_binary(item.get("score"))
|
| 150 |
+
bpy_check = _coerce_check(item.get("bpy_check"))
|
| 151 |
+
visual_check = _coerce_check(item.get("visual_check"))
|
| 152 |
+
applicable = [c for c in (bpy_check, visual_check) if c in ("pass", "fail")]
|
| 153 |
+
if enforce_cross_check and applicable:
|
| 154 |
+
score = 1 if all(c == "pass" for c in applicable) else 0
|
| 155 |
+
else:
|
| 156 |
+
score = model_score
|
| 157 |
+
if score is None:
|
| 158 |
+
# No usable verdict (no valid score AND no applicable sub-check) -> treat as missing,
|
| 159 |
+
# matching the pre-existing "score is None -> skip" behavior.
|
| 160 |
+
continue
|
| 161 |
+
by_id[rid] = {
|
| 162 |
+
"id": rid,
|
| 163 |
+
"score": score,
|
| 164 |
+
"evidence": str(item.get("evidence", "")).strip(),
|
| 165 |
+
"method": str(item.get("method", "")).strip() or "unknown",
|
| 166 |
+
"bpy_check": bpy_check,
|
| 167 |
+
"visual_check": visual_check,
|
| 168 |
+
"model_score": model_score,
|
| 169 |
+
"cross_check_applied": bool(applicable) and model_score is not None and score != model_score,
|
| 170 |
+
"source_views": item.get("source_views") if isinstance(item.get("source_views"), list) else [],
|
| 171 |
+
"confidence": str(item.get("confidence", "medium")).strip() or "medium",
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
normalized: list[dict[str, Any]] = []
|
| 175 |
+
missing: list[str] = []
|
| 176 |
+
for rubric in rubrics:
|
| 177 |
+
rid = str(rubric.get("id", "")).strip()
|
| 178 |
+
if rid in by_id:
|
| 179 |
+
normalized.append(by_id[rid])
|
| 180 |
+
else:
|
| 181 |
+
missing.append(rid)
|
| 182 |
+
if missing:
|
| 183 |
+
return False, normalized, f"missing scores for ids: {missing[:10]}"
|
| 184 |
+
return True, normalized, ""
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def finalize_judgement(
|
| 188 |
+
task_dir: Path,
|
| 189 |
+
rubrics: list[dict[str, Any]],
|
| 190 |
+
raw_obj: dict[str, Any] | None,
|
| 191 |
+
cfg: dict[str, Any],
|
| 192 |
+
*,
|
| 193 |
+
render_images: list[Path] | None = None,
|
| 194 |
+
extra_images: list[Path] | None = None,
|
| 195 |
+
reference_images: list[Path] | None = None,
|
| 196 |
+
extra_meta: dict[str, Any] | None = None,
|
| 197 |
+
) -> dict[str, Any]:
|
| 198 |
+
"""Compute the canonical judgement object from the agent's raw verdicts.
|
| 199 |
+
|
| 200 |
+
Pure/deterministic given ``raw_obj``: reuses ``vj.build_score_summary`` /
|
| 201 |
+
``vj.score_dimensions`` and the same uncapped fusion logic as the vision judge
|
| 202 |
+
(``judge_blender_binary_rubrics.py`` ~1636-1662). Unit-testable without spawning an agent."""
|
| 203 |
+
render_images = render_images or []
|
| 204 |
+
extra_images = extra_images or []
|
| 205 |
+
reference_images = reference_images or []
|
| 206 |
+
images = render_images + extra_images
|
| 207 |
+
|
| 208 |
+
ok, scores, error = normalize_agent_rubrics(
|
| 209 |
+
raw_obj, rubrics, enforce_cross_check=bool(cfg.get("cross_check", True))
|
| 210 |
+
)
|
| 211 |
+
total = sum(item["score"] for item in scores)
|
| 212 |
+
max_score = len(rubrics)
|
| 213 |
+
score_summary = vj.build_score_summary(rubrics, scores)
|
| 214 |
+
|
| 215 |
+
rubric_score_0_100 = score_summary["weighted_score_0_100"]
|
| 216 |
+
dim_result = vj.score_dimensions(raw_obj, vj.DIMENSIONS) if cfg.get("dimension_pass", True) else None
|
| 217 |
+
if cfg.get("dimension_pass", True) and (not dim_result or not dim_result["ok"]):
|
| 218 |
+
ok = False
|
| 219 |
+
error = "; ".join(x for x in [error, "dimension judge failed"] if x)
|
| 220 |
+
|
| 221 |
+
# Worst-of-both for the 1-10 dimensions: if the agent flagged a dimension's .blend internals as
|
| 222 |
+
# looking correct/better than what its renders actually show (`render_conflict`), the visible
|
| 223 |
+
# result governs -- clamp that dimension into the low band. This mirrors the rubric cross-check
|
| 224 |
+
# and runs before score fusion. The routed public protocol uses the VLM for dimensions.
|
| 225 |
+
dim_conflict_cap = cfg.get("dimension_conflict_cap")
|
| 226 |
+
if dim_result and dim_result.get("ok") and dim_conflict_cap is not None:
|
| 227 |
+
raw_dims = (raw_obj or {}).get("dimensions")
|
| 228 |
+
conflict_ids = {
|
| 229 |
+
str(d.get("id", "")).strip()
|
| 230 |
+
for d in (raw_dims if isinstance(raw_dims, list) else [])
|
| 231 |
+
if isinstance(d, dict) and _truthy(d.get("render_conflict"))
|
| 232 |
+
}
|
| 233 |
+
conflict_ids.discard("")
|
| 234 |
+
capped_any = False
|
| 235 |
+
for row in dim_result.get("dimension_scores", []):
|
| 236 |
+
if str(row.get("id", "")).strip() in conflict_ids:
|
| 237 |
+
row["render_conflict"] = True
|
| 238 |
+
if int(row.get("score", 0)) > dim_conflict_cap:
|
| 239 |
+
row["original_score"] = row.get("score")
|
| 240 |
+
row["score"] = dim_conflict_cap
|
| 241 |
+
issues = row.get("issues")
|
| 242 |
+
if not isinstance(issues, list):
|
| 243 |
+
issues = []
|
| 244 |
+
issues.append(
|
| 245 |
+
f"render conflicts with .blend internals; capped to <= {dim_conflict_cap}"
|
| 246 |
+
)
|
| 247 |
+
row["issues"] = issues
|
| 248 |
+
capped_any = True
|
| 249 |
+
if capped_any:
|
| 250 |
+
denom = 10 * len(vj.DIMENSIONS)
|
| 251 |
+
total_dim = sum(int(r.get("score", 0)) for r in dim_result["dimension_scores"])
|
| 252 |
+
dim_result["dimension_score_0_100"] = (100.0 * total_dim / denom) if denom else 0.0
|
| 253 |
+
|
| 254 |
+
w = float(cfg.get("dimension_weight", 0.5))
|
| 255 |
+
if dim_result and dim_result["ok"]:
|
| 256 |
+
dimension_score_0_100 = dim_result["dimension_score_0_100"]
|
| 257 |
+
fused_score_0_100 = w * dimension_score_0_100 + (1.0 - w) * rubric_score_0_100
|
| 258 |
+
else:
|
| 259 |
+
dimension_score_0_100 = None
|
| 260 |
+
fused_score_0_100 = rubric_score_0_100 # fall back to rubric-only
|
| 261 |
+
|
| 262 |
+
cap_applied = False
|
| 263 |
+
cap_reason = ""
|
| 264 |
+
|
| 265 |
+
obj: dict[str, Any] = {
|
| 266 |
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
| 267 |
+
"task_dir": str(task_dir),
|
| 268 |
+
"judge_kind": "agent",
|
| 269 |
+
"model": cfg.get("model", ""),
|
| 270 |
+
"reference_image_files": [vj.rel(p, task_dir) for p in reference_images],
|
| 271 |
+
"image_files": [vj.rel(p, task_dir) for p in images],
|
| 272 |
+
"rendered_image_files": [vj.rel(p, task_dir) for p in render_images],
|
| 273 |
+
"extra_image_files": [vj.rel(p, task_dir) for p in extra_images],
|
| 274 |
+
"rubric_count": len(rubrics),
|
| 275 |
+
"score": total,
|
| 276 |
+
"max_score": max_score,
|
| 277 |
+
"normalized_score": (total / max_score) if max_score else 0.0,
|
| 278 |
+
"raw_pass": score_summary["raw_pass"],
|
| 279 |
+
"raw_total": score_summary["raw_total"],
|
| 280 |
+
"raw_score_0_100": score_summary["raw_score_0_100"],
|
| 281 |
+
"weighted_pass": score_summary["weighted_pass"],
|
| 282 |
+
"weighted_total": score_summary["weighted_total"],
|
| 283 |
+
"weighted_score_0_100": score_summary["weighted_score_0_100"],
|
| 284 |
+
"score_summary": score_summary,
|
| 285 |
+
"passed_count": total,
|
| 286 |
+
"failed_count": max_score - total,
|
| 287 |
+
"rubric_scores": scores,
|
| 288 |
+
"overall_notes": str((raw_obj or {}).get("overall_notes", "")).strip(),
|
| 289 |
+
# the agent judge does not run a separate blind pass
|
| 290 |
+
"blind_pass": False,
|
| 291 |
+
"blind_description": None,
|
| 292 |
+
"blind_reference_description": None,
|
| 293 |
+
"rubric_batch_size": 0,
|
| 294 |
+
"rubric_chunk_count": 1,
|
| 295 |
+
# --- holistic dimension scoring + fusion ---
|
| 296 |
+
"dimension_pass": bool(cfg.get("dimension_pass", True)),
|
| 297 |
+
"dimension_weight": w,
|
| 298 |
+
"rubric_score_0_100": rubric_score_0_100,
|
| 299 |
+
"dimension_score_0_100": dimension_score_0_100,
|
| 300 |
+
"fused_score_0_100": fused_score_0_100,
|
| 301 |
+
"cap_applied": cap_applied,
|
| 302 |
+
"cap_reason": cap_reason,
|
| 303 |
+
"dimension_scores": (dim_result or {}).get("dimension_scores", []),
|
| 304 |
+
"core_objects_recognizable": (dim_result or {}).get("core_objects_recognizable"),
|
| 305 |
+
"catastrophic_failure": (dim_result or {}).get("catastrophic_failure"),
|
| 306 |
+
"dimension_missing": (dim_result or {}).get("missing_dimensions", []),
|
| 307 |
+
"dimension_notes": str((raw_obj or {}).get("dimension_notes", (raw_obj or {}).get("overall_notes", ""))).strip(),
|
| 308 |
+
"ok": ok,
|
| 309 |
+
}
|
| 310 |
+
if dim_result and not dim_result["ok"]:
|
| 311 |
+
obj["dimension_error"] = dim_result.get("error", "")
|
| 312 |
+
if not ok:
|
| 313 |
+
obj["error"] = error
|
| 314 |
+
if extra_meta:
|
| 315 |
+
obj.update(extra_meta)
|
| 316 |
+
if obj.get("agent_error"):
|
| 317 |
+
obj["ok"] = False
|
| 318 |
+
obj["error"] = obj["agent_error"]
|
| 319 |
+
return obj
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
# --------------------------------------------------------------------------------------
|
| 323 |
+
# Agent prompt + invocation
|
| 324 |
+
# --------------------------------------------------------------------------------------
|
| 325 |
+
def render_rubrics_for_agent(rubrics: list[dict[str, Any]]) -> str:
|
| 326 |
+
lines = []
|
| 327 |
+
for item in rubrics:
|
| 328 |
+
lines.append(
|
| 329 |
+
json.dumps(
|
| 330 |
+
{
|
| 331 |
+
"id": item.get("id"),
|
| 332 |
+
"category": item.get("category") or item.get("category_v2"),
|
| 333 |
+
"evidence_type": item.get("evidence_type"),
|
| 334 |
+
"criterion": item.get("criterion"),
|
| 335 |
+
"pass_condition": item.get("pass_condition"),
|
| 336 |
+
"fail_condition": item.get("fail_condition"),
|
| 337 |
+
},
|
| 338 |
+
ensure_ascii=False,
|
| 339 |
+
)
|
| 340 |
+
)
|
| 341 |
+
return "\n".join(lines)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def build_prompt(
|
| 345 |
+
task_dir: Path,
|
| 346 |
+
prompt_text: str,
|
| 347 |
+
rubrics: list[dict[str, Any]],
|
| 348 |
+
*,
|
| 349 |
+
blend_files: list[Path],
|
| 350 |
+
render_images: list[Path],
|
| 351 |
+
extra_images: list[Path],
|
| 352 |
+
reference_images: list[Path],
|
| 353 |
+
blender_bin: str,
|
| 354 |
+
output_rel: str,
|
| 355 |
+
use_bpy: bool,
|
| 356 |
+
render_required: bool = True,
|
| 357 |
+
) -> str:
|
| 358 |
+
def rels(paths: list[Path]) -> str:
|
| 359 |
+
return "\n".join(f" - {vj.rel(p, task_dir)}" for p in paths) or " (none)"
|
| 360 |
+
|
| 361 |
+
inventory = evidence_checks.file_inventory(task_dir / ".eval_workspace")
|
| 362 |
+
inventory_path = task_dir / output_rel / "submission_manifest.json"
|
| 363 |
+
inventory_path.parent.mkdir(parents=True, exist_ok=True)
|
| 364 |
+
inventory_path.write_text(json.dumps(inventory, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 365 |
+
# The full deterministic manifest stays available even for long sequences.
|
| 366 |
+
inventory_preview = json.dumps({**inventory, "files": inventory["files"][:80]}, ensure_ascii=False)
|
| 367 |
+
checks_script = str(Path(evidence_checks.__file__).resolve())
|
| 368 |
+
dims = "\n".join(f" - {d['id']}: {d['name']} — {d['desc']}" for d in vj.DIMENSIONS)
|
| 369 |
+
raw_rel = f"{output_rel}/{RAW_NAME}"
|
| 370 |
+
bpy_rel = f"{output_rel}/{BPY_DUMP_NAME}"
|
| 371 |
+
renders_rel = f"{output_rel}/agent_renders"
|
| 372 |
+
|
| 373 |
+
# RENDERING POLICY (both modes): rendering is expensive and, in this headless GPU container,
|
| 374 |
+
# EEVEE/Workbench silently degrade or fail — any scoring render MUST go through Cycles. When
|
| 375 |
+
# render_required is False (evidence routing: this agent only owns structural / scene_summary
|
| 376 |
+
# rubrics decided from the .blend internals) the agent should NOT render unless a specific
|
| 377 |
+
# rubric genuinely cannot be settled from bpy.
|
| 378 |
+
cycles_rule = (
|
| 379 |
+
"Whenever you render, you MUST use Cycles — never EEVEE/Workbench, which are unreliable "
|
| 380 |
+
"headless here and degrade quality. In your render script set "
|
| 381 |
+
"`scene.render.engine='CYCLES'`, select the GPU "
|
| 382 |
+
"(`bpy.context.preferences.addons['cycles'].preferences.compute_device_type='OPTIX'` or "
|
| 383 |
+
"`'CUDA'`, refresh devices, enable them, then `scene.cycles.device='GPU'`), and use enough "
|
| 384 |
+
"samples (>=64) so the image is not noisy. Confirm the engine is actually CYCLES before "
|
| 385 |
+
"trusting a render."
|
| 386 |
+
)
|
| 387 |
+
export_scan_rule = (
|
| 388 |
+
"When a rubric concerns an EXPORTED deliverable (a PNG image, a rendered still, an "
|
| 389 |
+
"animation/video such as .mp4/.mov/.gif/.webm, or a baked texture), verify its existence "
|
| 390 |
+
"by scanning the WHOLE submission export tree — check `exports/`, `output/`, `renders/`, "
|
| 391 |
+
"and the submission root recursively (e.g. `find . -type f \\( -iname '*.png' -o -iname "
|
| 392 |
+
"'*.mp4' -o -iname '*.mov' -o -iname '*.gif' -o -iname '*.webm' \\)`). Do NOT assume one "
|
| 393 |
+
"fixed folder; score such a rubric on whether the file actually exists somewhere under the "
|
| 394 |
+
"export paths."
|
| 395 |
+
)
|
| 396 |
+
if render_required:
|
| 397 |
+
render_intro = (
|
| 398 |
+
"Author-delivered images are listed below. To judge any appearance/visual "
|
| 399 |
+
"rubric inspect the relevant author file, or render targeted scene evidence in STEP 3 when needed. If you "
|
| 400 |
+
"have neither inspected a relevant author image nor produced a relevant render, do not pass a visual rubric. " + cycles_rule
|
| 401 |
+
)
|
| 402 |
+
step3 = (
|
| 403 |
+
"STEP 3 — Render MULTIPLE targeted images yourself, GUIDED by the rubric + prompt + "
|
| 404 |
+
"dimensions. " + cycles_rule + " Open a COPY of the .blend and render as many views as "
|
| 405 |
+
"you need — an overview PLUS the specific angles, close-ups and framings that expose what "
|
| 406 |
+
"the rubrics and each dimension actually check (e.g. a close-up on a part a rubric names; "
|
| 407 |
+
"an angle showing support/contact for `physics`; a wide shot for "
|
| 408 |
+
"`layout_spatial`/`completeness`; a material close-up for `lighting_material`/`style_color`). "
|
| 409 |
+
"You may adjust temporary cameras in your COPY. Preserve geometry, materials, lights, animation, visibility and color management. Save all images to " + renders_rel +
|
| 410 |
+
"/ with descriptive names and note what each one shows."
|
| 411 |
+
)
|
| 412 |
+
else:
|
| 413 |
+
render_intro = (
|
| 414 |
+
"You are scoring STRUCTURAL / scene_summary rubrics that are decided from the .blend "
|
| 415 |
+
"INTERNALS via bpy, NOT from appearance. You normally do NOT need to render anything, and "
|
| 416 |
+
"you should NOT re-render unless a specific rubric genuinely cannot be settled from the "
|
| 417 |
+
".blend internals. " + cycles_rule
|
| 418 |
+
)
|
| 419 |
+
step3 = (
|
| 420 |
+
"STEP 3 — Rendering is OPTIONAL for these rubrics and usually unnecessary. Do NOT render "
|
| 421 |
+
"just to have an image. Render your OWN image(s) into " + renders_rel + "/ ONLY if a "
|
| 422 |
+
"specific rubric truly requires visual confirmation that bpy cannot give; if you do, "
|
| 423 |
+
+ cycles_rule + " Preserve geometry, materials, lights, animation, visibility and color management. If no rubric needs a render, skip this step entirely (that is expected "
|
| 424 |
+
"and not an error)."
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
return f"""You are an AGENT-AS-JUDGE for a Blender scene-reconstruction benchmark. You are NOT solving
|
| 428 |
+
the task. You SCORE an already-submitted result (a .blend) against a fixed rubric list and a set of
|
| 429 |
+
holistic dimensions. Unlike an image-only judge you can (a) open the submitted .blend to inspect the
|
| 430 |
+
"original code" — its objects, modifiers, geometry-node graphs, shape keys, drivers, materials, scene
|
| 431 |
+
settings, and any embedded text/script data-blocks — AND (b) render your OWN targeted images from it.
|
| 432 |
+
|
| 433 |
+
# Task prompt given to the solver (the TARGET; the submission is what you judge)
|
| 434 |
+
{prompt_text}
|
| 435 |
+
|
| 436 |
+
# Submitted artifacts (paths relative to your working directory)
|
| 437 |
+
Submitted .blend file(s) — the "original code" (READ-ONLY: work on a COPY; never edit/re-save the original):
|
| 438 |
+
{rels(blend_files)}
|
| 439 |
+
Reference / target image(s) (the goal; do NOT credit the submission for something only here):
|
| 440 |
+
{rels(reference_images)}
|
| 441 |
+
Author-delivered images already discovered (these are original files, not your renders):
|
| 442 |
+
{rels(extra_images)}
|
| 443 |
+
Original file inventory (first 80 records; includes PNG IHDR bit depth):
|
| 444 |
+
{inventory_preview}
|
| 445 |
+
Read the FULL inventory at `{vj.rel(inventory_path, task_dir)}` when needed. Inspect the whole `.eval_workspace/` tree, including root-level exports, nested frame sequences, FBX/EXR and accompanying textures. A configured absolute output path in the .blend may be stale: it is not evidence that a delivered file is absent. Do not count evaluator renders, input references or sampled video frames as author-delivered files. The hashes of supplied inputs are listed in `input_media_sha256.json` when present.
|
| 446 |
+
Blender executable: {blender_bin}
|
| 447 |
+
Read-only evidence helper: `{checks_script}`
|
| 448 |
+
To inspect camera optics and rigid-body units, run the original file with autoexec disabled:
|
| 449 |
+
`{blender_bin} --background <original.blend> --disable-autoexec --python {checks_script} -- --output <probe.json>`
|
| 450 |
+
For a second-UV non-overlap condition add `--uv-layer <actual-layer-name>`. Inspect the relevant low-poly meshes; an incomplete scan is unknown, never proof of no overlap. The helper checks original mesh UVs; inspect evaluated geometry too when modifiers generate or alter the deliverable UVs.
|
| 451 |
+
|
| 452 |
+
{render_intro}
|
| 453 |
+
|
| 454 |
+
Work in this EXACT order:
|
| 455 |
+
|
| 456 |
+
STEP 1 — Plan. Read the task prompt above, EVERY rubric below (note each rubric's `evidence_type`),
|
| 457 |
+
and the {len(vj.DIMENSIONS)} holistic dimensions with their descriptions. Decide which scene facts to
|
| 458 |
+
extract from the .blend and which views / close-ups / angles will best reveal the rubric criteria and
|
| 459 |
+
each dimension.
|
| 460 |
+
|
| 461 |
+
STEP 2 — Inspect the .blend internals (the "original code") with bpy. Run Blender headless
|
| 462 |
+
(`{blender_bin} --background <copy-of-blend> --python /tmp/probe.py`) to extract exactly what the
|
| 463 |
+
rubrics/dimensions need: object list & names, mesh triangle counts, modifiers / Geometry-Nodes
|
| 464 |
+
node-group inputs & values, shape-key/blendshape names & counts, drivers, object bounding-box
|
| 465 |
+
dimensions (mm), scene unit settings (`scene.unit_settings`), render engine/samples/resolution,
|
| 466 |
+
material node graphs (Principled/SSS/IOR), UV layout & overlap, physics / rigid-body / Dynamic-Paint
|
| 467 |
+
settings, collections, and any embedded Text data-blocks (scripts). Save your probe script + raw
|
| 468 |
+
output to `{bpy_rel}` (JSON) as an audit trail. DO NOT modify or re-save the original .blend.
|
| 469 |
+
{export_scan_rule}
|
| 470 |
+
|
| 471 |
+
Evidence rules:
|
| 472 |
+
- PNG bit depth comes from the original PNG IHDR, not Pillow's RGB/RGBA mode; Pillow commonly presents 16-bit RGB files as RGB. Use the manifest or evidence helper.
|
| 473 |
+
- For alpha, inspect the actual channel and composite over a checkerboard. A black-looking RGB preview neither proves nor disproves transparency. Validate silhouettes in the actual alpha image.
|
| 474 |
+
- Convert rigid-body substeps_per_frame using effective fps = fps/fps_base. For example, 10 substeps/frame at 24 fps equals 240 steps/second; record time_scale separately. Do not compare different units directly.
|
| 475 |
+
- Camera downward pitch is measured from the world optical axis (local -Z) to the horizontal plane, not from Euler X. Euler X about 65 degrees can correspond to downward pitch about 25 degrees.
|
| 476 |
+
- UV layer names do not prove non-overlap. Check positive-area triangle intersections within the requested layer, allowing shared boundaries. Check actual coordinates, not beauty renders or labels.
|
| 477 |
+
- Preserve the original .blend as the source of settings. If using a copy for rendering, do not report changed render/world settings as original facts.
|
| 478 |
+
- Final-image composition, focus, noise and required deliverable appearance must be checked against the designated author final file. Previews or your rerenders cannot replace that file. Scene existence/geometry can use targeted views.
|
| 479 |
+
- Exact numerical facts, metadata and UV tests are structural checks: use visual_check=na where pixels cannot establish the numeric fact. A dimension that looks plausible is not an independent numeric measurement.
|
| 480 |
+
|
| 481 |
+
{step3}
|
| 482 |
+
|
| 483 |
+
STEP 4 — Score EVERY rubric by CROSS-CHECKING both evidence sources. Do NOT pick a single method and
|
| 484 |
+
stop. For each rubric produce TWO independent sub-verdicts, each `pass` / `fail` / `na`:
|
| 485 |
+
- `bpy_check`: does the requirement hold in the .blend INTERNALS (bpy)? Use `na` ONLY when the rubric
|
| 486 |
+
has no structural/internal aspect (e.g. "reads as a real chair" — a purely visual judgment).
|
| 487 |
+
- `visual_check`: does the requirement hold in YOUR rendered images? Use `na` ONLY when it is
|
| 488 |
+
genuinely invisible in any render you could make (e.g. triangle-count / UV-overlap / a driver).
|
| 489 |
+
At least one sub-verdict must be non-`na`. Whenever BOTH apply — colour, material, a part being
|
| 490 |
+
present AND correctly shaped, a dimension that is visible, layout — you MUST fill BOTH, and the rubric
|
| 491 |
+
passes ONLY if BOTH pass.
|
| 492 |
+
|
| 493 |
+
THE VISIBLE RENDER IS GROUND TRUTH for appearance. A correct internal value NEVER rescues a wrong
|
| 494 |
+
appearance, and vice-versa. Concretely: if the Principled BSDF base colour is red in the node graph
|
| 495 |
+
(`bpy_check`="pass") but the object renders grey/wrong (`visual_check`="fail"), the rubric FAILS —
|
| 496 |
+
because the material is on the wrong slot, unassigned to the visible faces, overridden by emission /
|
| 497 |
+
vertex colour, or the UVs are broken. Any such mismatch is a FAIL, not a pass.
|
| 498 |
+
|
| 499 |
+
Set the final `score`: 1 only if EVERY applicable (non-`na`) sub-verdict is `pass`, otherwise 0 (the
|
| 500 |
+
harness re-derives this from your sub-verdicts, so make them consistent). Score what is ACTUALLY
|
| 501 |
+
present in the submission (.blend + your renders), never what the prompt merely asked for. If truly
|
| 502 |
+
unverifiable even with bpy + targeted renders, score 0 and say why. Also set `method`="bpy" or
|
| 503 |
+
"visual" for the source that was decisive, and give a short concrete `evidence` string that cites the
|
| 504 |
+
bpy fact AND/OR the render file for each sub-verdict you made.
|
| 505 |
+
|
| 506 |
+
RUBRICS (one JSON object per line):
|
| 507 |
+
{render_rubrics_for_agent(rubrics)}
|
| 508 |
+
|
| 509 |
+
STEP 5 — Rate these {len(vj.DIMENSIONS)} dimensions as integers 1-10, scored by WHAT THE RENDER
|
| 510 |
+
VISIBLY ACHIEVES. The .blend internals may only CONFIRM or LOWER a dimension — a correct internal
|
| 511 |
+
value can NEVER raise a dimension above the visible result. Be strict & calibrated: 9-10 only for
|
| 512 |
+
essentially faithful results; 7-8 good with minor issues; 5-6 clear problems; 3-4 major failures;
|
| 513 |
+
1-2 absent/broken. Do NOT cluster at 7-8. Each dimension needs concrete `reasons` (cite views) + an
|
| 514 |
+
`issues` list.
|
| 515 |
+
{dims}
|
| 516 |
+
For EACH dimension also set a boolean `render_conflict`: true when the .blend internals look
|
| 517 |
+
correct/better than what the renders actually show, or the two disagree (e.g. materials/colours/parts
|
| 518 |
+
that are right in bpy but wrong or missing on screen). When `render_conflict` is true you MUST put
|
| 519 |
+
that dimension in the LOW band (the visible result governs; the harness additionally clamps such
|
| 520 |
+
dimensions).
|
| 521 |
+
Also two booleans: `core_objects_recognizable` (main requested objects independently recognizable) and
|
| 522 |
+
`catastrophic_failure` (scene fundamentally fails / unusable as requested).
|
| 523 |
+
|
| 524 |
+
STEP 6 — Write your verdict as a single JSON object to `{raw_rel}` (create the folder if needed),
|
| 525 |
+
EXACTLY this shape and nothing else in the file:
|
| 526 |
+
{{
|
| 527 |
+
"rubric_scores": [
|
| 528 |
+
{{"id": "R01", "score": 0 or 1, "bpy_check": "pass"/"fail"/"na", "visual_check": "pass"/"fail"/"na", "method": "bpy" or "visual", "evidence": "short reason"}}
|
| 529 |
+
// one entry per rubric id above, all of them
|
| 530 |
+
],
|
| 531 |
+
"dimensions": [
|
| 532 |
+
{{"id": "scene_fidelity", "score": 1-10, "render_conflict": true or false, "reasons": "...", "issues": ["..."]}}
|
| 533 |
+
// one entry per dimension id above, all of them
|
| 534 |
+
],
|
| 535 |
+
"core_objects_recognizable": true or false,
|
| 536 |
+
"catastrophic_failure": true or false,
|
| 537 |
+
"overall_notes": "short summary of the main strengths and failures"
|
| 538 |
+
}}
|
| 539 |
+
|
| 540 |
+
Rules: include every rubric id and every dimension id exactly once; integer scores; each rubric's
|
| 541 |
+
`score` must equal 1 iff every applicable (non-`na`) sub-verdict is `pass`; valid JSON (no trailing
|
| 542 |
+
commas/comments). When `{raw_rel}` is written you are done.
|
| 543 |
+
"""
|
| 544 |
+
|
| 545 |
+
|
| 546 |
+
def retry_preface(attempt: int, max_attempts: int, raw_rel: str, reason: str) -> str:
|
| 547 |
+
"""Preface prepended to the judge prompt on a retry.
|
| 548 |
+
|
| 549 |
+
Instead of silently dropping a non-conforming agent judgement to the VLM the moment it fails
|
| 550 |
+
to parse, we re-tell the agent exactly why its previous ``agent_judgement_raw.json`` was
|
| 551 |
+
rejected and ask it to re-emit a complete, valid JSON verdict."""
|
| 552 |
+
return (
|
| 553 |
+
f"RETRY {attempt}/{max_attempts}: your previous write to `{raw_rel}` was REJECTED because: "
|
| 554 |
+
f"{reason}. Common causes: the file was not valid JSON, or some rubric ids were "
|
| 555 |
+
f"missing/duplicated. Re-read EVERY rubric id listed below and re-emit the COMPLETE JSON "
|
| 556 |
+
f"object exactly per the STEP 6 shape — include every rubric id and every dimension id "
|
| 557 |
+
f"exactly once, integer scores, valid JSON only (no comments / no trailing commas), and "
|
| 558 |
+
f"nothing else in the file. Overwrite `{raw_rel}` with the corrected JSON.\n\n"
|
| 559 |
+
)
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
def run_one_task(result: dict[str, Any], cfg: dict[str, Any]) -> dict[str, Any] | None:
|
| 563 |
+
task_dir = Path(str(result.get("task_dir") or "")).expanduser()
|
| 564 |
+
rubrics = result.get("rubrics") or []
|
| 565 |
+
tname = task_dir.name
|
| 566 |
+
# Under evidence_type routing this judge only scores a subset (e.g. scene_summary). Filter
|
| 567 |
+
# immediately so is_complete/normalize/finalize all key off the same subset id-set, and the
|
| 568 |
+
# VLM judge owns the rest. Empty set = score every rubric (legacy behavior).
|
| 569 |
+
ev_types = cfg.get("agent_evidence_types") or set()
|
| 570 |
+
if ev_types:
|
| 571 |
+
rubrics = [r for r in rubrics if str(r.get("evidence_type") or "").strip().lower() in ev_types]
|
| 572 |
+
if not rubrics:
|
| 573 |
+
vj.log.info("[agent-judge] skip %s: no rubrics with evidence_type in %s", tname, sorted(ev_types))
|
| 574 |
+
return None
|
| 575 |
+
if not task_dir.is_dir():
|
| 576 |
+
return {"task_dir": str(task_dir), "ok": False, "error": "task_dir not found", "rubric_scores": []}
|
| 577 |
+
if not rubrics:
|
| 578 |
+
return {"task_dir": str(task_dir), "ok": False, "error": "no rubrics", "rubric_scores": []}
|
| 579 |
+
|
| 580 |
+
out_path = vj.output_path(task_dir, cfg["output_dir"])
|
| 581 |
+
rubric_ids = {str(r.get("id")) for r in rubrics}
|
| 582 |
+
if not cfg["overwrite"] and vj.is_complete_judgement(out_path, rubric_ids):
|
| 583 |
+
vj.log.info("[agent-judge] skip complete %s", tname)
|
| 584 |
+
return json.loads(out_path.read_text(encoding="utf-8"))
|
| 585 |
+
|
| 586 |
+
render_images = vj.find_render_images(task_dir, cfg["image_glob"], cfg["max_images"])
|
| 587 |
+
extra_images = vj.find_extra_submission_images(task_dir, cfg["extra_image_globs"], cfg["max_extra_images"])
|
| 588 |
+
reference_images = (
|
| 589 |
+
[] if cfg["no_reference_images"]
|
| 590 |
+
else vj.find_reference_images(task_dir, cfg["reference_image_glob"], cfg["max_reference_images"])
|
| 591 |
+
)
|
| 592 |
+
# The public submission contract names the primary project explicitly.
|
| 593 |
+
primary_project = task_dir / ".eval_workspace" / "final.blend"
|
| 594 |
+
blend_files = [primary_project] if primary_project.is_file() else []
|
| 595 |
+
|
| 596 |
+
output_rel = Path(cfg["output_dir"])
|
| 597 |
+
output_rel = output_rel if not output_rel.is_absolute() else Path(tname)
|
| 598 |
+
output_rel_str = output_rel.as_posix()
|
| 599 |
+
(task_dir / output_rel).mkdir(parents=True, exist_ok=True)
|
| 600 |
+
raw_path = task_dir / output_rel / RAW_NAME
|
| 601 |
+
if cfg["overwrite"] and raw_path.exists():
|
| 602 |
+
raw_path.unlink()
|
| 603 |
+
|
| 604 |
+
# Renders are required only when this judge owns visual rubrics. Under evidence routing it owns
|
| 605 |
+
# only scene_summary (structural, decided from bpy) → do NOT force a render (that render is
|
| 606 |
+
# wasteful and, if it fails headless, would falsely error the whole scene_summary verdict).
|
| 607 |
+
render_required = (not ev_types) or bool(ev_types & {"either", "render", "visual", "image"})
|
| 608 |
+
prompt = build_prompt(
|
| 609 |
+
task_dir, str(result.get("prompt", "")), rubrics,
|
| 610 |
+
blend_files=blend_files, render_images=render_images, extra_images=extra_images,
|
| 611 |
+
reference_images=reference_images, blender_bin=cfg["blender_bin"],
|
| 612 |
+
output_rel=output_rel_str, use_bpy=cfg["use_bpy"] and bool(blend_files),
|
| 613 |
+
render_required=render_required,
|
| 614 |
+
)
|
| 615 |
+
|
| 616 |
+
base_prompt = prompt
|
| 617 |
+
raw_rel = f"{output_rel_str}/{RAW_NAME}"
|
| 618 |
+
max_attempts = max(1, int(cfg.get("max_attempts", 3)))
|
| 619 |
+
returncode: int | None = None
|
| 620 |
+
agent_error = ""
|
| 621 |
+
raw_obj: dict[str, Any] | None = None
|
| 622 |
+
attempts_used = 0
|
| 623 |
+
last_reason = ""
|
| 624 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.jsonl"
|
| 625 |
+
|
| 626 |
+
if cfg["dry_run"]:
|
| 627 |
+
(task_dir / output_rel / "agent_judge_prompt.txt").write_text(base_prompt, encoding="utf-8")
|
| 628 |
+
else:
|
| 629 |
+
# Instead of dropping non-conforming agent output straight to the VLM, re-prompt the agent
|
| 630 |
+
# with what was wrong and let it re-score, up to max_attempts. Only JSON-conformance misses
|
| 631 |
+
# are retried; a timeout / missing-claude / spawn error is infrastructure, not the agent's
|
| 632 |
+
# scoring, so we stop and let the VLM fallback (load_agent_verdicts guard) handle it.
|
| 633 |
+
for attempt in range(1, max_attempts + 1):
|
| 634 |
+
attempts_used = attempt
|
| 635 |
+
if attempt == 1:
|
| 636 |
+
prompt_n = base_prompt
|
| 637 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.jsonl"
|
| 638 |
+
else:
|
| 639 |
+
prompt_n = retry_preface(attempt, max_attempts, raw_rel, last_reason) + base_prompt
|
| 640 |
+
stdout_rel = f"{output_rel_str}/agent_judge_stdout.attempt{attempt}.jsonl"
|
| 641 |
+
if raw_path.exists():
|
| 642 |
+
raw_path.unlink() # drop the previous bad file so it can't be misread as success
|
| 643 |
+
cmd = [
|
| 644 |
+
"claude", "--verbose",
|
| 645 |
+
"--max-turns", str(cfg["max_turns"]),
|
| 646 |
+
"--output-format", "stream-json",
|
| 647 |
+
"--allowedTools", "Bash", "Read", "Write", "Edit", "Glob", "Grep", "LS",
|
| 648 |
+
"--disallowedTools", "WebFetch", "WebSearch",
|
| 649 |
+
"-p", prompt_n,
|
| 650 |
+
]
|
| 651 |
+
env = os.environ.copy()
|
| 652 |
+
env["ANTHROPIC_BASE_URL"] = cfg["anthropic_base_url"]
|
| 653 |
+
env.setdefault("ANTHROPIC_API_KEY", cfg["anthropic_api_key"])
|
| 654 |
+
env.setdefault("ANTHROPIC_AUTH_TOKEN", "")
|
| 655 |
+
if cfg["model"]:
|
| 656 |
+
env["ANTHROPIC_MODEL"] = cfg["model"]
|
| 657 |
+
agent_error = ""
|
| 658 |
+
try:
|
| 659 |
+
with (task_dir / stdout_rel).open("w", encoding="utf-8") as stdout:
|
| 660 |
+
completed = subprocess.run(
|
| 661 |
+
cmd, cwd=str(task_dir), env=env,
|
| 662 |
+
stdout=stdout, stderr=subprocess.STDOUT,
|
| 663 |
+
text=True, timeout=cfg["timeout"], check=False,
|
| 664 |
+
)
|
| 665 |
+
returncode = completed.returncode
|
| 666 |
+
except subprocess.TimeoutExpired:
|
| 667 |
+
returncode = 124
|
| 668 |
+
agent_error = f"agent judge timed out after {cfg['timeout']}s"
|
| 669 |
+
except FileNotFoundError:
|
| 670 |
+
returncode = 127
|
| 671 |
+
agent_error = "claude command not found"
|
| 672 |
+
except Exception as exc: # noqa: BLE001
|
| 673 |
+
returncode = 1
|
| 674 |
+
agent_error = repr(exc)
|
| 675 |
+
|
| 676 |
+
# A terminal API failure is not a malformed judgement. In particular, an explicit
|
| 677 |
+
# content refusal must stop here, without a JSON repair retry or VLM fallback.
|
| 678 |
+
agent_error = agent_error or cli_api_error(task_dir / stdout_rel)
|
| 679 |
+
if agent_error:
|
| 680 |
+
break
|
| 681 |
+
|
| 682 |
+
# Parse this attempt's raw output (with json_repair fallback).
|
| 683 |
+
raw_obj = None
|
| 684 |
+
if raw_path.exists():
|
| 685 |
+
try:
|
| 686 |
+
text = raw_path.read_text(encoding="utf-8")
|
| 687 |
+
try:
|
| 688 |
+
raw_obj = json.loads(text)
|
| 689 |
+
except Exception: # noqa: BLE001
|
| 690 |
+
raw_obj = json.loads(repair_json(text))
|
| 691 |
+
except Exception as exc: # noqa: BLE001
|
| 692 |
+
raw_obj = None
|
| 693 |
+
last_reason = f"could not parse {RAW_NAME}: {exc!r}"
|
| 694 |
+
else:
|
| 695 |
+
last_reason = f"agent did not write {RAW_NAME}"
|
| 696 |
+
|
| 697 |
+
# Conformance probe (reuses the same normalization finalize will apply): ok iff valid
|
| 698 |
+
# JSON with a score for every rubric id.
|
| 699 |
+
if raw_obj is not None:
|
| 700 |
+
probe_ok, _, probe_reason = normalize_agent_rubrics(
|
| 701 |
+
raw_obj, rubrics, enforce_cross_check=bool(cfg.get("cross_check", True))
|
| 702 |
+
)
|
| 703 |
+
if probe_ok:
|
| 704 |
+
break # valid, complete scoring — done
|
| 705 |
+
last_reason = probe_reason or "agent scoring incomplete"
|
| 706 |
+
|
| 707 |
+
if attempt < max_attempts:
|
| 708 |
+
vj.log.info(
|
| 709 |
+
"[agent-judge] task=%s attempt=%d/%d invalid (%s) — retrying",
|
| 710 |
+
tname, attempt, max_attempts, last_reason,
|
| 711 |
+
)
|
| 712 |
+
continue
|
| 713 |
+
# Attempts exhausted, still non-conforming: flag the error so finalize records it and
|
| 714 |
+
# load_agent_verdicts' guard falls back to VLM (the last resort).
|
| 715 |
+
agent_error = f"agent output invalid after {max_attempts} attempts: {last_reason}"
|
| 716 |
+
|
| 717 |
+
# Enforce a self-render ONLY when this judge owns visual rubrics (render_required). Under
|
| 718 |
+
# evidence routing it scores structural / scene_summary rubrics from bpy, so an empty
|
| 719 |
+
# agent_renders/ is expected and must NOT be treated as an error.
|
| 720 |
+
renders_dir = task_dir / output_rel / "agent_renders"
|
| 721 |
+
agent_render_count = len(list(renders_dir.glob("*.png"))) if renders_dir.exists() else 0
|
| 722 |
+
if render_required and agent_render_count == 0 and not agent_error:
|
| 723 |
+
agent_error = "agent produced no self-rendered images (agent_renders/ empty) — visual rubrics unverified"
|
| 724 |
+
|
| 725 |
+
extra_meta = {
|
| 726 |
+
"agent_returncode": returncode,
|
| 727 |
+
"agent_stdout_path": stdout_rel,
|
| 728 |
+
"agent_raw_path": f"{output_rel_str}/{RAW_NAME}",
|
| 729 |
+
"bpy_dump_path": f"{output_rel_str}/{BPY_DUMP_NAME}",
|
| 730 |
+
"agent_renders_path": f"{output_rel_str}/agent_renders",
|
| 731 |
+
"agent_render_count": agent_render_count,
|
| 732 |
+
"agent_attempts": attempts_used,
|
| 733 |
+
}
|
| 734 |
+
if agent_error:
|
| 735 |
+
extra_meta["agent_error"] = agent_error
|
| 736 |
+
|
| 737 |
+
obj = finalize_judgement(
|
| 738 |
+
task_dir, rubrics, raw_obj, cfg,
|
| 739 |
+
render_images=render_images, extra_images=extra_images, reference_images=reference_images,
|
| 740 |
+
extra_meta=extra_meta,
|
| 741 |
+
)
|
| 742 |
+
obj["output_path"] = str(out_path)
|
| 743 |
+
vj.atomic_write_json(out_path, obj)
|
| 744 |
+
vj.log.info(
|
| 745 |
+
"[agent-judge] task=%s ok=%s fused=%.1f rubric=%.1f dim=%s self_renders=%d attempts=%d rc=%s",
|
| 746 |
+
tname, obj.get("ok"), obj.get("fused_score_0_100") or 0.0,
|
| 747 |
+
obj.get("weighted_score_0_100") or 0.0, obj.get("dimension_score_0_100"),
|
| 748 |
+
agent_render_count, attempts_used, returncode,
|
| 749 |
+
)
|
| 750 |
+
return obj
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
def parse_args() -> argparse.Namespace:
|
| 754 |
+
p = argparse.ArgumentParser(description="Agent-as-Judge for Blender trajectory eval")
|
| 755 |
+
p.add_argument("--rubrics-batch", required=True)
|
| 756 |
+
p.add_argument("--output-dir", default=DEFAULT_OUTPUT_DIR)
|
| 757 |
+
p.add_argument("--batch-output", default="")
|
| 758 |
+
p.add_argument("--image-glob", default=DEFAULT_IMAGE_GLOB)
|
| 759 |
+
p.add_argument("--extra-image-glob", action="append", default=[])
|
| 760 |
+
p.add_argument("--reference-image-glob", default="**/image_assets/*")
|
| 761 |
+
p.add_argument("--no-reference-images", action="store_true")
|
| 762 |
+
p.add_argument("--max-images", type=int, default=8)
|
| 763 |
+
p.add_argument("--max-extra-images", type=int, default=4)
|
| 764 |
+
p.add_argument("--max-reference-images", type=int, default=4)
|
| 765 |
+
p.add_argument("--model", default=os.environ.get("AGENT_JUDGE_MODEL") or os.environ.get("MODEL", ""))
|
| 766 |
+
p.add_argument("--max-turns", type=int, default=int(os.environ.get("AGENT_JUDGE_MAX_TURNS", "500")))
|
| 767 |
+
p.add_argument(
|
| 768 |
+
"--max-attempts", type=int,
|
| 769 |
+
default=int(os.environ.get("AGENT_JUDGE_MAX_ATTEMPTS", "3")),
|
| 770 |
+
help="Max agent-judge attempts per task. When the agent produces non-conforming JSON "
|
| 771 |
+
"(missing file / unparseable / missing rubric ids), it is re-prompted to re-score "
|
| 772 |
+
"up to this many times before the VLM fallback is used as a last resort.",
|
| 773 |
+
)
|
| 774 |
+
p.add_argument("--timeout", type=int, default=int(os.environ.get("AGENT_JUDGE_TIMEOUT", "14400")))
|
| 775 |
+
p.add_argument("--task-concurrency", type=int, default=int(os.environ.get("AGENT_JUDGE_TASK_CONCURRENCY", "2")))
|
| 776 |
+
p.add_argument("--dimension-weight", type=float, default=0.5)
|
| 777 |
+
p.add_argument("--no-dimension-pass", action="store_true")
|
| 778 |
+
p.add_argument("--dimension-conflict-cap", type=int, default=4,
|
| 779 |
+
help="Clamp any dimension the agent flags with render_conflict=true to <= this "
|
| 780 |
+
"1-10 value (worst-of-both; the visible render governs). Default 4.")
|
| 781 |
+
p.add_argument("--no-dimension-conflict-cap", action="store_true",
|
| 782 |
+
help="Disable the render_conflict dimension clamp.")
|
| 783 |
+
p.add_argument("--no-rubric-cross-check", action="store_true",
|
| 784 |
+
help="Disable conjunctive rubric scoring; fall back to the model's self-reported "
|
| 785 |
+
"0/1 score (ignore bpy_check/visual_check).")
|
| 786 |
+
p.add_argument("--blender-bin", default=os.environ.get("BLENDER_BIN", "blender"))
|
| 787 |
+
p.add_argument("--no-bpy", action="store_true")
|
| 788 |
+
p.add_argument("--anthropic-base-url", default=os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com"))
|
| 789 |
+
p.add_argument("--anthropic-api-key", default=os.environ.get("ANTHROPIC_API_KEY", ""))
|
| 790 |
+
p.add_argument("--limit", type=int, default=0)
|
| 791 |
+
p.add_argument("--overwrite", action="store_true")
|
| 792 |
+
p.add_argument("--dry-run", action="store_true")
|
| 793 |
+
p.add_argument(
|
| 794 |
+
"--agent-evidence-types",
|
| 795 |
+
default="",
|
| 796 |
+
help=(
|
| 797 |
+
"Comma list of evidence_type values this agent judge should score. Empty (default) "
|
| 798 |
+
"means score every rubric (legacy behavior). Under evidence_type routing set this to "
|
| 799 |
+
"'scene_summary' so the agent only judges those rubrics and the VLM handles the rest."
|
| 800 |
+
),
|
| 801 |
+
)
|
| 802 |
+
return p.parse_args()
|
| 803 |
+
|
| 804 |
+
|
| 805 |
+
def main() -> int:
|
| 806 |
+
args = parse_args()
|
| 807 |
+
rubrics_batch = Path(args.rubrics_batch)
|
| 808 |
+
results = vj.load_rubric_results(rubrics_batch)
|
| 809 |
+
if args.limit > 0:
|
| 810 |
+
results = results[: args.limit]
|
| 811 |
+
|
| 812 |
+
extra_globs = args.extra_image_glob or list(vj.DEFAULT_EXTRA_IMAGE_GLOBS)
|
| 813 |
+
cfg = {
|
| 814 |
+
"output_dir": args.output_dir,
|
| 815 |
+
"image_glob": args.image_glob,
|
| 816 |
+
"extra_image_globs": extra_globs,
|
| 817 |
+
"reference_image_glob": args.reference_image_glob,
|
| 818 |
+
"no_reference_images": args.no_reference_images,
|
| 819 |
+
"max_images": args.max_images,
|
| 820 |
+
"max_extra_images": args.max_extra_images,
|
| 821 |
+
"max_reference_images": args.max_reference_images,
|
| 822 |
+
"model": args.model,
|
| 823 |
+
"max_turns": args.max_turns,
|
| 824 |
+
"max_attempts": args.max_attempts,
|
| 825 |
+
"timeout": args.timeout,
|
| 826 |
+
"dimension_weight": args.dimension_weight,
|
| 827 |
+
"dimension_pass": not args.no_dimension_pass,
|
| 828 |
+
"dimension_conflict_cap": None if args.no_dimension_conflict_cap else args.dimension_conflict_cap,
|
| 829 |
+
"cross_check": not args.no_rubric_cross_check,
|
| 830 |
+
"blender_bin": args.blender_bin,
|
| 831 |
+
"use_bpy": not args.no_bpy,
|
| 832 |
+
"anthropic_base_url": args.anthropic_base_url,
|
| 833 |
+
"anthropic_api_key": args.anthropic_api_key,
|
| 834 |
+
"overwrite": args.overwrite,
|
| 835 |
+
"dry_run": args.dry_run,
|
| 836 |
+
"agent_evidence_types": vj.parse_type_set(args.agent_evidence_types),
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
outputs: list[dict[str, Any]] = []
|
| 840 |
+
workers = max(1, int(args.task_concurrency))
|
| 841 |
+
if workers == 1:
|
| 842 |
+
for result in results:
|
| 843 |
+
out = run_one_task(result, cfg)
|
| 844 |
+
if out is not None:
|
| 845 |
+
outputs.append(out)
|
| 846 |
+
else:
|
| 847 |
+
with ThreadPoolExecutor(max_workers=workers) as pool:
|
| 848 |
+
futures = {pool.submit(run_one_task, result, cfg): result for result in results}
|
| 849 |
+
for fut in as_completed(futures):
|
| 850 |
+
try:
|
| 851 |
+
out = fut.result()
|
| 852 |
+
except Exception as exc: # noqa: BLE001
|
| 853 |
+
r = futures[fut]
|
| 854 |
+
out = {"task_dir": str(r.get("task_dir")), "ok": False,
|
| 855 |
+
"error": repr(exc), "rubric_scores": []}
|
| 856 |
+
if out is not None:
|
| 857 |
+
outputs.append(out)
|
| 858 |
+
|
| 859 |
+
outputs.sort(key=lambda o: str(o.get("task_dir")))
|
| 860 |
+
batch_output = Path(args.batch_output) if args.batch_output else rubrics_batch.parent / "judge_agent_batch.json"
|
| 861 |
+
ok_count = sum(1 for item in outputs if item.get("ok"))
|
| 862 |
+
batch = {
|
| 863 |
+
"created_at": datetime.now(timezone.utc).isoformat(),
|
| 864 |
+
"rubrics_batch": str(rubrics_batch),
|
| 865 |
+
"model": args.model,
|
| 866 |
+
"judge_kind": "agent",
|
| 867 |
+
"task_count": len(outputs),
|
| 868 |
+
"ok_count": ok_count,
|
| 869 |
+
"score_summary": vj.build_batch_score_summary(outputs),
|
| 870 |
+
"results": outputs,
|
| 871 |
+
}
|
| 872 |
+
vj.atomic_write_json(batch_output, batch)
|
| 873 |
+
vj.log.info("[agent-judge] wrote batch %s ok=%d/%d", batch_output, ok_count, len(outputs))
|
| 874 |
+
return 0 if ok_count == len(outputs) else 2
|
| 875 |
+
|
| 876 |
+
|
| 877 |
+
if __name__ == "__main__":
|
| 878 |
+
sys.exit(main())
|
bw_0221/tests/blenderworld/evaluators/judge_blender_binary_rubrics.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
bw_0221/tests/blenderworld/harbor_export.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Export the frozen dataset as self-contained Harbor task packages."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import importlib.metadata
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
from .data import RESOURCE_FIELDS, load_tasks, prepare, resolve, sha256, verify, write_json
|
| 11 |
+
from .evaluation import PROTOCOL
|
| 12 |
+
from . import __version__
|
| 13 |
+
from .runtime import RUNTIME_VERSIONS, requirements
|
| 14 |
+
from .submissions import FORMAT, PROJECT
|
| 15 |
+
|
| 16 |
+
HARBOR_VERSION = "0.23.0"
|
| 17 |
+
ASSETS = Path(__file__).with_name("harbor_assets")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _harbor():
|
| 21 |
+
try:
|
| 22 |
+
from harbor.models.dataset.manifest import DatasetManifest
|
| 23 |
+
from harbor.models.task.task import Task
|
| 24 |
+
from harbor.publisher.packager import Packager
|
| 25 |
+
except ImportError as error:
|
| 26 |
+
raise RuntimeError("Harbor export requires Python 3.12+ and pip install 'blenderworld[harbor]'") from error
|
| 27 |
+
if importlib.metadata.version("harbor") != HARBOR_VERSION:
|
| 28 |
+
raise RuntimeError(f"This exporter is validated with harbor=={HARBOR_VERSION}; install the pinned harbor extra")
|
| 29 |
+
return DatasetManifest, Task, Packager
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def _instruction(row):
|
| 33 |
+
resources = []
|
| 34 |
+
for field in ("reference_images", "reference_videos", "attachments"):
|
| 35 |
+
for entry in row[field]:
|
| 36 |
+
resources.append(f"- `{field}`: `/workspace/inputs/{entry['task_relative_path']}`")
|
| 37 |
+
return (f"# BlenderWorld {row['task_id']}\n\n"
|
| 38 |
+
"## Task\n\n" + row["query"] + "\n\n"
|
| 39 |
+
"## Inputs\n\nThe original request is also in `/workspace/inputs/query.txt`.\n\n"
|
| 40 |
+
+ ("\n".join(resources) if resources else "This task has no reference media or declared attachments.")
|
| 41 |
+
+ "\n\nRead the supplied specifications and inspect the reference media before modeling. "
|
| 42 |
+
"Relative filenames in the request refer to the files listed above.\n\n"
|
| 43 |
+
"## Deliverables\n\nSave the editable project as `/workspace/exports/final.blend`. "
|
| 44 |
+
"Put all requested images, videos, model exports, and texture dependencies under "
|
| 45 |
+
"`/workspace/exports/`. Pack textures into the project or keep relative paths inside "
|
| 46 |
+
"this directory so the project can be opened in a fresh environment.\n\n"
|
| 47 |
+
"## Tools\n\nBlender is installed as `blender`. A Blender MCP server is configured "
|
| 48 |
+
"for agents that support task MCP servers; use its advertised tools to inspect the "
|
| 49 |
+
"scene, execute Blender Python, and capture viewport images. The Blender Python CLI "
|
| 50 |
+
"is also available. Use Blender 4.2.10, Node.js 22.17.0, Codex CLI 0.147.0 "
|
| 51 |
+
"or Claude Code 2.1.220; do not upgrade these tools. "
|
| 52 |
+
"Inspect your result and save your work before finishing.\n")
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _config(row, namespace, cpus, memory_mb, gpus, agent_timeout, verifier_timeout):
|
| 56 |
+
quote = json.dumps
|
| 57 |
+
gpu_line = f"gpus = {gpus}\n" if gpus else ""
|
| 58 |
+
return f'''schema_version = "1.3"
|
| 59 |
+
artifacts = ["/workspace/exports"]
|
| 60 |
+
|
| 61 |
+
[task]
|
| 62 |
+
name = {quote(namespace + '/BlenderWorld-' + row['task_id'])}
|
| 63 |
+
description = "BlenderWorld {row['task_id']} ({row['modality']})"
|
| 64 |
+
keywords = ["blender", "3d", "{row['modality']}"]
|
| 65 |
+
|
| 66 |
+
[metadata]
|
| 67 |
+
task_id = "{row['task_id']}"
|
| 68 |
+
modality = "{row['modality']}"
|
| 69 |
+
rubric_count = {row['rubric_count']}
|
| 70 |
+
protocol_version = {PROTOCOL['version']}
|
| 71 |
+
code_version = "{__version__}"
|
| 72 |
+
blender_version = "{RUNTIME_VERSIONS['blender']}"
|
| 73 |
+
node_version = "{RUNTIME_VERSIONS['node']}"
|
| 74 |
+
codex_version = "{RUNTIME_VERSIONS['codex']}"
|
| 75 |
+
claude_code_version = "{RUNTIME_VERSIONS['claude_code']}"
|
| 76 |
+
submission_format = "{FORMAT}"
|
| 77 |
+
submission_project = "{PROJECT}"
|
| 78 |
+
|
| 79 |
+
[agent]
|
| 80 |
+
timeout_sec = {agent_timeout}
|
| 81 |
+
|
| 82 |
+
[environment]
|
| 83 |
+
build_timeout_sec = 3600
|
| 84 |
+
cpus = {cpus}
|
| 85 |
+
memory_mb = {memory_mb}
|
| 86 |
+
storage_mb = 102400
|
| 87 |
+
{gpu_line}workdir = "/workspace"
|
| 88 |
+
|
| 89 |
+
[[environment.mcp_servers]]
|
| 90 |
+
name = "blender"
|
| 91 |
+
transport = "stdio"
|
| 92 |
+
command = "/usr/local/bin/bw-blender-mcp"
|
| 93 |
+
args = []
|
| 94 |
+
|
| 95 |
+
[verifier]
|
| 96 |
+
timeout_sec = {verifier_timeout}
|
| 97 |
+
environment_mode = "separate"
|
| 98 |
+
|
| 99 |
+
[verifier.environment]
|
| 100 |
+
build_timeout_sec = 3600
|
| 101 |
+
cpus = {cpus}
|
| 102 |
+
memory_mb = {memory_mb}
|
| 103 |
+
storage_mb = 102400
|
| 104 |
+
{gpu_line}workdir = "/workspace"
|
| 105 |
+
|
| 106 |
+
[verifier.env]
|
| 107 |
+
ANTHROPIC_BASE_URL = "${{BW_AGENT_JUDGE_ENDPOINT}}"
|
| 108 |
+
ANTHROPIC_API_KEY = "${{BW_AGENT_JUDGE_API_KEY}}"
|
| 109 |
+
JUDGE_API_ENDPOINT = "${{BW_VISION_JUDGE_ENDPOINT}}"
|
| 110 |
+
JUDGE_API_KEY = "${{BW_VISION_JUDGE_API_KEY}}"
|
| 111 |
+
RENDER_AGENT_MODEL = "${{BW_RENDER_MODEL:-gpt-5.6-terra}}"
|
| 112 |
+
AGENT_JUDGE_MODEL = "${{BW_AGENT_JUDGE_MODEL:-gpt-5.6-terra}}"
|
| 113 |
+
JUDGE_MODEL = "${{BW_VISION_JUDGE_MODEL:-gpt-5.6-terra}}"
|
| 114 |
+
'''
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def _copy_dataset_task(dataset, row, destination):
|
| 118 |
+
task_root = destination / "tasks" / row["task_id"]
|
| 119 |
+
task_root.mkdir(parents=True)
|
| 120 |
+
write_json(task_root / "task.json", row)
|
| 121 |
+
for key in ("query_file", "rubric_file"):
|
| 122 |
+
target = resolve(destination, row[key])
|
| 123 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 124 |
+
shutil.copyfile(resolve(dataset, row[key]), target)
|
| 125 |
+
for field in RESOURCE_FIELDS:
|
| 126 |
+
for entry in row[field]:
|
| 127 |
+
target = resolve(destination, entry["path"])
|
| 128 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 129 |
+
shutil.copyfile(resolve(dataset, entry["path"]), target)
|
| 130 |
+
(destination / "dataset.jsonl").write_text(json.dumps(row, ensure_ascii=False) + "\n")
|
| 131 |
+
rubric = json.loads(resolve(dataset, row["rubric_file"]).read_text())
|
| 132 |
+
write_json(destination / "rubrics.json", {"results": [rubric]})
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def export_harbor(dataset, output, namespace="Qwen", task_ids=None, cpus=8,
|
| 136 |
+
memory_mb=16384, gpus=0, agent_timeout=14400, verifier_timeout=28800):
|
| 137 |
+
"""Create a new export; the source dataset and existing task packages are never edited."""
|
| 138 |
+
Manifest, Task, Packager = _harbor()
|
| 139 |
+
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]*", namespace) or ".." in namespace:
|
| 140 |
+
raise ValueError("Invalid Harbor organization namespace")
|
| 141 |
+
if min(cpus, memory_mb, agent_timeout, verifier_timeout) <= 0 or gpus < 0:
|
| 142 |
+
raise ValueError("Resources and timeouts must be positive; GPU count may be zero")
|
| 143 |
+
dataset, output = Path(dataset).resolve(), Path(output).resolve()
|
| 144 |
+
if output == dataset or output.is_relative_to(dataset):
|
| 145 |
+
raise ValueError("Export directory must be outside the frozen dataset")
|
| 146 |
+
verify(dataset)
|
| 147 |
+
rows = load_tasks(dataset)
|
| 148 |
+
if task_ids:
|
| 149 |
+
selected = set(task_ids)
|
| 150 |
+
rows = [r for r in rows if r["task_id"] in selected]
|
| 151 |
+
if {r["task_id"] for r in rows} != selected:
|
| 152 |
+
raise ValueError("Unknown task ID in selection")
|
| 153 |
+
output.mkdir(parents=True, exist_ok=False)
|
| 154 |
+
manifest_tasks, audit_tasks = [], []
|
| 155 |
+
code_root = Path(__file__).parent
|
| 156 |
+
# Only Python runtime files go into the verifier, never into the agent image.
|
| 157 |
+
code_files = sorted(code_root.rglob("*.py"))
|
| 158 |
+
for row in rows:
|
| 159 |
+
task = output / row["task_id"]
|
| 160 |
+
env, tests = task / "environment", task / "tests"
|
| 161 |
+
env.mkdir(parents=True)
|
| 162 |
+
tests.mkdir()
|
| 163 |
+
(task / "instruction.md").write_text(_instruction(row))
|
| 164 |
+
(task / "task.toml").write_text(_config(row, namespace, cpus, memory_mb, gpus,
|
| 165 |
+
agent_timeout, verifier_timeout))
|
| 166 |
+
prepare(dataset, row["task_id"], env / "inputs")
|
| 167 |
+
for name in ("Dockerfile.agent", "mcp_bridge.py", "blender_startup.py", "install_blender.sh", "requirements-tools.txt", "LICENSE"):
|
| 168 |
+
shutil.copyfile(ASSETS / name, env / ("Dockerfile" if name == "Dockerfile.agent" else name))
|
| 169 |
+
for name in ("Dockerfile.verifier", "test.sh", "install_blender.sh", "requirements-verifier.txt", "LICENSE"):
|
| 170 |
+
shutil.copyfile(ASSETS / name, tests / ("Dockerfile" if name == "Dockerfile.verifier" else name))
|
| 171 |
+
(tests / "test.sh").chmod(0o755)
|
| 172 |
+
for path in code_files:
|
| 173 |
+
relative = path.relative_to(code_root)
|
| 174 |
+
if "harbor_assets" in relative.parts:
|
| 175 |
+
continue
|
| 176 |
+
target = tests / "blenderworld" / relative
|
| 177 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 178 |
+
shutil.copyfile(path, target)
|
| 179 |
+
_copy_dataset_task(dataset, row, tests / "dataset")
|
| 180 |
+
Task(task) # Validate with the same schema used by the installed Harbor release.
|
| 181 |
+
digest, files = Packager.compute_content_hash(task)
|
| 182 |
+
manifest_tasks.append({"name": f"{namespace}/BlenderWorld-{row['task_id']}",
|
| 183 |
+
"digest": "sha256:" + digest})
|
| 184 |
+
audit_tasks.append({"task_id": row["task_id"], "modality": row["modality"],
|
| 185 |
+
"digest": "sha256:" + digest, "files": len(files),
|
| 186 |
+
"query_sha256": sha256(env / "inputs/query.txt"),
|
| 187 |
+
"rubric_sha256": sha256(resolve(tests / "dataset", row["rubric_file"]))})
|
| 188 |
+
manifest = Manifest.model_validate({"dataset": {"name": f"{namespace}/BlenderWorld",
|
| 189 |
+
"version": "1.2.0", "description": "BlenderWorld: 3D creation in Blender",
|
| 190 |
+
"keywords": ["blender", "3d", "multimodal", "agent"]},
|
| 191 |
+
"tasks": manifest_tasks})
|
| 192 |
+
(output / "dataset.toml").write_text(manifest.to_toml())
|
| 193 |
+
for name in ("README.md", "verifier.env.example", "LICENSE"):
|
| 194 |
+
shutil.copyfile(ASSETS / name, output / name)
|
| 195 |
+
report = {"format": "blenderworld-harbor-v1", "harbor_version": HARBOR_VERSION,
|
| 196 |
+
"code_version": __version__, "runtime_requirements": requirements(),
|
| 197 |
+
"submission_format": FORMAT,
|
| 198 |
+
"dataset_name": manifest.dataset.name, "task_count": len(rows),
|
| 199 |
+
"dataset_digest": "sha256:" + manifest.compute_content_hash(),
|
| 200 |
+
"source_dataset_sha256": sha256(dataset / "dataset.jsonl"),
|
| 201 |
+
"protocol": PROTOCOL, "tasks": audit_tasks}
|
| 202 |
+
write_json(output / "export_manifest.json", report)
|
| 203 |
+
files = sorted(p for p in output.rglob("*") if p.is_file())
|
| 204 |
+
(output / "SHA256SUMS").write_text("".join(f"{sha256(p)} {p.relative_to(output).as_posix()}\n" for p in files))
|
| 205 |
+
return {k: v for k, v in report.items() if k != "tasks"}
|
bw_0221/tests/blenderworld/harbor_verify.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Harbor verifier entry point, backed by the standalone BlenderWorld evaluator."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import argparse
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
import shutil
|
| 8 |
+
import subprocess
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from types import SimpleNamespace
|
| 11 |
+
|
| 12 |
+
from .data import load_tasks, sha256, write_json
|
| 13 |
+
from .evaluation import PROTOCOL, evaluate, tree_hashes
|
| 14 |
+
from .submissions import pack_submission
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def run_verifier(dataset, submission, output):
|
| 18 |
+
dataset, submission, output = map(lambda p: Path(p).resolve(), (dataset, submission, output))
|
| 19 |
+
if output == submission or output.is_relative_to(submission):
|
| 20 |
+
raise ValueError("Verifier output must be outside the submission")
|
| 21 |
+
output.mkdir(parents=True, exist_ok=True)
|
| 22 |
+
reward = {"reward": 0.0, "rubric_score": 0.0, "dimension_score": 0.0}
|
| 23 |
+
# A timeout/crash can never leave a previous successful reward behind.
|
| 24 |
+
write_json(output / "reward.json", reward)
|
| 25 |
+
result = {"ok": False, "status": "running", "score": 0.0, "protocol": PROTOCOL}
|
| 26 |
+
write_json(output / "metrics.json", result)
|
| 27 |
+
try:
|
| 28 |
+
rows = load_tasks(dataset)
|
| 29 |
+
if len(rows) != 1:
|
| 30 |
+
raise ValueError("A Harbor verifier package must contain exactly one task")
|
| 31 |
+
task_id = rows[0]["task_id"]
|
| 32 |
+
result["task_id"] = task_id
|
| 33 |
+
if submission.is_symlink() or any(p.is_symlink() for p in submission.rglob("*")):
|
| 34 |
+
raise ValueError("Submission contains symbolic links")
|
| 35 |
+
before = sha256(submission) if submission.is_file() else tree_hashes(submission)
|
| 36 |
+
staging = output / "submissions"
|
| 37 |
+
staging.mkdir(exist_ok=False)
|
| 38 |
+
if submission.is_dir():
|
| 39 |
+
pack_submission(submission, task_id, staging / (task_id + ".zip"))
|
| 40 |
+
elif submission.is_file():
|
| 41 |
+
shutil.copyfile(submission, staging / (task_id + ".zip"))
|
| 42 |
+
options = SimpleNamespace(
|
| 43 |
+
dataset=str(dataset), submissions=str(staging), output=str(output / "run"),
|
| 44 |
+
task_id=[task_id], dry_run=False, resume=False,
|
| 45 |
+
blender_bin=os.environ.get("BLENDER_BIN", "blender"),
|
| 46 |
+
render_agent_model=os.environ.get("RENDER_AGENT_MODEL", "gpt-5.6-terra"),
|
| 47 |
+
agent_judge_model=os.environ.get("AGENT_JUDGE_MODEL", "gpt-5.6-terra"),
|
| 48 |
+
judge_model=os.environ.get("JUDGE_MODEL", "gpt-5.6-terra"),
|
| 49 |
+
judge_api_endpoint=os.environ.get("JUDGE_API_ENDPOINT", "https://api.openai.com/v1/chat/completions"))
|
| 50 |
+
evaluate(options)
|
| 51 |
+
outcome = json.loads((output / "run/tasks" / task_id / "result.json").read_text())
|
| 52 |
+
after = sha256(submission) if submission.is_file() else tree_hashes(submission)
|
| 53 |
+
if after != before:
|
| 54 |
+
raise ValueError("Original submission changed during verification")
|
| 55 |
+
result.update(outcome, status="scored" if outcome["ok"] else "failed")
|
| 56 |
+
if outcome["ok"]:
|
| 57 |
+
reward = {"reward": outcome["score"] / 100,
|
| 58 |
+
"rubric_score": outcome["rubric_score"] / 100,
|
| 59 |
+
"dimension_score": outcome["dimension_score"] / 100}
|
| 60 |
+
except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
|
| 61 |
+
result.update(ok=False, status="failed", score=0.0, error=str(error))
|
| 62 |
+
write_json(output / "metrics.json", result)
|
| 63 |
+
write_json(output / "reward.json", reward)
|
| 64 |
+
return result
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def main():
|
| 68 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 69 |
+
parser.add_argument("--dataset", default="/tests/dataset")
|
| 70 |
+
parser.add_argument("--submission", default="/workspace/exports",
|
| 71 |
+
help="Harbor exports directory (packaged before scoring), or one submission ZIP")
|
| 72 |
+
parser.add_argument("--output", default="/logs/verifier")
|
| 73 |
+
args = parser.parse_args()
|
| 74 |
+
result = run_verifier(args.dataset, args.submission, args.output)
|
| 75 |
+
print(json.dumps(result, ensure_ascii=False))
|
| 76 |
+
return 0 if result["ok"] else 1
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
if __name__ == "__main__":
|
| 80 |
+
raise SystemExit(main())
|