Dev-the-dev91 commited on
Commit
45f868c
·
verified ·
1 Parent(s): a3eefab

Update HF Jobs training script

Browse files
Files changed (1) hide show
  1. scripts/hf_jobs_train_syllabus.py +14 -1
scripts/hf_jobs_train_syllabus.py CHANGED
@@ -44,8 +44,21 @@ def run(cmd: list[str], *, cwd: Path | None = None) -> None:
44
  subprocess.run(cmd, check=True, cwd=cwd)
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  def main() -> None:
48
- api = HfApi()
 
49
  who = api.whoami()["name"]
50
  print(f"Hub user: {who}")
51
  print(f"Dataset: {DATASET_REPO}")
 
44
  subprocess.run(cmd, check=True, cwd=cwd)
45
 
46
 
47
+ def _require_hub_token() -> str:
48
+ token = os.environ.get("HF_TOKEN", "").strip()
49
+ if not token or token in ("$HF_TOKEN", "${HF_TOKEN}"):
50
+ raise SystemExit(
51
+ "HF_TOKEN is missing or still the literal '$HF_TOKEN' placeholder.\n"
52
+ "Resubmit with: uv run python scripts/submit_hf_training_job.py\n"
53
+ "Or CLI: hf jobs uv run --secrets HF_TOKEN <script-url>\n"
54
+ "(Do not pass secrets={'HF_TOKEN': '$HF_TOKEN'} from Python — use the real token.)"
55
+ )
56
+ return token
57
+
58
+
59
  def main() -> None:
60
+ token = _require_hub_token()
61
+ api = HfApi(token=token)
62
  who = api.whoami()["name"]
63
  print(f"Hub user: {who}")
64
  print(f"Dataset: {DATASET_REPO}")