File size: 2,081 Bytes
510314e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
"""Regole d'arresto del pilota C2 (BRIEF-PILOT-C2-GPU, Blocco GPU punto 4), dopo ogni lavoro.
Uso: check_c2.py RESULT_JSON STATE_JSON  -> exit 0 continua, exit 9 STOP (causa su stdout).
  - violazione di finestra o di margine vista dal contatore (margin_violations > 0)       -> STOP
  - rifiuto del motore: http_errors > 0 nel contatore o status ContextOverflow             -> STOP
  - rifiuto del banco (WindowRefused) per A/T/B: a 32k/64k non deve succedere              -> STOP
  - errori di sistema (status non ok, esclusi ProxyWindowRefused registrati) 2 di fila    -> STOP
  - D: risposte vuote o troncate in serie (>= 3 corse D consecutive)                       -> STOP
ProxyWindowRefused (400 della guardia del proxy senza invio) e' un esito del proxy: registrato, non ferma.
"""
import json
import sys
from pathlib import Path

r = json.load(open(sys.argv[1]))
sp = Path(sys.argv[2])
st = json.loads(sp.read_text()) if sp.exists() else {"nsys": 0, "d_bad": 0}
eng = r.get("engine") or {}
tag = "%s %s/%s %s" % (r["policy"], r["setting"], r["length"], r["qid"])
stop = None
if (eng.get("margin_violations") or 0) > 0:
    stop = "violazione del margine/finestra vista dal contatore (%s, min_slack %s)" % (tag, eng.get("min_window_slack"))
elif (eng.get("http_errors") or 0) > 0 or r["status"] == "ContextOverflow":
    stop = "rifiuto del motore (%s: status %s, http_errors %s)" % (tag, r["status"], eng.get("http_errors"))
elif r["status"] == "WindowRefused":
    stop = "rifiuto del banco WindowRefused (%s)" % tag
if r["status"] in ("ok", "ProxyWindowRefused"):
    st["nsys"] = 0
else:
    st["nsys"] += 1
    if stop is None and st["nsys"] >= 2:
        stop = "2 errori di sistema consecutivi (ultimo %s: %s)" % (tag, r["status"])
if r["policy"] == "D":
    bad = bool(r.get("answer_empty") or r.get("answer_truncated"))
    st["d_bad"] = st["d_bad"] + 1 if bad else 0
    if stop is None and st["d_bad"] >= 3:
        stop = "D: 3 risposte vuote/troncate di fila (ultima %s)" % tag
sp.write_text(json.dumps(st))
if stop:
    print("STOP: " + stop)
    sys.exit(9)