File size: 1,166 Bytes
6cc01b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path
import ast

SCRIPT = Path("trainNLPRAGV2.py")

if not SCRIPT.exists():
    raise FileNotFoundError("trainNLPRAGV2.py introuvable dans le dossier courant.")

text = SCRIPT.read_text(encoding="utf-8")

tree = ast.parse(text)
target = None

for node in tree.body:
    if isinstance(node, ast.Assign):
        for t in node.targets:
            if isinstance(t, ast.Name) and t.id == "DATASET_SPECS":
                target = node
                break
    if target:
        break

if target is None:
    raise RuntimeError("Impossible de trouver DATASET_SPECS dans trainNLPRAGV2.py")

lines = text.splitlines()

new_block = '''DATASET_SPECS = [
    {
        "label": "boolq",
        "name": "google/boolq",
        "config": None,
        "split": "train",
        "kind": "boolq",
        "text_field": "passage",
        "group": "single",
        "trust_remote_code": False,
    }
]'''

start = target.lineno - 1
end = target.end_lineno

new_lines = lines[:start] + new_block.splitlines() + lines[end:]
SCRIPT.write_text("\\n".join(new_lines) + "\\n", encoding="utf-8")

print("OK : DATASET_SPECS remplacé par google/boolq uniquement.")