File size: 2,109 Bytes
f0d12fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
from huggingface_hub import HfApi

# Initialize the Hugging Face API
api = HfApi()

# Repository details - using the agentica-org namespace as requested
repo_id = "agentica-org/DeepSWE-Preview-FP8"  # Using the organization namespace
local_dir = "/home/op/DeepSWE-Preview-FP8"

# Files to upload (excluding serving scripts)
files_to_upload = [
    "README.md",
    "added_tokens.json",
    "chat_template.jinja",
    "config.json",
    "generation_config.json",
    "merges.txt",
    "model-00001-of-00007.safetensors",
    "model-00002-of-00007.safetensors",
    "model-00003-of-00007.safetensors",
    "model-00004-of-00007.safetensors",
    "model-00005-of-00007.safetensors",
    "model-00006-of-00007.safetensors",
    "model-00007-of-00007.safetensors",
    "model.safetensors.index.json",
    "special_tokens_map.json",
    "tokenizer_config.json",
    "tokenizer.json",
    "vocab.json"
]

def upload_model():
    print(f"Creating repository {repo_id}...")
    
    # Create the repository if it doesn't exist
    try:
        api.create_repo(repo_id=repo_id, repo_type="model", private=False, exist_ok=True)
        print(f"Repository {repo_id} created or already exists.")
    except Exception as e:
        print(f"Error creating repository: {e}")
        return
    
    # Upload files
    print("Uploading files...")
    for file_name in files_to_upload:
        file_path = os.path.join(local_dir, file_name)
        if os.path.exists(file_path):
            try:
                print(f"Uploading {file_name}...")
                api.upload_file(
                    path_or_fileobj=file_path,
                    path_in_repo=file_name,
                    repo_id=repo_id,
                    repo_type="model"
                )
                print(f"Uploaded {file_name}")
            except Exception as e:
                print(f"Error uploading {file_name}: {e}")
        else:
            print(f"File not found: {file_path}")
    
    print("Upload completed!")
    print(f"Model uploaded to: https://huggingface.co/{repo_id}")

if __name__ == "__main__":
    upload_model()