Erinaldordso commited on
Commit
40c4fef
·
verified ·
1 Parent(s): 914be90

fix: bound the waits that could freeze the learn loop (app.py)

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -899,6 +899,30 @@ def voyager_status():
899
  return data
900
 
901
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
  @api.get("/gemini-bot/status")
903
  def gemini_bot_status():
904
  return GEMINI_BOT.status()
 
899
  return data
900
 
901
 
902
+ @api.get("/voyager/log")
903
+ def voyager_log(lines: int = 200, find: str | None = None):
904
+ """Expose the runner log.
905
+
906
+ /voyager/status deliberately drops log_tail: that payload is polled by the
907
+ dashboard and the log is large. Dropping it there left the loop's own
908
+ traceback unobservable from outside the Space -- the Hugging Face log
909
+ stream can lag hours behind, so a wedged runner looked identical to a
910
+ healthy one. This endpoint reads the same file the status builds from, on
911
+ demand, without changing the status contract.
912
+ """
913
+ lines = max(1, min(int(lines or 200), 5000))
914
+ tail = VOYAGER.tail(lines)
915
+ if find:
916
+ kept = [row for row in tail.splitlines() if find in row]
917
+ tail = "\n".join(kept)
918
+ return {
919
+ "lines": lines,
920
+ "find": find,
921
+ "bytes": len(tail),
922
+ "log": tail,
923
+ }
924
+
925
+
926
  @api.get("/gemini-bot/status")
927
  def gemini_bot_status():
928
  return GEMINI_BOT.status()