File size: 1,505 Bytes
17a5579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import subprocess
import os

print("=" * 50)
print("  Interior Env — Pre-flight Check")
print("=" * 50)

checks = ["Dockerfile", "inference.py", "openenv.yaml"]
all_ok = True

for f in checks:
    if os.path.exists(f):
        print(f"[OK] {f}")
    else:
        print(f"[FAIL] {f} missing!")
        all_ok = False

if not all_ok:
    print("\n[!] Missing critical files. Halting checks.")
    exit(1)

print("\n--- Running inference.py local validation ---\n")

try:
    result = subprocess.run(
        ["python", "inference.py"], 
        capture_output=True, 
        text=True, 
        timeout=15
    )
    
    stdout = result.stdout
    if "[START]" in stdout and "[STEP]" in stdout and "[END]" in stdout:
        if "score=0.0000" in stdout:
            print("[WARN] inference.py has structured tags but score is 0. Is Baseline working?")
            print(f"Stdout summary: {stdout[:800]}")
            all_ok = False
        else:
            print("[OK] inference.py produces structured tags correctly with baseline scores.")
            print(stdout)
    else:
        print("[FAIL] inference.py output is missing structured tags.")
        print(f"Stdout summary: {stdout[:500]}")
        all_ok = False
        
except Exception as e:
    print(f"[FAIL] inference.py crashed: {e}")
    all_ok = False

print("\n" + "=" * 50)
if all_ok:
    print("RESULT: ALL CHECKS PASSED. Ready for HF Spaces.")
else:
    print("RESULT: CHECKS FAILED. Fix issues before deployment.")
print("=" * 50)