Datasets:
Download tests/test_blocksworld.py from Nabidnur/RoboRACE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/tests/test_blocksworld.py
- Command line
-
hf download hf://datasets/Nabidnur/RoboRACE-Bench/tests/test_blocksworld.py
-
curl -L -o test_blocksworld.py https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/tests/test_blocksworld.py
1.96 kB
| import json | |
| from pathlib import Path | |
| import pytest | |
| from robotics.benchmarks import blocksworld as bw | |
| DATA = Path("data/planbench/task_1_plan_generation.json") | |
| def test_all_500_ground_truth_plans_validate(): | |
| """Validator correctness gate: every official PlanBench ground-truth plan must be valid and | |
| reach the goal (stands in for VAL on this domain).""" | |
| ins = bw.load(DATA) | |
| assert len(ins) == 500 | |
| bad = [i["instance_id"] for i in ins if not bw.validate(i["query"], i["ground_truth_plan"])["reached"]] | |
| assert bad == [] | |
| def test_corrupted_plans_are_rejected(): | |
| ins = bw.load(DATA)[:100] | |
| rejected = 0 | |
| for i in ins: | |
| lines = [x for x in i["ground_truth_plan"].strip().splitlines() if x] | |
| if len(lines) < 2: | |
| continue | |
| swapped = "\n".join([lines[1], lines[0]] + lines[2:]) # swap first two actions | |
| truncated = "\n".join(lines[:-1]) # drop the last action | |
| rejected += (not bw.validate(i["query"], swapped)["reached"]) + (not bw.validate(i["query"], truncated)["reached"]) | |
| assert rejected >= 190 | |
| def test_natural_language_plan_and_feedback(): | |
| q = ("[STATEMENT]\nAs initial conditions I have that, the red block is clear, the hand is empty, " | |
| "the red block is on top of the blue block and the blue block is on the table.\n" | |
| "My goal is to have that the blue block is on top of the red block.\n\nMy plan is as follows:\n\n[PLAN]") | |
| good = "unstack the red block from on top of the blue block\nput down the red block\n" \ | |
| "pick up the blue block\nstack the blue block on top of the red block\n[PLAN END]" | |
| assert bw.validate(q, good)["reached"] | |
| v = bw.validate(q, "pick up the blue block") | |
| assert not v["valid"] and "not clear" in bw.feedback(v) | |