Spaces:
Sleeping
Sleeping
Add Space landing endpoint and hub checkpoint push
Browse files- .gitignore +4 -0
- incident_commander_env/server/app.py +26 -2
- incident_commander_env/training.py +7 -1
.gitignore
CHANGED
|
@@ -13,3 +13,7 @@ outputs/*
|
|
| 13 |
wandb/
|
| 14 |
*.egg-info/
|
| 15 |
.env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
wandb/
|
| 14 |
*.egg-info/
|
| 15 |
.env
|
| 16 |
+
|
| 17 |
+
# Keep huge raw HF logs local; commit summaries instead.
|
| 18 |
+
outputs/logs/hf_job_*_logs.txt
|
| 19 |
+
|
incident_commander_env/server/app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
|
| 3 |
from typing import Any
|
| 4 |
|
|
@@ -10,6 +10,26 @@ def create_incident_commander_environment() -> IncidentCommanderEnvironment:
|
|
| 10 |
return IncidentCommanderEnvironment()
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
try:
|
| 14 |
from openenv.core.env_server import create_app
|
| 15 |
|
|
@@ -20,12 +40,17 @@ try:
|
|
| 20 |
env_name="incident_commander_env",
|
| 21 |
max_concurrent_envs=64,
|
| 22 |
)
|
|
|
|
| 23 |
except Exception:
|
| 24 |
from fastapi import FastAPI
|
| 25 |
|
| 26 |
app = FastAPI(title="Incident Commander RL Arena")
|
| 27 |
_env = create_incident_commander_environment()
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
@app.get("/health")
|
| 30 |
def health() -> dict[str, str]:
|
| 31 |
return {"status": "healthy"}
|
|
@@ -49,4 +74,3 @@ def main() -> None:
|
|
| 49 |
import uvicorn
|
| 50 |
|
| 51 |
uvicorn.run("server.app:app", host="0.0.0.0", port=8000)
|
| 52 |
-
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
|
| 3 |
from typing import Any
|
| 4 |
|
|
|
|
| 10 |
return IncidentCommanderEnvironment()
|
| 11 |
|
| 12 |
|
| 13 |
+
def root_landing() -> dict[str, Any]:
|
| 14 |
+
return {
|
| 15 |
+
"name": "Incident Commander RL Arena",
|
| 16 |
+
"status": "running",
|
| 17 |
+
"description": "OpenEnv environment where LLM agents investigate incidents, choose safe mitigations, and write stakeholder updates.",
|
| 18 |
+
"endpoints": {
|
| 19 |
+
"health": "/health",
|
| 20 |
+
"reset": "/reset",
|
| 21 |
+
"step": "/step",
|
| 22 |
+
"state": "/state",
|
| 23 |
+
"docs": "/docs",
|
| 24 |
+
},
|
| 25 |
+
"submission": {
|
| 26 |
+
"training_job": "https://huggingface.co/jobs/Dar3devil/69ed03a7d2c8bd8662bce22d",
|
| 27 |
+
"best_logged_reward": 0.23,
|
| 28 |
+
"final_logged_reward": 0.2125,
|
| 29 |
+
},
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
|
| 33 |
try:
|
| 34 |
from openenv.core.env_server import create_app
|
| 35 |
|
|
|
|
| 40 |
env_name="incident_commander_env",
|
| 41 |
max_concurrent_envs=64,
|
| 42 |
)
|
| 43 |
+
app.get("/")(root_landing)
|
| 44 |
except Exception:
|
| 45 |
from fastapi import FastAPI
|
| 46 |
|
| 47 |
app = FastAPI(title="Incident Commander RL Arena")
|
| 48 |
_env = create_incident_commander_environment()
|
| 49 |
|
| 50 |
+
@app.get("/")
|
| 51 |
+
def root() -> dict[str, Any]:
|
| 52 |
+
return root_landing()
|
| 53 |
+
|
| 54 |
@app.get("/health")
|
| 55 |
def health() -> dict[str, str]:
|
| 56 |
return {"status": "healthy"}
|
|
|
|
| 74 |
import uvicorn
|
| 75 |
|
| 76 |
uvicorn.run("server.app:app", host="0.0.0.0", port=8000)
|
|
|
incident_commander_env/training.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
|
| 3 |
import argparse
|
| 4 |
from pathlib import Path
|
|
@@ -144,6 +144,8 @@ def main() -> None:
|
|
| 144 |
parser.add_argument("--gradient-accumulation-steps", type=int, default=16)
|
| 145 |
parser.add_argument("--enable-thinking", action="store_true")
|
| 146 |
parser.add_argument("--no-vllm", action="store_true", help="Fallback for T4/Colab installs where vLLM fails.")
|
|
|
|
|
|
|
| 147 |
args = parser.parse_args()
|
| 148 |
|
| 149 |
from trl import GRPOConfig, GRPOTrainer
|
|
@@ -167,6 +169,8 @@ def main() -> None:
|
|
| 167 |
vllm_mode="colocate",
|
| 168 |
chat_template_kwargs={"enable_thinking": args.enable_thinking},
|
| 169 |
report_to=[],
|
|
|
|
|
|
|
| 170 |
)
|
| 171 |
trainer = GRPOTrainer(
|
| 172 |
model=args.model,
|
|
@@ -177,6 +181,8 @@ def main() -> None:
|
|
| 177 |
)
|
| 178 |
trainer.train()
|
| 179 |
trainer.save_model(str(output_dir / "final"))
|
|
|
|
|
|
|
| 180 |
|
| 181 |
|
| 182 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
|
| 3 |
import argparse
|
| 4 |
from pathlib import Path
|
|
|
|
| 144 |
parser.add_argument("--gradient-accumulation-steps", type=int, default=16)
|
| 145 |
parser.add_argument("--enable-thinking", action="store_true")
|
| 146 |
parser.add_argument("--no-vllm", action="store_true", help="Fallback for T4/Colab installs where vLLM fails.")
|
| 147 |
+
parser.add_argument("--push-to-hub", action="store_true", help="Push final model/checkpoint to the Hugging Face Hub.")
|
| 148 |
+
parser.add_argument("--hub-model-id", default=None, help="Target Hub repo id for --push-to-hub.")
|
| 149 |
args = parser.parse_args()
|
| 150 |
|
| 151 |
from trl import GRPOConfig, GRPOTrainer
|
|
|
|
| 169 |
vllm_mode="colocate",
|
| 170 |
chat_template_kwargs={"enable_thinking": args.enable_thinking},
|
| 171 |
report_to=[],
|
| 172 |
+
push_to_hub=args.push_to_hub,
|
| 173 |
+
hub_model_id=args.hub_model_id,
|
| 174 |
)
|
| 175 |
trainer = GRPOTrainer(
|
| 176 |
model=args.model,
|
|
|
|
| 181 |
)
|
| 182 |
trainer.train()
|
| 183 |
trainer.save_model(str(output_dir / "final"))
|
| 184 |
+
if args.push_to_hub:
|
| 185 |
+
trainer.push_to_hub(commit_message="Add incident commander GRPO checkpoint")
|
| 186 |
|
| 187 |
|
| 188 |
if __name__ == "__main__":
|