File size: 1,332 Bytes
773566b ef18673 773566b ef18673 773566b ef18673 773566b ef18673 773566b ef18673 773566b ef18673 773566b | 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 | """Upload SAGE model repository contents to the Hugging Face Hub.
Only uploads files relevant to the model: source code, configs,
tokenizer assets, documentation, and serving infrastructure.
Debug scripts, test suites, IDE files, checkpoints, and build
artifacts are excluded.
"""
from __future__ import annotations
import os
from huggingface_hub import HfApi
REPO_ID = "sage002/sage"
DEFAULT_COMMIT_MESSAGE = "SAGE model repository : Updating some model checkpoints "
HF_IGNORE_PATTERNS = [
".git/*",
".gitignore",
".idea/*",
".pytest_cache/*",
".venv/*",
"__pycache__/*",
"*.pyc",
"*.pyo",
"checkpoints/*",
"runs/*",
"wandb/*",
"logs/*",
"data/raw/*",
"data/processed/*",
"debug/*",
"tests/*",
"*.log",
]
def main() -> None:
"""Replace the remote Hugging Face repo contents with the local folder state."""
api = HfApi()
commit_message = os.environ.get("HF_COMMIT_MESSAGE", DEFAULT_COMMIT_MESSAGE)
print(f"Syncing current repository to {REPO_ID}...")
api.upload_folder(
folder_path=".",
repo_id=REPO_ID,
repo_type="model",
ignore_patterns=HF_IGNORE_PATTERNS,
delete_patterns="*",
commit_message=commit_message,
)
print("Sync complete.")
if __name__ == "__main__":
main() |