"""Task tests through a running llama-server (architecture 6.5). Extends legacy evaltasks.py and gsm.py. python3 tasks.py --url http://127.0.0.1:PORT --test humaneval|mbpp|gsm8k|mmlu --n N --version V \ --tests /srv/prune/data/texts/tests --out /srv/prune/out [--effort 0] [--max-tokens M] [--concurrency 12] Writes /per_problem/__.jsonl, one line per problem (resumable by id), and prints ONE JSON line: {version, test, n, correct, score, finished_share, tokens_mean, wall_s, effort}, computed from the per-problem file. Only message.content is graded, never reasoning_content. finish_reason "length" = wrong and unfinished. A file written at one (effort, max_tokens) is never continued at another: use a different --version (e.g. full-think) for the thinking-on run. Requests that fail after retries are not written; the exit code is then 3 and a rerun retries them. Generated code runs with `python3 -I` (this interpreter) in a fresh temp dir, 10 s limit. """ import argparse import concurrent.futures as cf import json import os import re import shutil import signal import subprocess import sys import tempfile import threading import time import urllib.request MAX_TOKENS = {'humaneval': 3000, 'mbpp': 3000, 'gsm8k': 2000, 'mmlu': 1000} # ------------------------------------------------------------------------------------------- graders def extract_code(txt): """Last fenced code block (```python, ```py or bare ```); the whole reply if there is none.""" blocks = re.findall(r'```[ \t]*(?:python3?|py)?[ \t]*\n(.*?)```', txt, re.S | re.I) return blocks[-1] if blocks else txt def last_number(txt): nums = re.findall(r'-?\d[\d,]*(?:\.\d+)?', txt) if not nums: return None try: return float(nums[-1].replace(',', '')) except ValueError: return None def gold_number(answer): return float(answer.split('####')[-1].strip().replace(',', '')) def last_letter(txt): m = re.findall(r'(?