yamahei21 commited on
Commit
b8adc7d
·
verified ·
1 Parent(s): 2b2dfe2

Rebuild: b2b6920d (publish_results + verified publish)

Browse files
kit_manifest.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "built_from_commit": "6c480a5f6224f7598c6c0b6388bcadc8f16502a5",
3
  "capabilities": [
4
  "rht_int4_convert.layer_filter",
5
  "eval_quantized.dtype",
@@ -28,7 +28,7 @@
28
  "scripts/lalamo_forward.py": "e4429221ecb6127faae9a5770bcc16d4e72d7c5ab7a7e2171477266be820745a",
29
  "scripts/kaggle_usage.py": "e1c4c1a902d716e09a9b8fce9a0019b152a758f2390dd34c678fc44c7aef48b1",
30
  "scripts/eval_generation.py": "bc240aef06c6ede583c3334fd0483ca9153ca07a52e22ef53c85c0b4fb90f7d2",
31
- "scripts/pull_results.py": "e5873cfda71dcebcf86e1ecfaacefc9bf01a142521d06c065654eaea7d07de5c",
32
  "scripts/corpus_guard.py": "5f226a81988acaebd80b8b81dfb4207ed8b661e52067b0260deec6ee48e9af6a",
33
  "scripts/dedup_lines.py": "d7caa00dc29f0ba48bc1bdac675e2ed5d81f0514d5d9df17a8f5b2017e6ea8d4",
34
  "scripts/dedup_calibration.py": "62ecc3c3921d307048c9e3547026634b616110115baf561f74dfb74c91e89b7d",
@@ -37,9 +37,10 @@
37
  "scripts/preflight.py": "5c2bcbe3693c8abf645fbf3f8160d96fdc1695daf09dc4961464ca8a23698e6e",
38
  "scripts/env_fingerprint.py": "651db85ad3cdf28bc46e97010986109df60785eb6646507ee38b0fa75dce57d5",
39
  "scripts/kaggle_slots.py": "e3baafe52347e74158c5b82fe6a2849f72a201d8ce60c0bbbf0871e47c75ae79",
 
40
  "scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
41
  "scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
42
- "scripts/build_kit.py": "1f8c3519fe8ffe29963b80f81d066de554b30f2294f993dee737b62e6bbb2541",
43
  "scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
44
  "data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
45
  "data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
 
1
  {
2
+ "built_from_commit": "b2b6920d14d9f9a4c5dda98f3ca69e1ebbb96fa2",
3
  "capabilities": [
4
  "rht_int4_convert.layer_filter",
5
  "eval_quantized.dtype",
 
28
  "scripts/lalamo_forward.py": "e4429221ecb6127faae9a5770bcc16d4e72d7c5ab7a7e2171477266be820745a",
29
  "scripts/kaggle_usage.py": "e1c4c1a902d716e09a9b8fce9a0019b152a758f2390dd34c678fc44c7aef48b1",
30
  "scripts/eval_generation.py": "bc240aef06c6ede583c3334fd0483ca9153ca07a52e22ef53c85c0b4fb90f7d2",
31
+ "scripts/pull_results.py": "ad51bdd36f7ebed06ec2b7c107b00009e219a645dd148bd568737ec95cc0bfaa",
32
  "scripts/corpus_guard.py": "5f226a81988acaebd80b8b81dfb4207ed8b661e52067b0260deec6ee48e9af6a",
33
  "scripts/dedup_lines.py": "d7caa00dc29f0ba48bc1bdac675e2ed5d81f0514d5d9df17a8f5b2017e6ea8d4",
34
  "scripts/dedup_calibration.py": "62ecc3c3921d307048c9e3547026634b616110115baf561f74dfb74c91e89b7d",
 
37
  "scripts/preflight.py": "5c2bcbe3693c8abf645fbf3f8160d96fdc1695daf09dc4961464ca8a23698e6e",
38
  "scripts/env_fingerprint.py": "651db85ad3cdf28bc46e97010986109df60785eb6646507ee38b0fa75dce57d5",
39
  "scripts/kaggle_slots.py": "e3baafe52347e74158c5b82fe6a2849f72a201d8ce60c0bbbf0871e47c75ae79",
40
+ "scripts/publish_results.py": "bc371280cc9f2fc45b2fee7d63422fb7e51b1f5bb0e14015f58de0f3ecec48ee",
41
  "scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
42
  "scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
43
+ "scripts/build_kit.py": "4cc1112537655634691650f56a8015da7a18bfc9b4e6895b55baa9e96be3bd4b",
44
  "scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
45
  "data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
46
  "data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
scripts/build_kit.py CHANGED
@@ -61,6 +61,7 @@ KIT_SCRIPTS = [
61
  "preflight.py",
62
  "env_fingerprint.py",
63
  "kaggle_slots.py",
 
64
  # sharding / audit
65
  "tiny_sharding_probe.py",
66
  "audit_public_corpus.py",
 
61
  "preflight.py",
62
  "env_fingerprint.py",
63
  "kaggle_slots.py",
64
+ "publish_results.py",
65
  # sharding / audit
66
  "tiny_sharding_probe.py",
67
  "audit_public_corpus.py",
scripts/publish_results.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Publish lane results to the shared HF results dataset.
3
+
4
+ Results used to go to ``kentasatomuse/uzu-results``, which the owner account
5
+ cannot read, so every handoff needed a manual export. They now go to one private
6
+ dataset: ``yamahei21/uzu-results``.
7
+
8
+ The upload carries provenance because a result without it cannot be compared:
9
+
10
+ <namespace>/environment.json lalamo commit + RHT code hashes
11
+ <namespace>/<lane>/manifest.json run_lane manifest (already has the fingerprint)
12
+
13
+ Uploads are refused when a manifest reports ``problems`` (a broken lane must not
14
+ look like data) or when no manifest exists at all.
15
+
16
+ Usage:
17
+ python scripts/publish_results.py --out out --as muse
18
+ python scripts/publish_results.py --out out --as muse --dry-run
19
+ python scripts/publish_results.py --out out --as muse --allow-problems
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import json
26
+ import subprocess
27
+ import sys
28
+ from pathlib import Path
29
+ from typing import Any
30
+
31
+ DEFAULT_REPO = "yamahei21/uzu-results"
32
+
33
+
34
+ def load_manifests(root: Path) -> list[tuple[Path, dict[str, Any]]]:
35
+ found = []
36
+ for path in sorted(root.rglob("manifest.json")):
37
+ try:
38
+ payload = json.loads(path.read_text(encoding="utf-8"))
39
+ except (OSError, ValueError) as error:
40
+ print(f"skip unreadable {path}: {error}", file=sys.stderr)
41
+ continue
42
+ if isinstance(payload, dict):
43
+ found.append((path, payload))
44
+ return found
45
+
46
+
47
+ def collect_issues(root: Path) -> tuple[list[str], list[str]]:
48
+ """Return (errors, warnings).
49
+
50
+ Errors block the upload: a lane that reported problems is not data, and an
51
+ empty tree usually means the run wrote somewhere else.
52
+ """
53
+ errors: list[str] = []
54
+ warnings: list[str] = []
55
+ manifests = load_manifests(root)
56
+ if not manifests:
57
+ errors.append(f"no manifest.json under {root}")
58
+ return errors, warnings
59
+
60
+ for path, manifest in manifests:
61
+ lane = manifest.get("lane") or path.parent.name
62
+ problems = manifest.get("problems") or []
63
+ if problems:
64
+ errors.append(f"{lane}: {len(problems)} problem(s), first: {problems[0]}")
65
+ fingerprint = manifest.get("environment_fingerprint") or {}
66
+ if not fingerprint:
67
+ warnings.append(f"{lane}: no environment_fingerprint (older kit?)")
68
+ elif fingerprint.get("lalamo_hash_complete") == "false":
69
+ warnings.append(f"{lane}: lalamo fingerprints incomplete; do not compare with owner")
70
+ return errors, warnings
71
+
72
+
73
+ def result_files(root: Path) -> list[str]:
74
+ """Relative paths that are worth uploading (skip caches and temp output)."""
75
+ skipped = {".git", "__pycache__", ".ipynb_checkpoints"}
76
+ files = []
77
+ for path in sorted(root.rglob("*")):
78
+ if not path.is_file():
79
+ continue
80
+ relative = path.relative_to(root)
81
+ if any(part in skipped for part in relative.parts):
82
+ continue
83
+ files.append(str(relative))
84
+ return files
85
+
86
+
87
+ def write_environment(root: Path) -> Path:
88
+ """Record which code produced these numbers, next to the numbers."""
89
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
90
+ try:
91
+ from env_fingerprint import fingerprint
92
+ except Exception as error: # noqa: BLE001 - provenance is best effort
93
+ print(f"warning: cannot compute fingerprint: {error}", file=sys.stderr)
94
+ return root
95
+ path = root / "environment.json"
96
+ path.write_text(json.dumps(fingerprint(), indent=2, sort_keys=True) + "\n", encoding="utf-8")
97
+ return path
98
+
99
+
100
+ def upload(repo: str, root: Path, namespace: str) -> None:
101
+ command = [
102
+ "hf",
103
+ "upload",
104
+ repo,
105
+ str(root),
106
+ namespace,
107
+ "--repo-type",
108
+ "dataset",
109
+ "--commit-message",
110
+ f"results: {namespace}",
111
+ ]
112
+ print("$ " + " ".join(command), flush=True)
113
+ result = subprocess.run(command, check=False)
114
+ if result.returncode != 0:
115
+ raise SystemExit(f"hf upload failed ({result.returncode})")
116
+
117
+
118
+ def main() -> None:
119
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
120
+ parser.add_argument("--out", type=Path, required=True, help="lane output directory")
121
+ parser.add_argument("--repo", default=DEFAULT_REPO)
122
+ parser.add_argument("--as", dest="namespace", required=True, help="subdirectory, e.g. muse or owner")
123
+ parser.add_argument("--dry-run", action="store_true")
124
+ parser.add_argument("--allow-problems", action="store_true")
125
+ args = parser.parse_args()
126
+
127
+ if not args.out.exists():
128
+ raise SystemExit(f"nothing at {args.out}")
129
+
130
+ errors, warnings = collect_issues(args.out)
131
+ for warning in warnings:
132
+ print(f"warning: {warning}")
133
+ if errors and not args.allow_problems:
134
+ print("REFUSING TO PUBLISH")
135
+ for error in errors:
136
+ print(f" - {error}")
137
+ raise SystemExit(1)
138
+ for error in errors:
139
+ print(f"overridden: {error}")
140
+
141
+ files = result_files(args.out)
142
+ print(f"{len(files)} file(s) under {args.out}")
143
+ if args.dry_run:
144
+ print(f"dry-run: would upload to {args.repo}/{args.namespace}")
145
+ return
146
+
147
+ environment = write_environment(args.out)
148
+ print(f"wrote {environment}")
149
+ upload(args.repo, args.out, args.namespace)
150
+ print(f"PUBLISHED {args.repo}/{args.namespace}")
151
+
152
+
153
+ if __name__ == "__main__":
154
+ main()
scripts/pull_results.py CHANGED
@@ -1,14 +1,14 @@
1
  #!/usr/bin/env python3
2
  """Pull a results repository and summarise what landed.
3
 
4
- The Kaggle operator uploads ``<lane>/manifest.json`` + per-condition JSON to
5
- ``<user>/uzu-results``. This downloads it and prints what is complete, what is
6
  missing, and whether any manifest reported problems, so nobody has to eyeball a
7
  directory tree.
8
 
9
  Usage:
10
- python scripts/pull_results.py --repo kentasatomuse/uzu-results --out results/kentasatomuse
11
- python scripts/pull_results.py --out results/kentasatomuse --skip-download
12
  python scripts/pull_results.py --repo ... --out ... --json results/summary.json
13
  """
14
 
@@ -82,7 +82,7 @@ def download(repo: str, out: Path, revision: str | None) -> None:
82
 
83
  def main() -> None:
84
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
85
- parser.add_argument("--repo", default=None, help="HF dataset repo, e.g. <user>/uzu-results")
86
  parser.add_argument("--revision", default=None)
87
  parser.add_argument("--out", type=Path, required=True)
88
  parser.add_argument("--skip-download", action="store_true")
 
1
  #!/usr/bin/env python3
2
  """Pull a results repository and summarise what landed.
3
 
4
+ The Kaggle operator uploads ``<namespace>/<lane>/manifest.json`` + per-condition
5
+ JSON to ``yamahei21/uzu-results`` (private). This downloads it and prints what is complete, what is
6
  missing, and whether any manifest reported problems, so nobody has to eyeball a
7
  directory tree.
8
 
9
  Usage:
10
+ python scripts/pull_results.py --repo yamahei21/uzu-results --out results/shared
11
+ python scripts/pull_results.py --out results/shared --skip-download
12
  python scripts/pull_results.py --repo ... --out ... --json results/summary.json
13
  """
14
 
 
82
 
83
  def main() -> None:
84
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
85
+ parser.add_argument("--repo", default="yamahei21/uzu-results", help="HF dataset repo")
86
  parser.add_argument("--revision", default=None)
87
  parser.add_argument("--out", type=Path, required=True)
88
  parser.add_argument("--skip-download", action="store_true")