Add Space setup guide
Browse files- HUGGINGFACE_SPACE_SETUP_GUIDE.md +18 -20
HUGGINGFACE_SPACE_SETUP_GUIDE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
# π Hugging Face Space Setup Guide for OpenLLM Training (
|
| 2 |
|
| 3 |
-
This guide will help you set up proper authentication for Hugging Face Spaces using
|
| 4 |
|
| 5 |
## π― Overview
|
| 6 |
|
|
@@ -16,26 +16,24 @@ The issue you encountered was that training completed successfully in Hugging Fa
|
|
| 16 |
4. Select "Write" role for full access
|
| 17 |
5. Copy the generated token
|
| 18 |
|
| 19 |
-
### Step 2: Set Up
|
| 20 |
|
| 21 |
-
1. Go to your
|
| 22 |
```
|
| 23 |
-
https://
|
| 24 |
```
|
| 25 |
|
| 26 |
-
2.
|
| 27 |
|
| 28 |
-
3.
|
| 29 |
|
| 30 |
-
4.
|
| 31 |
-
|
| 32 |
-
5. Add a new secret:
|
| 33 |
- **Name**: `HF_TOKEN`
|
| 34 |
-
- **Value**: Your Hugging Face token from Step 1
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
**Note**:
|
| 39 |
|
| 40 |
### Step 3: Verify Authentication in Your Space
|
| 41 |
|
|
@@ -47,15 +45,15 @@ import os
|
|
| 47 |
from huggingface_hub import HfApi, whoami
|
| 48 |
|
| 49 |
def verify_space_auth():
|
| 50 |
-
"""Verify authentication is working in the Space using
|
| 51 |
-
print("π Verifying Space Authentication (
|
| 52 |
|
| 53 |
-
# Check if HF_TOKEN is set (from
|
| 54 |
token = os.getenv("HF_TOKEN")
|
| 55 |
if not token:
|
| 56 |
print("β HF_TOKEN not found in Space environment")
|
| 57 |
-
print(" - Please set HF_TOKEN in your
|
| 58 |
-
print(" - Go to
|
| 59 |
return False
|
| 60 |
|
| 61 |
try:
|
|
@@ -69,7 +67,7 @@ def verify_space_auth():
|
|
| 69 |
print(f"β
Authentication successful!")
|
| 70 |
print(f" - Username: {username}")
|
| 71 |
print(f" - Token: {token[:8]}...{token[-4:]}")
|
| 72 |
-
print(f" - Source:
|
| 73 |
|
| 74 |
# Test API access
|
| 75 |
api = HfApi()
|
|
@@ -96,7 +94,7 @@ from huggingface_hub import HfApi, login, create_repo
|
|
| 96 |
import json
|
| 97 |
|
| 98 |
class SpaceTrainingManager:
|
| 99 |
-
"""Manages training and upload in Hugging Face Spaces using
|
| 100 |
|
| 101 |
def __init__(self):
|
| 102 |
self.api = None
|
|
|
|
| 1 |
+
# π Hugging Face Space Setup Guide for OpenLLM Training (HF Access Token)
|
| 2 |
|
| 3 |
+
This guide will help you set up proper authentication for Hugging Face Spaces using HF access token so that your OpenLLM training and model uploads work correctly.
|
| 4 |
|
| 5 |
## π― Overview
|
| 6 |
|
|
|
|
| 16 |
4. Select "Write" role for full access
|
| 17 |
5. Copy the generated token
|
| 18 |
|
| 19 |
+
### Step 2: Set Up HF Access Token in Space Settings
|
| 20 |
|
| 21 |
+
1. Go to your Hugging Face Space settings:
|
| 22 |
```
|
| 23 |
+
https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME/settings
|
| 24 |
```
|
| 25 |
|
| 26 |
+
2. Navigate to "Repository secrets" section
|
| 27 |
|
| 28 |
+
3. Click "New secret"
|
| 29 |
|
| 30 |
+
4. Add a new secret:
|
|
|
|
|
|
|
| 31 |
- **Name**: `HF_TOKEN`
|
| 32 |
+
- **Value**: Your Hugging Face access token from Step 1 (starts with `hf_`)
|
| 33 |
|
| 34 |
+
5. Click "Add secret"
|
| 35 |
|
| 36 |
+
**Note**: This token will be automatically available to your Space as the `HF_TOKEN` environment variable.
|
| 37 |
|
| 38 |
### Step 3: Verify Authentication in Your Space
|
| 39 |
|
|
|
|
| 45 |
from huggingface_hub import HfApi, whoami
|
| 46 |
|
| 47 |
def verify_space_auth():
|
| 48 |
+
"""Verify authentication is working in the Space using HF access token."""
|
| 49 |
+
print("π Verifying Space Authentication (HF Access Token)")
|
| 50 |
|
| 51 |
+
# Check if HF_TOKEN is set (from Space settings)
|
| 52 |
token = os.getenv("HF_TOKEN")
|
| 53 |
if not token:
|
| 54 |
print("β HF_TOKEN not found in Space environment")
|
| 55 |
+
print(" - Please set HF_TOKEN in your Space settings")
|
| 56 |
+
print(" - Go to Space settings β Repository secrets")
|
| 57 |
return False
|
| 58 |
|
| 59 |
try:
|
|
|
|
| 67 |
print(f"β
Authentication successful!")
|
| 68 |
print(f" - Username: {username}")
|
| 69 |
print(f" - Token: {token[:8]}...{token[-4:]}")
|
| 70 |
+
print(f" - Source: HF access token in Space settings")
|
| 71 |
|
| 72 |
# Test API access
|
| 73 |
api = HfApi()
|
|
|
|
| 94 |
import json
|
| 95 |
|
| 96 |
class SpaceTrainingManager:
|
| 97 |
+
"""Manages training and upload in Hugging Face Spaces using HF access token."""
|
| 98 |
|
| 99 |
def __init__(self):
|
| 100 |
self.api = None
|