64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Push zindango-slm scripts to Hugging Face model repo (scripts/ folder).
|
|
|
|
Usage:
|
|
python scripts/push_scripts_to_hub.py [--repo-id USERNAME/zindango-slm]
|
|
"""
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from huggingface_hub import HfApi, create_repo, upload_file
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--repo-id", default=None)
|
|
parser.add_argument("--skip-create", action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
sft_root = Path(__file__).resolve().parent.parent
|
|
benchmark_root = sft_root.parent / "nanbeige-benchmark-verification"
|
|
|
|
api = HfApi()
|
|
user = api.whoami()
|
|
username = user["name"]
|
|
repo_id = args.repo_id or f"{username}/zindango-slm"
|
|
|
|
if not args.skip_create:
|
|
try:
|
|
create_repo(repo_id, repo_type="model", exist_ok=True)
|
|
except Exception as e:
|
|
if "403" in str(e).lower() or "forbidden" in str(e).lower():
|
|
print("Create repo failed. Run with --skip-create.")
|
|
raise
|
|
|
|
scripts_to_upload = [
|
|
(sft_root / "scripts/convert_and_push_gguf.py", "scripts/convert_and_push_gguf.py"),
|
|
(sft_root / "scripts/push_to_hub.py", "scripts/push_to_hub.py"),
|
|
(sft_root / "scripts/push_scripts_to_hub.py", "scripts/push_scripts_to_hub.py"),
|
|
(benchmark_root / "scripts/test_zindango_gguf.py", "scripts/test_zindango_gguf.py"),
|
|
(benchmark_root / "scripts/llamacpp_chat.py", "scripts/llamacpp_chat.py"),
|
|
(benchmark_root / "scripts/llamacpp_chat.sh", "scripts/llamacpp_chat.sh"),
|
|
]
|
|
|
|
for local_path, path_in_repo in scripts_to_upload:
|
|
if not local_path.exists():
|
|
print(f"Skipping {local_path} (not found)")
|
|
continue
|
|
print(f"Uploading {path_in_repo}...")
|
|
upload_file(
|
|
path_or_fileobj=str(local_path),
|
|
path_in_repo=path_in_repo,
|
|
repo_id=repo_id,
|
|
repo_type="model",
|
|
commit_message=f"Add {path_in_repo}",
|
|
)
|
|
|
|
print(f"Done. https://huggingface.co/{repo_id}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|