Download nodes/locator.py from tailot/lingologos-thinkingpython: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/locator.py
- Command line
-
hf download hf://datasets/tailot/lingologos-thinkingpython/nodes/locator.py
-
curl -L -o locator.py https://huggingface.co/datasets/tailot/lingologos-thinkingpython/resolve/main/nodes/locator.py
1.38 kB
| """Node: locator. Finds the candidate in the workspace for a frame. | |
| Deterministic. It runs the preflight admission first, so a workspace outside the mission | |
| never reaches the planner. | |
| """ | |
| 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, preflight, session # noqa: E402 | |
| def main() -> int: | |
| task = json.load(sys.stdin) | |
| workspace = task["workspace"] | |
| ir = task["ir"] | |
| entries = catalog.load_entries() | |
| admit = preflight.admit(workspace) | |
| if not admit["admitted"]: | |
| print(json.dumps({"node": "locator", "status": "refused", | |
| "reasons": admit["reasons"]})) | |
| return 1 | |
| candidates, reasons = session.locate(workspace, ir["frame"], ir.get("anchor"), entries) | |
| if not candidates: | |
| print(json.dumps({"node": "locator", "status": "refused", "reasons": reasons})) | |
| return 1 | |
| print(json.dumps({"node": "locator", "status": "ok", | |
| "candidates": [{"file": c["file"], "target": c["target"], | |
| "entry": c["entry"].get("id", ""), | |
| "evidence": c["evidence"]} for c in candidates], | |
| "reasons": reasons})) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |