jiagengliu02 commited on
Commit
aa4e7ae
·
verified ·
1 Parent(s): 03a35fd

Replace with Croissant-friendly questions table

Browse files
data/questions.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
scripts/export_hf_questions.py CHANGED
@@ -262,6 +262,9 @@ def main() -> int:
262
 
263
  json_root = args.json_root
264
  question_files = sorted(p for p in json_root.rglob("*.json") if p.parent != json_root)
 
 
 
265
  id_width = max(4, len(str(len(question_files))))
266
  records = [
267
  record_for_file(path, json_root, f"{index:0{id_width}d}")
 
262
 
263
  json_root = args.json_root
264
  question_files = sorted(p for p in json_root.rglob("*.json") if p.parent != json_root)
265
+ if not question_files:
266
+ raise SystemExit(f"No question JSON files found under {json_root}")
267
+
268
  id_width = max(4, len(str(len(question_files))))
269
  records = [
270
  record_for_file(path, json_root, f"{index:0{id_width}d}")
scripts/upload_hf_dataset.py CHANGED
@@ -2,19 +2,17 @@
2
  from __future__ import annotations
3
 
4
  import argparse
5
- import subprocess
6
- import sys
7
  from pathlib import Path
8
 
9
  from huggingface_hub import HfApi
10
 
11
 
12
- def run_export(repo_root: Path) -> None:
13
- subprocess.run(
14
- [sys.executable, "scripts/export_hf_questions.py"],
15
- cwd=repo_root,
16
- check=True,
17
- )
18
 
19
 
20
  def main() -> int:
@@ -22,13 +20,11 @@ def main() -> int:
22
  parser.add_argument("--repo-id", default="ESI-Bench/esi-bench")
23
  parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
24
  parser.add_argument("--private", action="store_true", help="Create the dataset repo as private if it does not exist.")
25
- parser.add_argument("--skip-export", action="store_true", help="Upload existing data/questions.jsonl without regenerating it.")
26
  parser.add_argument("--commit-message", default="Replace with Croissant-friendly questions table")
27
  args = parser.parse_args()
28
 
29
  repo_root = args.repo_root.resolve()
30
- if not args.skip_export:
31
- run_export(repo_root)
32
 
33
  api = HfApi()
34
  api.create_repo(repo_id=args.repo_id, repo_type="dataset", private=args.private, exist_ok=True)
 
2
  from __future__ import annotations
3
 
4
  import argparse
 
 
5
  from pathlib import Path
6
 
7
  from huggingface_hub import HfApi
8
 
9
 
10
+ def validate_dataset_file(repo_root: Path) -> None:
11
+ dataset_file = repo_root / "data/questions.jsonl"
12
+ if not dataset_file.exists():
13
+ raise SystemExit(f"Missing {dataset_file}")
14
+ if dataset_file.stat().st_size == 0:
15
+ raise SystemExit(f"{dataset_file} is empty. Regenerate it before uploading.")
16
 
17
 
18
  def main() -> int:
 
20
  parser.add_argument("--repo-id", default="ESI-Bench/esi-bench")
21
  parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
22
  parser.add_argument("--private", action="store_true", help="Create the dataset repo as private if it does not exist.")
 
23
  parser.add_argument("--commit-message", default="Replace with Croissant-friendly questions table")
24
  args = parser.parse_args()
25
 
26
  repo_root = args.repo_root.resolve()
27
+ validate_dataset_file(repo_root)
 
28
 
29
  api = HfApi()
30
  api.create_repo(repo_id=args.repo_id, repo_type="dataset", private=args.private, exist_ok=True)