Download nodes/executor.py from tailot/lingologos-thinkingpython: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/executor.py
- Command line
-
hf download hf://datasets/tailot/lingologos-thinkingpython/nodes/executor.py
-
curl -L -o executor.py https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/executor.py
1.04 kB
| """Node: executor. Writes the edit pair in one transaction and runs the suite. | |
| The executor is the only node that writes. Everything it does is recorded so the two | |
| independent checkers can re-derive the result instead of trusting it. | |
| """ | |
| 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 session # noqa: E402 | |
| def main() -> int: | |
| task = json.load(sys.stdin) | |
| workspace = task["workspace"] | |
| plan = task["plan"] | |
| cwd = os.getcwd() | |
| os.chdir(workspace) | |
| try: | |
| receipt = session.apply_pair(workspace, plan) | |
| suite = session.run_suite(workspace) | |
| finally: | |
| os.chdir(cwd) | |
| status = "ok" if receipt.get("applied") else "refused" | |
| print(json.dumps({"node": "executor", "status": status, "receipt": receipt, | |
| "suite": suite["status"], "output": suite["output"]})) | |
| return 0 if status == "ok" else 1 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |