const fs = require('fs'); const vm = require('vm'); const context = { TDGBENCH_FEATURES:{showKggen:true}, DATASETS_METADATA:{domains:{ biomed:{graphs:{cg:{},GT2KG_tdg:{},kggen:{}}}, dbpedia:{graphs:{cg:{},GT2KG_tdg:{}}} }} }; vm.createContext(context); vm.runInContext(fs.readFileSync('assets/js/pages/evaluate-gnn.js','utf8'),context); function state(overrides){ return Object.assign({ dataset:'biomed',graph:'GT2KG_tdg',variant:'default',modelSource:'existing', existingModel:'GCN',pygModel:'SAGEConv',customModule:'my_model',customSymbol:'MyGNN', emb:'sentence-transformers/all-MiniLM-L6-v2',results:'tdgbench_results' },overrides||{}); } let code=context.genC2(state({modelSource:'pyg',pygModel:'SAGEConv'})); if(!code.includes('from torch_geometric.nn import SAGEConv'))throw new Error('Import PyG absent.'); if(!code.includes('model=SAGEConv'))throw new Error('La convolution PyG doit être passée comme classe.'); code=context.genC2(state({modelSource:'existing',existingModel:'GCN'})); if(!code.includes('model="GCN"')||code.includes('torch_geometric'))throw new Error('Modèle TDGBench incorrect.'); code=context.genC2(state({modelSource:'custom',customModule:'models',customSymbol:'ResearchGNN'})); if(!code.includes('from models import ResearchGNN')||!code.includes('model=ResearchGNN'))throw new Error('Modèle personnalisé incorrect.'); code=context.genC2(state({modelSource:'existing',existingModel:'MLP'})); if(code.includes(' graph=')||!code.includes('model="MLP"'))throw new Error('Baseline MLP incorrecte.'); code=context.genC2(state({dataset:'dbpedia',graph:'all',modelSource:'pyg',pygModel:'SAGEConv'})); if(code.includes('available_graphs')||code.includes('for graph in graphs'))throw new Error('Tous les graphes doivent produire des appels explicites.'); if(!code.includes('tdg = bench.unified_evaluation(')||!code.includes('graph="GT2KG_tdg"'))throw new Error('L\'évaluation explicite du TDG DBpedia est absente.'); if(!code.includes('cg = bench.unified_evaluation(')||!code.includes('graph="cg"'))throw new Error('L\'évaluation explicite du graphe curé DBpedia est absente.'); if(!code.includes('print(tdg.best_results().to_string(index=False))')||!code.includes('print(cg.best_results().to_string(index=False))'))throw new Error('Les meilleurs résultats des deux graphes ne sont pas affichés.'); if((code.match(/model=SAGEConv/g)||[]).length!==2)throw new Error('SAGEConv doit être transmis aux deux évaluations.'); code=context.genC2(state({dataset:'biomed',graph:'all',modelSource:'pyg',pygModel:'SAGEConv'})); if(!code.includes('graph="kggen"'))throw new Error('KGGen doit être inclus dans l’évaluation de tous les graphes biomédicaux.'); console.log('Evaluation GNN valide : TDGBench, PyG, modèle personnalisé, MLP et tous les graphes.');