Datasets:
Modalities:
Text
Formats:
parquet
Languages:
English
Size:
100K - 1M
ArXiv:
Tags:
multi-hop-question-answering
hotpotqa
evidence-selection
question-decomposition
chain-of-thought
supervised-fine-tuning
License:
| #!/usr/bin/env python3 | |
| """Validate and publish a completed Bactrainus dataset checkout.""" | |
| from __future__ import annotations | |
| import argparse | |
| import os | |
| import subprocess | |
| import sys | |
| from collections.abc import Sequence | |
| from pathlib import Path | |
| DEFAULT_REPO_ID = "bactrianus/bactrainus-hotpotqa" | |
| UPLOAD_PATTERNS = ( | |
| "README.md", | |
| "LICENSE", | |
| "ATTRIBUTION.md", | |
| "DATA_PROVENANCE.md", | |
| "SOURCE_MANIFEST.json", | |
| "SOURCE_PATCHES.json", | |
| "architecture.svg", | |
| "CHECKSUMS.sha256", | |
| "data/**/*.parquet", | |
| "scripts/*.py", | |
| ) | |
| def parse_args(argv: Sequence[str] | None = None) -> argparse.Namespace: | |
| package_root = Path(__file__).resolve().parents[1] | |
| parser = argparse.ArgumentParser( | |
| description=( | |
| "Validate a completed Bactrainus dataset checkout and optionally " | |
| "publish it to Hugging Face." | |
| ) | |
| ) | |
| parser.add_argument("--root", type=Path, default=package_root) | |
| parser.add_argument("--repo-id", default=DEFAULT_REPO_ID) | |
| parser.add_argument( | |
| "--token-env", | |
| default="HF_TOKEN", | |
| help="environment variable holding a write token (default: HF_TOKEN)", | |
| ) | |
| parser.add_argument( | |
| "--execute", | |
| action="store_true", | |
| help="perform the upload after validation; omitted means validation only", | |
| ) | |
| return parser.parse_args(argv) | |
| def validate_checkout(root: Path) -> None: | |
| validator = Path(__file__).with_name("validate_release.py").resolve() | |
| subprocess.run( | |
| [sys.executable, str(validator), "--root", str(root)], | |
| check=True, | |
| ) | |
| required = (root / "data", root / "CHECKSUMS.sha256", root / "README.md") | |
| missing = [str(path) for path in required if not path.exists()] | |
| if missing: | |
| raise FileNotFoundError(f"validated checkout is missing: {missing}") | |
| def publish(root: Path, repo_id: str, token_env: str) -> str: | |
| token = os.environ.get(token_env) | |
| if not token: | |
| raise RuntimeError(f"set {token_env} before publishing") | |
| try: | |
| from huggingface_hub import HfApi | |
| except ModuleNotFoundError as error: | |
| raise RuntimeError("install huggingface_hub before publishing") from error | |
| api = HfApi(token=token) | |
| api.create_repo(repo_id=repo_id, repo_type="dataset", private=False, exist_ok=True) | |
| result = api.upload_folder( | |
| folder_path=root, | |
| repo_id=repo_id, | |
| repo_type="dataset", | |
| allow_patterns=list(UPLOAD_PATTERNS), | |
| ignore_patterns=["README_PENDING.md", "**/__pycache__/**", "*.pyc"], | |
| commit_message="Publish complete validated Bactrainus HotpotQA training data", | |
| ) | |
| return str(result) | |
| def main(argv: Sequence[str] | None = None) -> int: | |
| args = parse_args(argv) | |
| root = args.root.resolve() | |
| if not root.is_dir(): | |
| print(f"error: dataset root does not exist: {root}", file=sys.stderr) | |
| return 2 | |
| try: | |
| validate_checkout(root) | |
| if not args.execute: | |
| print("Validation passed. Re-run with --execute to publish.") | |
| return 0 | |
| url = publish(root, args.repo_id, args.token_env) | |
| except (FileNotFoundError, RuntimeError, subprocess.CalledProcessError) as error: | |
| print(f"error: {error}", file=sys.stderr) | |
| return 1 | |
| print(f"Published validated dataset revision: {url}") | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |