Download tools/background_gst_binary_upload.py from SitongGong/gst-code-collection: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/datasets/SitongGong/gst-code-collection/resolve/main/tools/background_gst_binary_upload.py
- Command line
-
hf download hf://datasets/SitongGong/gst-code-collection/tools/background_gst_binary_upload.py
-
curl -L -o background_gst_binary_upload.py https://huggingface.co/datasets/SitongGong/gst-code-collection/resolve/main/tools/background_gst_binary_upload.py
1.92 kB
| #!/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 | |