Download nodes/planner.py from tailot/lingologos-thinkingpython: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/planner.py
- Command line
-
hf download hf://datasets/tailot/lingologos-thinkingpython/nodes/planner.py
-
curl -L -o planner.py https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/planner.py
1.22 kB
| """Node: planner. Turns the located candidate into a language free plan. | |
| The plan carries a frame, a file, a line window and the text of the edit pair. It carries | |
| no word of the request: tests/test_language_free_plan.py checks exactly that. | |
| """ | |
| import json | |
| import os | |
| import sys | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| sys.path.insert(0, ROOT) | |
| from lingologos_thinkingpython import catalog, session # noqa: E402 | |
| def main() -> int: | |
| task = json.load(sys.stdin) | |
| workspace = task["workspace"] | |
| candidate = task["candidates"][0] | |
| entries = catalog.load_entries() | |
| entry = catalog.by_id(entries, candidate["entry"]) or {} | |
| shaped = {"file": candidate["file"], "target": candidate["target"], "entry": entry, | |
| "evidence": candidate["evidence"]} | |
| cwd = os.getcwd() | |
| try: | |
| os.chdir(workspace) | |
| planned = session.plan(shaped) | |
| finally: | |
| os.chdir(cwd) | |
| if not planned.get("edits"): | |
| print(json.dumps({"node": "planner", "status": "refused", "reason": "NO_EDIT"})) | |
| return 1 | |
| print(json.dumps({"node": "planner", "status": "ok", "plan": planned})) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |