#!/usr/bin/env python3 from __future__ import annotations import argparse import json import sys from pathlib import Path from huggingface_hub import HfApi from huggingface_hub.utils import RepositoryNotFoundError def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--repo-id", default="skyzhou06/LifeStreamingCoT") parser.add_argument("--folder", default="life_streaming_cot_dataset") args = parser.parse_args() folder = Path(args.folder) if not folder.exists(): print(f"Dataset folder does not exist: {folder}", file=sys.stderr) sys.exit(1) info_path = folder / "dataset_info.json" if not info_path.exists(): print(f"Missing dataset_info.json in {folder}", file=sys.stderr) sys.exit(1) info = json.loads(info_path.read_text(encoding="utf-8")) if info.get("version") != "v0.4.1": print("Refusing upload: dataset_info.json is not version v0.4.1.", file=sys.stderr) sys.exit(1) if info.get("repo_id") != "skyzhou06/LifeStreamingCoT": print("Refusing upload: dataset_info.json repo_id is not skyzhou06/LifeStreamingCoT.", file=sys.stderr) sys.exit(1) if "v0.4.1" not in str(info.get("generation_method", "")): print("Refusing upload: generation_method does not contain v0.4.1.", file=sys.stderr) sys.exit(1) if args.repo_id != "skyzhou06/LifeStreamingCoT": print("Refusing upload: use the existing repo skyzhou06/LifeStreamingCoT.", file=sys.stderr) sys.exit(1) api = HfApi() try: api.whoami() except Exception: # noqa: BLE001 - do not print auth internals or tokens print("Hugging Face authentication is missing or invalid.") print("Run this command, then rerun the upload:") print("huggingface-cli login") sys.exit(2) try: api.repo_info(repo_id=args.repo_id, repo_type="dataset") except RepositoryNotFoundError: print(f"Refusing upload: dataset repo does not exist: {args.repo_id}", file=sys.stderr) sys.exit(1) api.upload_folder( repo_id=args.repo_id, repo_type="dataset", folder_path=str(folder), path_in_repo=".", commit_message="Update LifeStreamingCoT to v0.4.1 loading config and HQ subset patch", ignore_patterns=[ ".DS_Store", "*/.DS_Store", "__pycache__", "*/__pycache__/*", "*.pyc", ], ) print(f"https://huggingface.co/datasets/{args.repo_id}") if __name__ == "__main__": main()