File size: 1,244 Bytes
6055811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""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()