padmapriyagosakan commited on
Commit
a662941
·
1 Parent(s): aaceff1

fix: SSL cert verification and J-05 pattern in run_tests.sh

Browse files

- K/M groups: add ssl.create_default_context() with CERT_NONE so Python 3.14
urllib can connect to https://...hf.space without SSL cert verification errors
- Q group: same SSL context fix for WebSocket upgrade check
- J-05: pattern was too restrictive (0\.[5-9] misses 1.0); the baseline agent
earns investigation bonuses that push its score to 1.0 after clamping.
Updated to (1\.0|0\.[5-9]) to accept any passing normalised score >= 0.5

Files changed (1) hide show
  1. run_tests.sh +17 -8
run_tests.sh CHANGED
@@ -346,7 +346,7 @@ check "J-01 POST /baseline → normalised_score present" "$BASELINE" '"normalis
346
  check "J-02 POST /baseline → total_reward present" "$BASELINE" '"total_reward":'
347
  check "J-03 POST /baseline → steps > 0" "$BASELINE" '"steps":[1-9]'
348
  check "J-04 POST /baseline → per_task scores present" "$BASELINE" '"scores":\['
349
- check "J-05 POST /baseline → score >= 0.5 (passes)" "$BASELINE" '"normalised_score":0\.[5-9]'
350
 
351
  # ═══════════════════════════════════════════════════════════
352
  # GROUP K — /analytics endpoint
@@ -356,15 +356,18 @@ section "GROUP K — Analytics endpoint"
356
  # Run a full episode first so analytics has data
357
  reset
358
  BASE=$BASE python3 - <<'PYEOF'
359
- import os, urllib.request, json, sys
360
  BASE = os.environ.get("BASE", "http://localhost:8000")
 
 
 
361
  def post(path, body=None):
362
  req = urllib.request.Request(f"{BASE}{path}",
363
  data=json.dumps(body).encode() if body else None,
364
  headers={"Content-Type": "application/json"}, method="POST")
365
- with urllib.request.urlopen(req) as r: return json.loads(r.read())
366
  def get(path):
367
- with urllib.request.urlopen(f"{BASE}{path}") as r: return json.loads(r.read())
368
 
369
  post("/reset")
370
  actions = [
@@ -409,13 +412,16 @@ section "GROUP M — Perfect episode (all 20 correct, no investigation cost)"
409
 
410
  reset
411
  BASE=$BASE python3 - <<'PYEOF'
412
- import os, urllib.request, json
413
  BASE = os.environ.get("BASE", "http://localhost:8000")
 
 
 
414
  def post(path, body=None):
415
  req = urllib.request.Request(f"{BASE}{path}",
416
  data=json.dumps(body).encode() if body else None,
417
  headers={"Content-Type": "application/json"}, method="POST")
418
- with urllib.request.urlopen(req) as r: return json.loads(r.read())
419
 
420
  post("/reset")
421
  actions = [
@@ -548,13 +554,16 @@ section "GROUP Q — WebSocket (requires wscat or python)"
548
 
549
  if command -v python3 &>/dev/null; then
550
  WS_RESULT=$(BASE=$BASE python3 - <<'PYEOF'
551
- import os, urllib.request, json
552
  try:
553
  BASE = os.environ.get("BASE", "http://localhost:8000")
 
 
 
554
  # ws upgrade check via HTTP (will get 426 Upgrade Required — proves endpoint exists)
555
  req = urllib.request.Request(f"{BASE}/ws")
556
  try:
557
- urllib.request.urlopen(req)
558
  except Exception as e:
559
  msg = str(e)
560
  if "426" in msg or "101" in msg or "Switching" in msg or "upgrade" in msg.lower():
 
346
  check "J-02 POST /baseline → total_reward present" "$BASELINE" '"total_reward":'
347
  check "J-03 POST /baseline → steps > 0" "$BASELINE" '"steps":[1-9]'
348
  check "J-04 POST /baseline → per_task scores present" "$BASELINE" '"scores":\['
349
+ check "J-05 POST /baseline → score >= 0.5 (passes)" "$BASELINE" '"normalised_score":(1\.0|0\.[5-9])'
350
 
351
  # ═══════════════════════════════════════════════════════════
352
  # GROUP K — /analytics endpoint
 
356
  # Run a full episode first so analytics has data
357
  reset
358
  BASE=$BASE python3 - <<'PYEOF'
359
+ import os, ssl, urllib.request, json, sys
360
  BASE = os.environ.get("BASE", "http://localhost:8000")
361
+ _ssl = ssl.create_default_context()
362
+ _ssl.check_hostname = False
363
+ _ssl.verify_mode = ssl.CERT_NONE
364
  def post(path, body=None):
365
  req = urllib.request.Request(f"{BASE}{path}",
366
  data=json.dumps(body).encode() if body else None,
367
  headers={"Content-Type": "application/json"}, method="POST")
368
+ with urllib.request.urlopen(req, context=_ssl) as r: return json.loads(r.read())
369
  def get(path):
370
+ with urllib.request.urlopen(f"{BASE}{path}", context=_ssl) as r: return json.loads(r.read())
371
 
372
  post("/reset")
373
  actions = [
 
412
 
413
  reset
414
  BASE=$BASE python3 - <<'PYEOF'
415
+ import os, ssl, urllib.request, json
416
  BASE = os.environ.get("BASE", "http://localhost:8000")
417
+ _ssl = ssl.create_default_context()
418
+ _ssl.check_hostname = False
419
+ _ssl.verify_mode = ssl.CERT_NONE
420
  def post(path, body=None):
421
  req = urllib.request.Request(f"{BASE}{path}",
422
  data=json.dumps(body).encode() if body else None,
423
  headers={"Content-Type": "application/json"}, method="POST")
424
+ with urllib.request.urlopen(req, context=_ssl) as r: return json.loads(r.read())
425
 
426
  post("/reset")
427
  actions = [
 
554
 
555
  if command -v python3 &>/dev/null; then
556
  WS_RESULT=$(BASE=$BASE python3 - <<'PYEOF'
557
+ import os, ssl, urllib.request, json
558
  try:
559
  BASE = os.environ.get("BASE", "http://localhost:8000")
560
+ _ssl = ssl.create_default_context()
561
+ _ssl.check_hostname = False
562
+ _ssl.verify_mode = ssl.CERT_NONE
563
  # ws upgrade check via HTTP (will get 426 Upgrade Required — proves endpoint exists)
564
  req = urllib.request.Request(f"{BASE}/ws")
565
  try:
566
+ urllib.request.urlopen(req, context=_ssl)
567
  except Exception as e:
568
  msg = str(e)
569
  if "426" in msg or "101" in msg or "Switching" in msg or "upgrade" in msg.lower():