Spaces:
Paused
Paused
Commit Β·
4bad83e
1
Parent(s): f9a6e3e
Fix create_repo naming error with huggingface_hub 1.x
Browse filesNewer huggingface_hub rejects 'user/repo' as repo_id in create_repo
(the slash fails server-side name validation). Pass only the repo name
and set the token on HfApi() instead so the namespace is inferred.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -63,8 +63,10 @@ def _training_thread():
|
|
| 63 |
|
| 64 |
if not HF_REPO:
|
| 65 |
from huggingface_hub import whoami
|
| 66 |
-
username = whoami(token=HF_TOKEN)["name"]
|
| 67 |
HF_REPO = f"{username}/spindleflow-rl"
|
|
|
|
|
|
|
| 68 |
_log(f"Model will be pushed to: https://huggingface.co/{HF_REPO}")
|
| 69 |
|
| 70 |
REPO_DIR = "/home/user/app"
|
|
@@ -78,9 +80,12 @@ def _training_thread():
|
|
| 78 |
|
| 79 |
# ββ Create HF repo early so periodic pushes can start ββ
|
| 80 |
from huggingface_hub import HfApi, CommitOperationAdd
|
| 81 |
-
api = HfApi()
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# ββ Patch env for simulate_specialists ββββββββββββββ
|
| 86 |
_log("Loading environment...")
|
|
|
|
| 63 |
|
| 64 |
if not HF_REPO:
|
| 65 |
from huggingface_hub import whoami
|
| 66 |
+
username = whoami(token=HF_TOKEN)["name"].strip()
|
| 67 |
HF_REPO = f"{username}/spindleflow-rl"
|
| 68 |
+
else:
|
| 69 |
+
HF_REPO = HF_REPO.strip()
|
| 70 |
_log(f"Model will be pushed to: https://huggingface.co/{HF_REPO}")
|
| 71 |
|
| 72 |
REPO_DIR = "/home/user/app"
|
|
|
|
| 80 |
|
| 81 |
# ββ Create HF repo early so periodic pushes can start ββ
|
| 82 |
from huggingface_hub import HfApi, CommitOperationAdd
|
| 83 |
+
api = HfApi(token=HF_TOKEN)
|
| 84 |
+
# Pass only the repo name (no namespace) β newer huggingface_hub
|
| 85 |
+
# rejects "user/repo" as the repo_id in create_repo.
|
| 86 |
+
_repo_name = HF_REPO.split("/")[-1]
|
| 87 |
+
api.create_repo(repo_id=_repo_name, repo_type="model",
|
| 88 |
+
exist_ok=True)
|
| 89 |
|
| 90 |
# ββ Patch env for simulate_specialists ββββββββββββββ
|
| 91 |
_log("Loading environment...")
|