File size: 8,518 Bytes
f45837e | 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | #!/usr/bin/env python3
"""Download + prepare MLE-bench competitions on the cluster, one Job per comp.
gke/.venv/bin/python gke/prep_datasets.py submit --split both # the 5/15 split (20 comps)
gke/.venv/bin/python gke/prep_datasets.py submit --lite # MLE-bench Lite (22 comps)
gke/.venv/bin/python gke/prep_datasets.py submit --competitions spooky-author-identification
gke/.venv/bin/python gke/prep_datasets.py status
Each Job runs `mlebench prepare` from Kaggle (kaggle-json secret + rules you
accepted on kaggle.com), tars prepared/, and uploads it to
gs://<bucket>/data/<comp>/prepared.tar.gz. Already-uploaded comps are skipped
unless --force. Prep pods run on spot by default (cheap; a preempted prep just
reruns).
"""
from __future__ import annotations
import argparse
import json
import sys
import urllib.request
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import k8s as K
import settings as S
REPO = Path(__file__).resolve().parents[1]
LITE_URL = ("https://raw.githubusercontent.com/openai/mle-bench/main/"
"experiments/splits/low.txt")
# On-disk size hints (GB) for scratch sizing; wrong entries cost headroom, not
# correctness. Union of rubric_gen/prepare_train.py's table + the split comps.
SIZE_GB = {
"spooky-author-identification": 0.1, "tabular-playground-series-dec-2021": 1,
"lmsys-chatbot-arena": 1, "dog-breed-identification": 1,
"dogs-vs-cats-redux-kernels-edition": 1, "random-acts-of-pizza": 0.1,
"tweet-sentiment-extraction": 0.1, "new-york-city-taxi-fare-prediction": 6,
"plant-pathology-2020-fgvc7": 3, "facebook-recruiting-iii-keyword-extraction": 4,
"ventilator-pressure-prediction": 1, "smartphone-decimeter-2022": 20,
"AI4Code": 4, "billion-word-imputation": 5,
"cassava-leaf-disease-classification": 7, "osic-pulmonary-fibrosis-progression": 20,
"petfinder-pawpularity-score": 2, "statoil-iceberg-classifier-challenge": 1,
"bms-molecular-translation": 10, "nfl-player-contact-detection": 10,
"stanford-covid-vaccine": 3, "whale-categorization-playground": 1,
"aerial-cactus-identification": 0.1, "denoising-dirty-documents": 0.1,
"detecting-insults-in-social-commentary": 0.1, "leaf-classification": 0.1,
"mlsp-2013-birds": 1, "text-normalization-challenge-english-language": 1,
"text-normalization-challenge-russian-language": 1, "nomad2018-predict-transparent-conductors": 0.1,
"jigsaw-toxic-comment-classification-challenge": 1, "kuzushiji-recognition": 6,
"histopathologic-cancer-detection": 8, "aptos2019-blindness-detection": 10,
"siim-isic-melanoma-classification": 30, "tgs-salt-identification-challenge": 1,
"the-icml-2013-whale-challenge-right-whale-redux": 1,
# The giants. All 14 died in the first prep sweep because they were
# absent here, defaulted to 25 GB, and got 120Gi scratch — disk-full
# mid-download. Estimates are deliberately generous: wrong entries cost
# headroom, not correctness.
"3d-object-detection-for-autonomous-vehicles": 120,
"cdiscount-image-classification-challenge": 60,
"google-research-identify-contrails-reduce-global-warming": 450,
"h-and-m-personalized-fashion-recommendations": 40,
"herbarium-2020-fgvc7": 130,
"herbarium-2021-fgvc8": 180,
"herbarium-2022-fgvc9": 160,
"icecube-neutrinos-in-deep-ice": 150,
"inaturalist-2019-fgvc6": 230,
"iwildcam-2019-fgvc6": 50,
"iwildcam-2020-fgvc7": 110,
"rsna-miccai-brain-tumor-radiogenomic-classification": 140,
"seti-breakthrough-listen": 160,
"siim-covid19-detection": 130,
# The rules-unblocked batch (accepted 2026-08-16); DICOM comps sized up.
"plant-pathology-2021-fgvc8": 20,
"predict-volcanic-eruptions-ingv-oe": 35,
"rsna-2022-cervical-spine-fracture-detection": 350,
"rsna-breast-cancer-detection": 280,
"tensorflow-speech-recognition-challenge": 5,
"tensorflow2-question-answering": 20,
"us-patent-phrase-to-phrase-matching": 1,
"uw-madison-gi-tract-image-segmentation": 5,
"vesuvius-challenge-ink-detection": 40,
"vinbigdata-chest-xray-abnormalities-detection": 210,
}
# Comps whose FILE COUNT (not byte size) blows past the 4*size+20 formula.
# bms-molecular-translation extracts ~4M small PNGs: zip + raw + prepared
# coexist, and ext4 inode count scales with volume size, so give it room.
SCRATCH_OVERRIDE_GI = {
"bms-molecular-translation": 400,
# 30 GB compressed but ~108 GB raw DICOM + prepared copies
"siim-isic-melanoma-classification": 500,
}
def split_sides() -> dict[str, str]:
"""comp -> train|eval from the frozen 5/15 manifest (also feeds SIZE_GB)."""
mf = json.loads((REPO / "rubric_gen/splits/error_side_5_15.json").read_text())
sides = {}
for key, side in (("source_competitions", "train"),
("evaluation_competitions", "eval")):
for c in mf[key]:
sides[c["id"]] = side
SIZE_GB[c["id"]] = float(c.get("dataset_size_gb") or 25)
return sides
def wanted(args) -> list[str]:
sides = split_sides()
comps: list[str] = []
if args.competitions:
comps += [c.strip() for c in args.competitions.split(",") if c.strip()]
if args.split in ("train", "both"):
comps += [c for c, s in sides.items() if s == "train"]
if args.split in ("eval", "both"):
comps += [c for c, s in sides.items() if s == "eval"]
if args.lite:
with urllib.request.urlopen(LITE_URL, timeout=30) as r:
comps += [l.strip() for l in r.read().decode().splitlines() if l.strip()]
seen, out = set(), []
for c in comps:
if c not in seen:
seen.add(c)
out.append(c)
return out
def in_bucket(comp: str) -> bool:
return S.bucket().blob(f"data/{comp}/meta.json").exists()
def cmd_submit(args) -> None:
sides = split_sides()
comps = wanted(args)
if not comps:
raise SystemExit("nothing selected — use --split/--lite/--competitions")
K.upload_code("prep") # prep pods run gke/run_shard.py from this snapshot
launched = skipped = 0
for comp in comps:
if not args.force and in_bucket(comp):
print(f"[have] {comp}")
skipped += 1
continue
scratch = SCRATCH_OVERRIDE_GI.get(
comp, int(min(max(4 * SIZE_GB.get(comp, 25) + 20, 50), 2000)))
slug = comp.lower().replace("_", "-")[:40].strip("-")
K.delete_job(f"prep-{slug}") # clear any prior failed attempt
job = K.make_prep_job(comp, sides.get(comp, "benchmark"), scratch,
force=args.force, spot=not args.no_spot)
K.submit_job(job)
print(f"[job] {job.metadata.name} (scratch {scratch}Gi, "
f"side {sides.get(comp, 'benchmark')})")
launched += 1
print(f"\nlaunched {launched}, already in bucket {skipped}. "
f"Watch: gke/.venv/bin/python gke/prep_datasets.py status")
def cmd_status(args) -> None:
comps = wanted(args) or sorted(split_sides())
have = 0
for comp in comps:
if in_bucket(comp):
meta = json.loads(S.bucket().blob(f"data/{comp}/meta.json")
.download_as_text())
print(f"[have] {comp} ({meta['tar_bytes']/1e9:.2f} GB tar, "
f"{meta['prep_minutes']} min prep)")
have += 1
else:
slug = comp.lower().replace("_", "-")[:40].strip("-")
print(f"[....] {comp} job: {K.job_status(f'prep-{slug}')}")
print(f"\n{have}/{len(comps)} in gs://{S.BUCKET}/data/")
def cmd_logs(args) -> None:
slug = args.competitions.lower().replace("_", "-")[:40].strip("-")
print(K.pod_logs(f"prep-{slug}", tail=args.tail))
def main() -> None:
ap = argparse.ArgumentParser()
sub = ap.add_subparsers(dest="cmd", required=True)
for name in ("submit", "status", "logs"):
p = sub.add_parser(name)
p.add_argument("--competitions", default="")
p.add_argument("--split", choices=("train", "eval", "both", "none"),
default="none")
p.add_argument("--lite", action="store_true")
p.add_argument("--force", action="store_true")
p.add_argument("--no-spot", action="store_true")
p.add_argument("--tail", type=int, default=60)
args = ap.parse_args()
{"submit": cmd_submit, "status": cmd_status, "logs": cmd_logs}[args.cmd](args)
if __name__ == "__main__":
main()
|