#!/usr/bin/env python3
import argparse,pathlib,platform,sys,importlib
p=argparse.ArgumentParser();p.add_argument('--root',default='/root/disk_3tb/earlywarning/30072026');a=p.parse_args()
print('[SUITE28 PREFLIGHT] python=',sys.version.split()[0], 'OS=',platform.platform())
for module in ['numpy','scipy','pandas','sklearn','joblib','torch']:
    z=importlib.import_module(module);print(f'[PACKAGE] {module} {getattr(z,"__version__","unknown")}')
import torch
print('[ACCELERATOR] cuda=',torch.cuda.is_available(),'device=',torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'cpu')
root=pathlib.Path(a.root);can=root/'results'/'cross_faculty_residual_moe'/'cache';struc=root/'results'/'suite12_structured_cache'
if not can.is_dir() or not struc.is_dir():raise RuntimeError(f'Missing required cache roots: {can}, {struc}')
for fold in range(1,8):
    files=list(can.glob(f'*_fold_{fold}.joblib'))
    missing=[f.name for f in files if not (struc/f.name).exists()]
    print(f'[FOLD {fold}] canonical={len(files)} structured_missing={len(missing)}')
    if not files or missing:raise RuntimeError(f'F{fold} missing input caches: {missing[:6]}')
print('[SUITE28 PREFLIGHT] BASIC PATH/DEPENDENCY CHECK PASSED')
print('[NOTE] For schema, row alignment, grade and student-context checks use train_suite28_drrm.py --preflight-only')
