Datasets:
Download tests/test_planner_eng.py from Nabidnur/RoboRACE-Bench: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/tests/test_planner_eng.py
- Command line
-
hf download hf://datasets/Nabidnur/RoboRACE-Bench/tests/test_planner_eng.py
-
curl -L -o test_planner_eng.py https://huggingface.co/datasets/Nabidnur/RoboRACE-Bench/resolve/main/tests/test_planner_eng.py
2.49 kB
| from robotics.planner.canon import canon_str | |
| from robotics.planner.engineered import plan_engineered, validate | |
| from robotics.planner.procgen import make_cases | |
| from robotics.planner.task_planner import parse_plan | |
| SCENE = ["red cube", "green cube", "blue cube", "drawer"] | |
| def test_canon_equivalences(): | |
| a = parse_plan('{"steps":[{"skill":"pick","object":"red cube"},' | |
| '{"skill":"stack","object":"red cube","location":"on top of the green cube"},{"skill":"home"}]}') | |
| b = parse_plan('{"steps":[{"skill":"place","object":"red cube","location":"green cube"}]}') | |
| assert canon_str(a.steps) == canon_str(b.steps) == "put(red cube->green cube)" | |
| def test_validator_catches_grounding_and_drawer_errors(): | |
| p = parse_plan('{"steps":[{"skill":"place","object":"green cube","location":"table"},' | |
| '{"skill":"place","object":"red cube","location":"drawer"}]}') | |
| errs = validate(p, SCENE, "put the red cube in the drawer") | |
| assert any("table" in e for e in errs) | |
| assert any("never asks to move 'green cube'" in e for e in errs) | |
| assert any("opened" in e for e in errs) | |
| def test_repair_loop_uses_feedback(): | |
| replies = iter(['{"steps":[{"skill":"place","object":"red cube","location":"table"}]}', | |
| '{"steps":[{"skill":"open","object":"drawer"},' | |
| '{"skill":"place","object":"red cube","location":"drawer"}]}']) | |
| seen = [] | |
| def fake(msgs): | |
| seen.append(msgs[-1]["content"]) | |
| return next(replies), "fake" | |
| ans, calls, _ = plan_engineered(fake, SCENE, "put the red cube in the drawer") | |
| assert calls == 2 and ans == "open(drawer) | put(red cube->drawer)" | |
| assert "not a scene object" in seen[1] | |
| def test_procgen_golds_are_grounded(): | |
| for c in make_cases(48, seed=7): | |
| assert c["gold"] == "INFEASIBLE" or all(o in c["scene"] for o in | |
| [t.split("->")[0].split("(")[1].rstrip(")") for t in c["gold"].split(" | ")]) | |
| def test_validator_allows_quantified_instructions(): | |
| # regression: "every cube except X" moves cubes that the instruction never names | |
| p = parse_plan('{"steps":[{"skill":"place","object":"green cube","location":"red cube"},' | |
| '{"skill":"place","object":"blue cube","location":"red cube"}]}') | |
| assert validate(p, ["red cube", "green cube", "blue cube"], | |
| "put every cube except the red cube onto the red cube, starting with the green cube") == [] | |