remote_code_model_with_dots / upload_test_model.py
Rocketknight1's picture
Rocketknight1 HF Staff
Upload 14 files
6055811 verified
Raw
History Blame Contribute Delete
1.24 kB
"""Upload the test model with dotted name to the Hub for testing the fix."""
from huggingface_hub import HfApi, create_repo
from pathlib import Path
import os
def upload_test_model():
# Get your username
api = HfApi()
user_info = api.whoami()
username = "August4293"
# Model details
model_dir = "/workspaces/transformers/saved_model_v1.0"
repo_name = "test-model_v1.0" # Using dash instead of dot for repo name
repo_id = f"{username}/{repo_name}"
print(f"Uploading model from {model_dir} to {repo_id}")
# Create repository
try:
create_repo(repo_id, exist_ok=True, private=True)
print(f"✓ Repository {repo_id} created/exists")
except Exception as e:
print(f"Repository creation: {e}")
# Upload all files
try:
api.upload_folder(
folder_path=model_dir,
repo_id=repo_id,
repo_type="model"
)
print(f"✓ Model uploaded successfully to https://huggingface.co/{repo_id}")
print(f"✓ Use repo_id: '{repo_id}' in tests")
return repo_id
except Exception as e:
print(f"Upload failed: {e}")
return None
if __name__ == "__main__":
upload_test_model()