garvitsachdeva Claude Sonnet 4.6 commited on
Commit
4bad83e
Β·
1 Parent(s): f9a6e3e

Fix create_repo naming error with huggingface_hub 1.x

Browse files

Newer 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>

Files changed (1) hide show
  1. app.py +9 -4
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
- api.create_repo(repo_id=HF_REPO, repo_type="model",
83
- exist_ok=True, token=HF_TOKEN)
 
 
 
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...")