Datasets:
Download crosscodeeval_v2/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 4.37 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F24/crosscodeeval_v2/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks@refs/pr/24/crosscodeeval_v2/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F24/crosscodeeval_v2/patch.py
4.37 kB
| """Reproduce CrossCodeEval v2 tasks.parquet: the current v1 payload of every kept task plus the recorded results. | |
| pip install pyarrow huggingface_hub | |
| python patch.py --out ./rebuilt | |
| Both inputs are pinned to repository revision a43f5635 and checked by SHA-256: | |
| - crosscodeeval_v1/tasks.parquet: the current v1 payloads, content hashes and image manifest. | |
| - crosscodeeval_v2/tasks.parquet as published before this refresh: which tasks are kept, the | |
| recorded success counts (`instruct_successes`, `thinking_successes`, `attempts_per_model`, `archive_category`) and the release metadata. | |
| Use --source-dir PATH (holding v1.parquet and v2.parquet) to reuse local copies. | |
| Trajectories and success counts stay as recorded; each trace row keeps the content hash it | |
| was evaluated on. | |
| """ | |
| import argparse | |
| import copy | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| import pyarrow as pa | |
| import pyarrow.parquet as pq | |
| REPO = 'FWeindel/validated-tasks' | |
| REVISION = 'a43f56353751d6d73a93ff448de6981040c4d0c5' | |
| SOURCES = {'v1': ('crosscodeeval_v1/tasks.parquet', '2607baee26489948dbfeb1a02494e5a7d149752a1910be882c40cbc09f139f0f'), | |
| 'v2': ('crosscodeeval_v2/tasks.parquet', '21a25eac1b374c251f67f76e7abbb865435eeba329c7598ba210ba274d31f648')} | |
| REFRESHED = '2026-10-17' | |
| def source(name, source_dir, cache): | |
| path_in_repo, digest = SOURCES[name] | |
| if source_dir is None: | |
| from huggingface_hub import hf_hub_download | |
| path = Path(hf_hub_download(REPO, path_in_repo, repo_type='dataset', revision=REVISION, cache_dir=cache)) | |
| else: | |
| path = source_dir / f'{name}.parquet' | |
| if hashlib.sha256(path.read_bytes()).hexdigest() != digest: | |
| raise ValueError(f'pinned source hash mismatch: {path_in_repo}') | |
| return path | |
| def restrict_images(manifest, kept): | |
| result = copy.deepcopy(manifest) | |
| result['tasks'] = {path: entry for path, entry in manifest['tasks'].items() if path in kept} | |
| used = {env['bundle'] for entry in result['tasks'].values() for env in entry['environments']} | |
| result['bundles'] = {bid: bundle for bid, bundle in manifest['bundles'].items() if bid in used} | |
| result['missing'] = [m for m in manifest.get('missing', []) if m.get('task') in kept] | |
| return result | |
| def build(source_dir, out): | |
| out.mkdir(parents=True, exist_ok=True) | |
| if (out / 'tasks.parquet').exists(): | |
| raise ValueError('tasks.parquet already exists; choose an empty output directory') | |
| v1 = pq.read_table(source('v1', source_dir, out / '.source-cache')) | |
| old = pq.read_table(source('v2', source_dir, out / '.source-cache')) | |
| current = {row['path']: row for row in v1.to_pylist()} | |
| extra = [name for name in old.schema.names if name not in v1.schema.names] | |
| rows, earlier = [], 0 | |
| for row in old.to_pylist(): | |
| fresh = dict(current[row['path']]) | |
| fresh.update({name: row[name] for name in extra}) | |
| # The published v2 hash is the one the teacher runs were scored on. | |
| earlier += fresh['content_sha256'] != row['content_sha256'] | |
| rows.append(fresh) | |
| schema = pa.schema([*v1.schema, *(old.schema.field(name) for name in extra)]) | |
| metadata = dict(old.schema.metadata or {}) | |
| if b'ot.images.v1' in (v1.schema.metadata or {}): | |
| images = restrict_images(json.loads(v1.schema.metadata[b'ot.images.v1']), {r['path'] for r in rows}) | |
| metadata[b'ot.images.v1'] = json.dumps(images).encode() | |
| release = json.loads(metadata.get(b'ot.release.v2', b'{}')) | |
| release['current_v1'] = {'folder': 'crosscodeeval_v1', 'revision': REVISION, 'sha256': SOURCES['v1'][1], | |
| 'refreshed': REFRESHED, 'kept_tasks_evaluated_on_earlier_version': earlier} | |
| metadata[b'ot.release.v2'] = json.dumps(release).encode() | |
| pq.write_table(pa.Table.from_pylist(rows, schema=schema).replace_schema_metadata(metadata), | |
| out / 'tasks.parquet', compression='zstd') | |
| print(json.dumps({'kept': len(rows), 'evaluated_on_earlier_version': earlier, | |
| 'images': b'ot.images.v1' in metadata})) | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| parser.add_argument('--source-dir', type=Path) | |
| parser.add_argument('--out', type=Path, required=True) | |
| args = parser.parse_args() | |
| build(args.source_dir, args.out) | |