from huggingface_hub import HfApi, HfFolder, Repository import os def push_to_hf(model_dir, repo_name, token): repo = Repository(local_dir=model_dir, clone_from=f"{repo_name}", use_auth_token=token) repo.push_to_hub(commit_message="Save checkpoint") def load_from_hf(repo_name, token, local_dir="model_checkpoint"): repo = Repository(local_dir=local_dir, clone_from=repo_name, use_auth_token=token) return local_dir