""" 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)") # =========================================================================== # 1. File-level evaluation # =========================================================================== # Input : issue_title + issue_body + images + (repo snapshot at base_commit) # Output: ranked list of files to edit # Gold : row["edit_files"] — always non-empty in the canonical config. # =========================================================================== 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)") # Decode the first screenshot — HF Image feature returns PIL.Image automatically. img = row["images"][0] print(f" image[0] : {img.size} px, mode={img.mode}, caption={row['image_alts'][0]!r}") # img.save("first_issue_screenshot.png") # persist for visual inspection # =========================================================================== # 2. Function-level evaluation # =========================================================================== # Input : same as file-level # Output: ranked list of `path/to/file:function` identifiers # Gold : row["edit_functions"] (always non-empty in the function_level config) # Caveat: exclude row["added_functions"] when scoring — those functions do # not exist at base_commit, so they cannot be retrieved from the # repository tree. # =========================================================================== 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']}") # Pick any instance that is ONLY file-level (no function annotation) to # illustrate the filter that separates the two configs. 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']}") # =========================================================================== # 3. VCE+ preview (illustrative; not a shipped config) # =========================================================================== # VCE+ is a 7-dimensional structured extraction per screenshot (OCR, error # signal, UI elements, user action, code hints, visual saliency, confidence) # produced by a multimodal LLM. The FULL cache is a rerunnable byproduct and # is NOT shipped in data/. A 20-row preview aligned by instance_id with # examples/preview/preview.jsonl ships at examples/preview/vce_plus_preview.jsonl # so the schema stays discoverable without running the extractor. # =========================================================================== 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', [])}" ) # =========================================================================== # 4. Repository snapshots # =========================================================================== # Scoring requires the repository tree at each row's base_commit. Repos are # not embedded in the Parquet (they would total several GB and carry # heterogeneous upstream licenses). Use commit_cache.json + the bundled # script to fetch them: # # export GITHUB_TOKEN=ghp_xxx # python3 scripts/download_repos.py # fetch all 653 repos # python3 scripts/download_repos.py --only 5 # dry-run slice # =========================================================================== 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)")