Delete upload.py
Browse files
upload.py
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from huggingface_hub import HfApi
|
3 |
-
import time
|
4 |
-
|
5 |
-
def upload_with_retry(folder_path, repo_id, max_retries=10):
|
6 |
-
api = HfApi()
|
7 |
-
|
8 |
-
# 获取所有文件
|
9 |
-
files = []
|
10 |
-
for root, _, filenames in os.walk(folder_path):
|
11 |
-
for filename in filenames:
|
12 |
-
if not any(pattern in filename for pattern in [".git"]):
|
13 |
-
full_path = os.path.join(root, filename)
|
14 |
-
relative_path = os.path.relpath(full_path, folder_path)
|
15 |
-
files.append((full_path, relative_path))
|
16 |
-
|
17 |
-
print(f"Found {len(files)} files to upload")
|
18 |
-
|
19 |
-
for file_path, path_in_repo in files:
|
20 |
-
for attempt in range(max_retries):
|
21 |
-
try:
|
22 |
-
print(f"Uploading {path_in_repo} (Attempt {attempt + 1} of {max_retries})")
|
23 |
-
api.upload_file(
|
24 |
-
path_or_fileobj=file_path,
|
25 |
-
path_in_repo=path_in_repo,
|
26 |
-
repo_id=repo_id,
|
27 |
-
repo_type="model"
|
28 |
-
)
|
29 |
-
print(f"Successfully uploaded {path_in_repo}")
|
30 |
-
break
|
31 |
-
except Exception as e:
|
32 |
-
print(f"Error uploading {path_in_repo}: {e}")
|
33 |
-
if attempt < max_retries - 1:
|
34 |
-
wait_time = 10 * (attempt + 1)
|
35 |
-
print(f"Retrying in {wait_time} seconds...")
|
36 |
-
time.sleep(wait_time)
|
37 |
-
else:
|
38 |
-
print(f"Max retries reached. Failed to upload {path_in_repo}")
|
39 |
-
|
40 |
-
# 使用
|
41 |
-
upload_with_retry(".", "Neph0s/CoSER-Llama-3.1-70B")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|