garvitsachdeva commited on
Commit
aa154f2
Β·
1 Parent(s): 175b600

pre-deployment fixes for HF Spaces

Browse files
Files changed (3) hide show
  1. app.py +5 -7
  2. colab/train_colab.py +3 -2
  3. requirements.txt +3 -1
app.py CHANGED
@@ -89,11 +89,7 @@ def _training_thread():
89
  # ── Create HF repo early so periodic pushes can start ──
90
  from huggingface_hub import HfApi, CommitOperationAdd
91
  api = HfApi(token=HF_TOKEN)
92
- # Pass only the repo name (no namespace) β€” newer huggingface_hub
93
- # rejects "user/repo" as the repo_id in create_repo.
94
- _repo_name = HF_REPO.split("/")[-1]
95
- api.create_repo(repo_id=_repo_name, repo_type="model",
96
- exist_ok=True)
97
 
98
  # ── Patch env for simulate_specialists ──────────────
99
  _log("Loading environment...")
@@ -229,7 +225,8 @@ def _training_thread():
229
  simulate_specialists=True,
230
  )
231
 
232
- vec_env = DummyVecEnv([make_env])
 
233
  vec_env = VecNormalize(vec_env, norm_obs=True, norm_reward=True, clip_obs=10.0)
234
 
235
  _ppo = cfg.get("ppo", {})
@@ -484,6 +481,7 @@ with gr.Blocks(title="SpindleFlow RL Training", css=CSS) as demo:
484
  )
485
 
486
  refresh_btn.click(fn=_get_state, outputs=[status_box, log_box])
487
- demo.load(fn=_get_state, outputs=[status_box, log_box], every=10)
 
488
 
489
  demo.launch()
 
89
  # ── Create HF repo early so periodic pushes can start ──
90
  from huggingface_hub import HfApi, CommitOperationAdd
91
  api = HfApi(token=HF_TOKEN)
92
+ api.create_repo(repo_id=HF_REPO, repo_type="model", exist_ok=True)
 
 
 
 
93
 
94
  # ── Patch env for simulate_specialists ──────────────
95
  _log("Loading environment...")
 
225
  simulate_specialists=True,
226
  )
227
 
228
+ _n_envs = int(cfg.get("training", {}).get("n_envs", 1))
229
+ vec_env = DummyVecEnv([make_env] * _n_envs)
230
  vec_env = VecNormalize(vec_env, norm_obs=True, norm_reward=True, clip_obs=10.0)
231
 
232
  _ppo = cfg.get("ppo", {})
 
481
  )
482
 
483
  refresh_btn.click(fn=_get_state, outputs=[status_box, log_box])
484
+ timer = gr.Timer(value=10)
485
+ timer.tick(fn=_get_state, outputs=[status_box, log_box])
486
 
487
  demo.launch()
colab/train_colab.py CHANGED
@@ -421,11 +421,12 @@ print("CELL 7 done βœ“")
421
  import os, numpy as np
422
  from huggingface_hub import HfApi, CommitOperationAdd
423
 
424
- HF_REPO = "garvitsachdeva/spindleflow-rl"
 
425
  api = HfApi(token=HF_TOKEN)
426
 
427
  _tlog(f"Pushing to https://huggingface.co/{HF_REPO} ...")
428
- api.create_repo(repo_id=HF_REPO.split("/")[-1], repo_type="model", exist_ok=True)
429
 
430
  ep = reward_logger.episode_rewards
431
  readme = f"""---
 
421
  import os, numpy as np
422
  from huggingface_hub import HfApi, CommitOperationAdd
423
 
424
+ from huggingface_hub import whoami
425
+ HF_REPO = f"{whoami(token=HF_TOKEN)['name']}/spindleflow-rl"
426
  api = HfApi(token=HF_TOKEN)
427
 
428
  _tlog(f"Pushing to https://huggingface.co/{HF_REPO} ...")
429
+ api.create_repo(repo_id=HF_REPO, repo_type="model", exist_ok=True)
430
 
431
  ep = reward_logger.episode_rewards
432
  readme = f"""---
requirements.txt CHANGED
@@ -13,4 +13,6 @@ datasets>=2.19.0
13
  huggingface_hub>=0.33.5
14
  gradio>=5.50.0
15
  matplotlib>=3.8.0
16
- audioop-lts>=0.2.1
 
 
 
13
  huggingface_hub>=0.33.5
14
  gradio>=5.50.0
15
  matplotlib>=3.8.0
16
+ audioop-lts>=0.2.1; python_version>="3.13"
17
+ click>=8.0.0
18
+ python-dotenv>=1.0.0