Upload openllm_training_with_auth.py with huggingface_hub
Browse files
openllm_training_with_auth.py
CHANGED
|
@@ -122,9 +122,22 @@ GPL-3.0
|
|
| 122 |
"""Upload trained model to Hugging Face Hub."""
|
| 123 |
print(f"π€ Uploading model to Hugging Face Hub...")
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
# Create model repository name
|
| 126 |
repo_name = f"openllm-{model_size}-{steps}steps"
|
| 127 |
repo_id = f"{self.username}/{repo_name}"
|
|
|
|
| 128 |
|
| 129 |
try:
|
| 130 |
# Create repository
|
|
@@ -178,7 +191,20 @@ GPL-3.0
|
|
| 178 |
print(f"=" * 40)
|
| 179 |
print(f"π Model Size: {model_size}")
|
| 180 |
print(f"π Training Steps: {steps}")
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
# Simulate training process
|
| 184 |
print(f"\nπ Step 1: Initializing training...")
|
|
|
|
| 122 |
"""Upload trained model to Hugging Face Hub."""
|
| 123 |
print(f"π€ Uploading model to Hugging Face Hub...")
|
| 124 |
|
| 125 |
+
# Ensure username is set correctly before upload
|
| 126 |
+
if not self.username or self.username == "unknown" or self.username == "None":
|
| 127 |
+
try:
|
| 128 |
+
from huggingface_hub import whoami
|
| 129 |
+
user_info = whoami()
|
| 130 |
+
self.username = user_info.get("name", "lemms")
|
| 131 |
+
print(f"π§ Fixed username: {self.username}")
|
| 132 |
+
except Exception as e:
|
| 133 |
+
print(f"β οΈ Could not retrieve username for upload: {e}")
|
| 134 |
+
self.username = "lemms" # Fallback to known username
|
| 135 |
+
print(f"π§ Using fallback username: {self.username}")
|
| 136 |
+
|
| 137 |
# Create model repository name
|
| 138 |
repo_name = f"openllm-{model_size}-{steps}steps"
|
| 139 |
repo_id = f"{self.username}/{repo_name}"
|
| 140 |
+
print(f"π Creating repository: {repo_id}")
|
| 141 |
|
| 142 |
try:
|
| 143 |
# Create repository
|
|
|
|
| 191 |
print(f"=" * 40)
|
| 192 |
print(f"π Model Size: {model_size}")
|
| 193 |
print(f"π Training Steps: {steps}")
|
| 194 |
+
|
| 195 |
+
# Ensure username is set correctly
|
| 196 |
+
if not self.username or self.username == "unknown":
|
| 197 |
+
try:
|
| 198 |
+
from huggingface_hub import whoami
|
| 199 |
+
user_info = whoami()
|
| 200 |
+
self.username = user_info.get("name", "lemms")
|
| 201 |
+
print(f"π€ User: {self.username} (retrieved from authentication)")
|
| 202 |
+
except Exception as e:
|
| 203 |
+
print(f"β οΈ Could not retrieve username: {e}")
|
| 204 |
+
self.username = "lemms" # Fallback to known username
|
| 205 |
+
print(f"π€ User: {self.username} (using fallback)")
|
| 206 |
+
else:
|
| 207 |
+
print(f"π€ User: {self.username}")
|
| 208 |
|
| 209 |
# Simulate training process
|
| 210 |
print(f"\nπ Step 1: Initializing training...")
|