| """ |
| The dataset ships two Parquet configs under `data/`: |
| |
| canonical.parquet 652 rows β full benchmark; drives file-level eval |
| function_level.parquet 343 rows β subset where edit_functions is non-empty |
| |
| This script walks through both evaluation granularities (file-level and |
| function-level), decodes an image, reads a 20-row VCE+ preview from |
| `examples/preview/vce_plus_preview.jsonl`, and shows how to materialize |
| the underlying GitHub repository snapshot required at scoring time. |
| |
| Run: |
| python3 examples/load_dataset.py |
| """ |
|
|
| from __future__ import annotations |
|
|
| import json |
| from pathlib import Path |
|
|
| from datasets import Dataset |
|
|
| ROOT = Path(__file__).resolve().parent.parent |
| DATA = ROOT / "data" |
|
|
| ds = Dataset.from_parquet(str(DATA / "canonical.parquet")) |
| ds_fn = Dataset.from_parquet(str(DATA / "function_level.parquet")) |
|
|
| print(f"canonical: {len(ds):4d} rows (file-level eval β all edit_files non-empty)") |
| print(f"function_level: {len(ds_fn):4d} rows (function-level eval β strict subset)") |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| row = ds[0] |
| print(f"\nββ file-level example ββββββββββββββββββββββββββββββββββββββββββββββ") |
| print(f" instance_id : {row['instance_id']}") |
| print(f" repo @ commit: {row['repo_full_name']} @ {row['base_commit'][:12]}") |
| print(f" language : {row['language']} ({row['language_category']})") |
| print(f" difficulty : {row['difficulty']} (changed_files={row['changed_files']})") |
| print(f" # images : {len(row['images'])}") |
| print(f" gold files : {row['edit_files']}") |
| print(f" (your model must rank {row['edit_files'][0]!r} near the top)") |
|
|
| |
| img = row["images"][0] |
| print(f" image[0] : {img.size} px, mode={img.mode}, caption={row['image_alts'][0]!r}") |
| |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| fn_row = ds_fn[0] |
| print(f"\nββ function-level example ββββββββββββββββββββββββββββββββββββββββββ") |
| print(f" instance_id : {fn_row['instance_id']}") |
| print(f" edit_functions : {fn_row['edit_functions']}") |
| print(f" added_functions: {fn_row['added_functions']} β exclude from scoring") |
| print(f" supports_function_level: {fn_row['supports_function_level']}") |
|
|
| |
| |
| file_only = next(r for r in ds if not r["supports_function_level"] or not r["edit_functions"]) |
| print(f"\n (a file-level-only instance in canonical but NOT in function_level)") |
| print(f" instance_id : {file_only['instance_id']}") |
| print(f" supports_function_level : {file_only['supports_function_level']}") |
| print(f" edit_functions (empty here!) : {file_only['edit_functions']}") |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| vce_preview_path = ROOT / "examples" / "preview" / "vce_plus_preview.jsonl" |
| vce_rows = [json.loads(l) for l in vce_preview_path.open()] |
| print(f"\nββ VCE+ preview (20 records) ββββββββββββββββββββββββββββββββββββββ") |
| print(f" path: {vce_preview_path.relative_to(ROOT)} ({len(vce_rows)} rows)") |
| vce_row = vce_rows[0] |
| print(f" sample instance_id: {vce_row['instance_id']} (category={vce_row['category']})") |
| for i, rec in enumerate(vce_row["records"]): |
| err = rec["error_signal"] or {} |
| ch = rec["code_hint"] or {} |
| print( |
| f" record[{i}]: conf={rec.get('confidence', 0.0):.2f} " |
| f"error={err.get('kind', '')}/{err.get('type', '')!r} " |
| f"ui_elements={(rec.get('ui_elements') or [])[:3]} " |
| f"frameworks={ch.get('frameworks', [])}" |
| ) |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| cache = json.loads((ROOT / "commit_cache.json").read_text()) |
| entry = cache[row["instance_id"]] |
| print(f"\nββ repo snapshot for the file-level example βββββββββββββββββββββββββ") |
| print(f" expected directory: repos/{entry['dir_name']}/") |
| print(f" equivalent to :") |
| print(f" git clone https://github.com/{entry['repo']} {entry['dir_name']}") |
| print(f" git -C {entry['dir_name']} checkout {entry['sha']}") |
| print(f" (or run: python3 scripts/download_repos.py β see scripts/download_repos.py)") |
|
|