Download tools/upload_release.py from PureOne/Avenyra-Geometric-Memory-Physics: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/tools/upload_release.py
- Command line
-
hf download hf://datasets/PureOne/Avenyra-Geometric-Memory-Physics/tools/upload_release.py
-
curl -L -o upload_release.py https://huggingface.co/datasets/PureOne/Avenyra-Geometric-Memory-Physics/resolve/main/tools/upload_release.py
2.02 kB
| #!/usr/bin/env python3 | |
| """Plan a dataset upload by default; actual publication requires --upload.""" | |
| import argparse | |
| from pathlib import Path | |
| import re | |
| import shlex | |
| import shutil | |
| import subprocess | |
| import sys | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--repo-id", required=True) | |
| parser.add_argument("--upload", action="store_true", help="Perform the remote dataset upload") | |
| args = parser.parse_args() | |
| if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*", args.repo_id): | |
| parser.error("Expected a repository identifier in namespace/name form.") | |
| cmd = ["hf", "upload", args.repo_id, str(ROOT), ".", "--repo-type", "dataset"] | |
| print("Destination:", args.repo_id, "(dataset)", flush=True) | |
| print("Release root:", ROOT, flush=True) | |
| if not args.upload: | |
| print("DRY RUN — no remote requests or authentication checks performed.") | |
| print(shlex.join(cmd)) | |
| return | |
| cli = shutil.which("hf") | |
| if not cli: | |
| parser.error("hf CLI not found. Install huggingface_hub and authenticate locally first.") | |
| check = subprocess.run([sys.executable, "-B", str(ROOT / "tools" / "validate_release.py")]) | |
| if check.returncode: | |
| raise SystemExit(check.returncode) | |
| help_result = subprocess.run([cli, "upload", "--help"], text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
| if help_result.returncode: | |
| parser.error("Could not inspect hf upload --help.") | |
| if "--repo-type" in help_result.stdout: | |
| flag = "--repo-type" | |
| elif "--type" in help_result.stdout: | |
| flag = "--type" | |
| else: | |
| parser.error("This hf CLI exposes no recognized dataset-type flag.") | |
| cmd = [cli, "upload", args.repo_id, str(ROOT), ".", flag, "dataset"] | |
| print("Uploading validated release contents to the specified dataset repository.", flush=True) | |
| raise SystemExit(subprocess.run(cmd).returncode) | |
| if __name__ == "__main__": | |
| main() | |