Spaces:
Runtime error
Runtime error
Commit Β·
aa154f2
1
Parent(s): 175b600
pre-deployment fixes for HF Spaces
Browse files- app.py +5 -7
- colab/train_colab.py +3 -2
- 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 |
-
|
| 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 |
-
|
|
|
|
| 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 |
-
|
|
|
|
| 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 |
-
|
|
|
|
| 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
|
| 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
|