97 lines
3.2 KiB
Python
97 lines
3.2 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def run_worker_probe(exe: Path, solver_id: str, case_file: Path) -> dict:
|
|
command = [
|
|
str(exe),
|
|
"--cclite-worker",
|
|
"--solver-id",
|
|
solver_id,
|
|
"--case",
|
|
str(case_file),
|
|
"--ipc-name",
|
|
"CCLITE_REAL_WORKER_AUDIT",
|
|
"--timeout-ms",
|
|
"100",
|
|
]
|
|
try:
|
|
completed = subprocess.run(command, text=True, capture_output=True, timeout=5.0)
|
|
except subprocess.TimeoutExpired as exc:
|
|
return {
|
|
"command": command,
|
|
"exit_code": None,
|
|
"stdout": exc.stdout or "",
|
|
"stderr": exc.stderr or "",
|
|
"status": "TIMEOUT",
|
|
"recognized_worker_cli": False,
|
|
"ipc_implemented": False,
|
|
}
|
|
|
|
output = (completed.stdout or "") + "\n" + (completed.stderr or "")
|
|
recognized = "--solver-id" not in output and "unknown argument" not in output
|
|
unsupported = "not implemented" in output.lower() or "unsupported" in output.lower()
|
|
return {
|
|
"command": command,
|
|
"exit_code": completed.returncode,
|
|
"stdout": completed.stdout,
|
|
"stderr": completed.stderr,
|
|
"status": classify_probe(recognized, unsupported, completed.returncode),
|
|
"recognized_worker_cli": recognized,
|
|
"ipc_implemented": recognized and completed.returncode == 0 and not unsupported,
|
|
}
|
|
|
|
|
|
def classify_probe(recognized: bool, unsupported: bool, exit_code: int) -> str:
|
|
if recognized and unsupported:
|
|
return "CONTROLLED_UNSUPPORTED"
|
|
if recognized and exit_code == 0:
|
|
return "READY_FOR_HANDSHAKE"
|
|
if not recognized:
|
|
return "MISSING_WORKER_CLI"
|
|
return "FAILED"
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--sph-exe", required=True)
|
|
parser.add_argument("--fem-exe", required=True)
|
|
parser.add_argument("--case-dir", required=True)
|
|
parser.add_argument("--report", required=True)
|
|
args = parser.parse_args()
|
|
|
|
case_dir = Path(args.case_dir)
|
|
sph = run_worker_probe(Path(args.sph_exe), "SPH", case_dir / "mock_sph.inp")
|
|
fem = run_worker_probe(Path(args.fem_exe), "FEM", case_dir / "mock_fem.inp")
|
|
report = {
|
|
"status": "CONTROLLED_GAP",
|
|
"required_worker_args": [
|
|
"--cclite-worker",
|
|
"--solver-id <SPH|FEM>",
|
|
"--case <solver.inp>",
|
|
"--ipc-name <prefix>",
|
|
"--timeout-ms <milliseconds>",
|
|
],
|
|
"sphlite": sph,
|
|
"femlite": fem,
|
|
"conclusion": [
|
|
"SPHLite 0.8.2 recognizes worker mode but reports real IPC as not implemented.",
|
|
"FEMLite 0.6.3 does not yet recognize the worker CLI argument set.",
|
|
"CCLite 0.1.7 keeps mock-worker integration as the executable acceptance path.",
|
|
],
|
|
}
|
|
|
|
report_path = Path(args.report)
|
|
report_path.parent.mkdir(parents=True, exist_ok=True)
|
|
report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
print(f"real worker audit -> {report_path}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|