YashashMathur commited on
Commit
206f794
Β·
verified Β·
1 Parent(s): acb482d

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. hf_training/train.py +15 -2
hf_training/train.py CHANGED
@@ -17,13 +17,26 @@ from huggingface_hub import login, HfApi, hf_hub_download, snapshot_download
17
  from peft import set_peft_model_state_dict
18
 
19
  # ─── Auth & Config ────────────────────────────────────────────────────────────
20
- HF_TOKEN = os.environ["HF_TOKEN"]
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  HF_USERNAME = os.environ.get("HF_USERNAME", "YashashMathur")
22
  STEP50_REPO = f"{HF_USERNAME}/aegis-step50"
23
  CKPT_REPO = f"{HF_USERNAME}/aegis-training-checkpoints"
24
 
25
  login(token=HF_TOKEN)
26
- api = HfApi()
27
 
28
  # Optional WandB Logging
29
  WANDB_API_KEY = os.environ.get("WANDB_API_KEY")
 
17
  from peft import set_peft_model_state_dict
18
 
19
  # ─── Auth & Config ────────────────────────────────────────────────────────────
20
+ HF_TOKEN = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
21
+
22
+ if not HF_TOKEN:
23
+ print("\n" + "="*80)
24
+ print(" MISSING HF_TOKEN SECRET ".center(80, "#"))
25
+ print(" 1. Go to your Space 'Settings' tab. ".center(80))
26
+ print(" 2. Find 'Variables and Secrets' section. ".center(80))
27
+ print(" 3. Click 'New Secret', name it 'HF_TOKEN'. ".center(80))
28
+ print(" 4. Paste your WRITE-access token (huggingface.co/settings/tokens). ".center(80))
29
+ print(" 5. Restart the Space. ".center(80))
30
+ print("".center(80, "#"))
31
+ print("="*80 + "\n")
32
+ sys.exit(0) # Exit gracefully
33
+
34
  HF_USERNAME = os.environ.get("HF_USERNAME", "YashashMathur")
35
  STEP50_REPO = f"{HF_USERNAME}/aegis-step50"
36
  CKPT_REPO = f"{HF_USERNAME}/aegis-training-checkpoints"
37
 
38
  login(token=HF_TOKEN)
39
+ api = HfApi(token=HF_TOKEN)
40
 
41
  # Optional WandB Logging
42
  WANDB_API_KEY = os.environ.get("WANDB_API_KEY")