Syntax-3B-Untrained / push_to_hub.py
algorythmtechnologies's picture
Upload project folder .
a59f0ab verified
raw
history blame
1.33 kB
from huggingface_hub import HfApi
import os
import sys
# --- Configuration ---
# The local directory to upload.
# We will upload the entire current directory.
local_dir = "."
# The Hugging Face repository ID (username/model_name)
hf_repo_id = "algorythmtechnologies/Syntax-3B-Untrained"
# The branch you want to push to
branch_name = "main"
# --- End Configuration ---
# Get the token from the command-line arguments
if len(sys.argv) > 1:
token = sys.argv[1]
else:
print("Error: Hugging Face token not provided.")
print("Usage: python push_to_hub.py <your_hf_token>")
sys.exit(1)
print(f"Found local directory: {local_dir}")
print("Authenticating with Hugging Face...")
try:
# Initialize the HfApi client with the provided token.
api = HfApi(token=token)
print(f"Uploading contents of '{local_dir}' to '{hf_repo_id}' on branch '{branch_name}'...")
# Upload the folder to the repository
api.upload_folder(
folder_path=local_dir,
repo_id=hf_repo_id,
repo_type="model",
revision=branch_name,
commit_message=f"Upload project folder {local_dir}"
)
print("\nUpload complete!")
print(f"You can view your repository at: https://huggingface.co/{hf_repo_id}/tree/{branch_name}")
except Exception as e:
print(f"\nAn error occurred: {e}")