Add /smoke endpoint for quick pipeline testing
Browse files
app.py
CHANGED
|
@@ -12,14 +12,14 @@ training_status = {
|
|
| 12 |
"log": ""
|
| 13 |
}
|
| 14 |
|
| 15 |
-
def run_training():
|
| 16 |
global training_status
|
| 17 |
training_status["status"] = "running"
|
| 18 |
-
training_status["log"] = "Started training...\n"
|
| 19 |
|
| 20 |
# Run the trainer script and capture output
|
| 21 |
process = subprocess.Popen(
|
| 22 |
-
["python", "-m", "trainer.train", "--steps",
|
| 23 |
stdout=subprocess.PIPE,
|
| 24 |
stderr=subprocess.STDOUT,
|
| 25 |
text=True,
|
|
@@ -40,7 +40,8 @@ def read_root():
|
|
| 40 |
"message": "CodeForge GRPO Training Node Active",
|
| 41 |
"status": training_status["status"],
|
| 42 |
"endpoints": {
|
| 43 |
-
"/start": "Start training (
|
|
|
|
| 44 |
"/logs": "View live training logs"
|
| 45 |
}
|
| 46 |
}
|
|
@@ -50,10 +51,20 @@ def start_training(background_tasks: BackgroundTasks):
|
|
| 50 |
if training_status["status"] == "running":
|
| 51 |
return {"message": "Training is already running!"}
|
| 52 |
|
| 53 |
-
# Run
|
| 54 |
-
thread = threading.Thread(target=run_training)
|
| 55 |
thread.start()
|
| 56 |
-
return {"message": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
@app.get("/logs", response_class=PlainTextResponse)
|
| 59 |
def get_logs():
|
|
|
|
| 12 |
"log": ""
|
| 13 |
}
|
| 14 |
|
| 15 |
+
def run_training(steps: int = 300):
|
| 16 |
global training_status
|
| 17 |
training_status["status"] = "running"
|
| 18 |
+
training_status["log"] = f"Started training for {steps} steps...\n"
|
| 19 |
|
| 20 |
# Run the trainer script and capture output
|
| 21 |
process = subprocess.Popen(
|
| 22 |
+
["python", "-m", "trainer.train", "--steps", str(steps)],
|
| 23 |
stdout=subprocess.PIPE,
|
| 24 |
stderr=subprocess.STDOUT,
|
| 25 |
text=True,
|
|
|
|
| 40 |
"message": "CodeForge GRPO Training Node Active",
|
| 41 |
"status": training_status["status"],
|
| 42 |
"endpoints": {
|
| 43 |
+
"/start": "Start full training (300 steps)",
|
| 44 |
+
"/smoke": "Run smoke test (5 steps)",
|
| 45 |
"/logs": "View live training logs"
|
| 46 |
}
|
| 47 |
}
|
|
|
|
| 51 |
if training_status["status"] == "running":
|
| 52 |
return {"message": "Training is already running!"}
|
| 53 |
|
| 54 |
+
# Run full 300 steps in background
|
| 55 |
+
thread = threading.Thread(target=run_training, args=(300,))
|
| 56 |
thread.start()
|
| 57 |
+
return {"message": "Full training started! Go to /logs to monitor."}
|
| 58 |
+
|
| 59 |
+
@app.post("/smoke")
|
| 60 |
+
def start_smoke_test(background_tasks: BackgroundTasks):
|
| 61 |
+
if training_status["status"] == "running":
|
| 62 |
+
return {"message": "Training is already running!"}
|
| 63 |
+
|
| 64 |
+
# Run just 5 steps for a quick smoke test
|
| 65 |
+
thread = threading.Thread(target=run_training, args=(5,))
|
| 66 |
+
thread.start()
|
| 67 |
+
return {"message": "Smoke test (5 steps) started! Go to /logs to monitor."}
|
| 68 |
|
| 69 |
@app.get("/logs", response_class=PlainTextResponse)
|
| 70 |
def get_logs():
|