File size: 1,003 Bytes
30865cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Standalone runner for flow_free verification.

Invoked as a subprocess by VerificationService so that the FlowFree solver
(which compiles/runs a native binary, has no internal timeout, and can raise
SystemExit on a missing compiler/binary) cannot hang or crash the web worker.

Reads a JSON object {"problem_ascii": ..., "board_ascii": ...} on stdin and
writes the verification result dict as JSON to stdout.
"""
from __future__ import annotations

import json
import sys
from pathlib import Path

ROOT_DIR = Path(__file__).resolve().parents[1]
EVALS_SRC_DIR = ROOT_DIR / "evals" / "src"
if str(EVALS_SRC_DIR) not in sys.path:
    sys.path.insert(0, str(EVALS_SRC_DIR))


def main() -> None:
    payload = json.loads(sys.stdin.read())
    from evals_verifier import verify_flow_free  # type: ignore

    result = verify_flow_free(
        payload.get("problem_ascii", ""),
        payload.get("board_ascii", ""),
    )
    sys.stdout.write(json.dumps(result))


if __name__ == "__main__":
    main()