File size: 1,916 Bytes
0e2032e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/env python3
"""Persistently upload explicitly authorized GST_EGOSERVE binary assets."""
from __future__ import annotations
import logging
from pathlib import Path
from huggingface_hub import HfApi
ROOT = Path("/mnt/tokyo-ai/gst")
SOURCE = ROOT / "GST_EGOSERVE"
LOG = ROOT / "migration_gst_binary.log"
REPO_ID = "SitongGong/GST_EGOSERVE"
MEDIA_AND_WEIGHT_PATTERNS = [
"**/*.mp4", "**/*.mov", "**/*.avi", "**/*.mkv", "**/*.webm", "**/*.m4v",
"**/*.wav", "**/*.mp3", "**/*.flac", "**/*.m4a", "**/*.aac", "**/*.ogg",
"**/*.jpg", "**/*.jpeg", "**/*.png", "**/*.webp", "**/*.bmp",
"**/*.tif", "**/*.tiff", "**/*.gif",
"**/*.safetensors", "**/*.pth", "**/*.pt", "**/*.bin", "**/*.ckpt",
"**/*.onnx",
"**/.cache/**", "**/downloads/**",
]
NEVER_UPLOAD = [
"**/.env", "**/.env.*", "**/id_rsa", "**/id_rsa.*", "**/id_ed25519",
"**/id_ed25519.*", "**/*.pem", "**/*.key", "**/*credentials*",
"**/*secret*", "**/*api_key*", "**/*apikey*", "**/*token*",
"**/.git/**", "**/.cache/huggingface/upload/**",
]
def main() -> None:
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(message)s",
handlers=[logging.FileHandler(LOG, encoding="utf-8")],
)
logging.info("GST_BINARY_UPLOAD_START source=%s repo=%s", SOURCE, REPO_ID)
api = HfApi()
api.upload_large_folder(
repo_id=REPO_ID,
repo_type="dataset",
folder_path=SOURCE,
allow_patterns=MEDIA_AND_WEIGHT_PATTERNS,
ignore_patterns=NEVER_UPLOAD,
num_workers=8,
print_report=True,
print_report_every=60,
)
info = api.repo_info(REPO_ID, repo_type="dataset")
logging.info("GST_BINARY_UPLOAD_COMPLETE remote_files=%d", len(info.siblings))
if __name__ == "__main__":
try:
main()
except Exception:
logging.exception("GST_BINARY_UPLOAD_FAILED")
raise
|