RFTSystems commited on
Commit
b433d03
·
verified ·
1 Parent(s): 37baf66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import json
3
  import tempfile
@@ -46,7 +47,6 @@ def _new_session(
46
  cfg=cfg.to_dict(),
47
  seed=int(seed),
48
  )
49
- # record root event (step 0) as a receipt too
50
  rec.record_event(state=state, action="RESET")
51
  return {"cfg": cfg, "state": state, "rec": rec}
52
 
@@ -91,7 +91,6 @@ def ui_step(sess: Optional[Dict[str, Any]]):
91
  world, pov, status = _render(state)
92
  return sess, world, pov, status + " (done)", _receipt_tail(rec)
93
 
94
- # Agent decides action internally (simple deterministic heuristic in sim)
95
  new_state, action = step_sim(cfg, state)
96
  sess["state"] = new_state
97
  rec.record_event(state=new_state, action=action)
@@ -153,14 +152,14 @@ def ui_verify(zip_file):
153
  return json.dumps(report, indent=2)
154
 
155
 
156
- def ui_replay(zip_file, export_gif: bool, watermark: bool):
157
  if zip_file is None:
158
  return None, None, "Upload a receipt bundle ZIP."
159
 
160
  zip_path = zip_file if isinstance(zip_file, str) else zip_file.name
161
  replay = replay_from_receipt_bundle_zip(
162
  zip_path,
163
- export_gif=bool(export_gif),
164
  watermark=bool(watermark),
165
  )
166
 
@@ -220,7 +219,7 @@ with gr.Blocks(title=APP_TITLE) as demo:
220
  with gr.Tab("Replay"):
221
  replay_upload = gr.File(label="Upload receipt bundle ZIP")
222
  with gr.Row():
223
- replay_export_gif = gr.Checkbox(value=True, label="Export replay GIF")
224
  replay_watermark = gr.Checkbox(value=True, label="Watermark final hash on frames")
225
  btn_replay = gr.Button("Replay From Bundle", variant="primary")
226
  with gr.Row():
@@ -229,7 +228,6 @@ with gr.Blocks(title=APP_TITLE) as demo:
229
  replay_gif = gr.File(label="Replayed GIF (if exported)")
230
  replay_msg = gr.Textbox(label="Replay result", interactive=False)
231
 
232
- # Wiring
233
  btn_new.click(
234
  ui_new,
235
  inputs=[seed, size, walls_pct, coins, hazards, pov_radius],
@@ -268,7 +266,7 @@ with gr.Blocks(title=APP_TITLE) as demo:
268
 
269
  btn_replay.click(
270
  ui_replay,
271
- inputs=[replay_upload, replay_export_gif, replay_watermark],
272
  outputs=[replay_world, replay_pov, replay_gif, replay_msg],
273
  )
274
 
 
1
+ # app.py
2
  import os
3
  import json
4
  import tempfile
 
47
  cfg=cfg.to_dict(),
48
  seed=int(seed),
49
  )
 
50
  rec.record_event(state=state, action="RESET")
51
  return {"cfg": cfg, "state": state, "rec": rec}
52
 
 
91
  world, pov, status = _render(state)
92
  return sess, world, pov, status + " (done)", _receipt_tail(rec)
93
 
 
94
  new_state, action = step_sim(cfg, state)
95
  sess["state"] = new_state
96
  rec.record_event(state=new_state, action=action)
 
152
  return json.dumps(report, indent=2)
153
 
154
 
155
+ def ui_replay(zip_file, export_gif_flag: bool, watermark: bool):
156
  if zip_file is None:
157
  return None, None, "Upload a receipt bundle ZIP."
158
 
159
  zip_path = zip_file if isinstance(zip_file, str) else zip_file.name
160
  replay = replay_from_receipt_bundle_zip(
161
  zip_path,
162
+ export_gif_flag=bool(export_gif_flag),
163
  watermark=bool(watermark),
164
  )
165
 
 
219
  with gr.Tab("Replay"):
220
  replay_upload = gr.File(label="Upload receipt bundle ZIP")
221
  with gr.Row():
222
+ replay_export_gif_flag = gr.Checkbox(value=True, label="Export replay GIF")
223
  replay_watermark = gr.Checkbox(value=True, label="Watermark final hash on frames")
224
  btn_replay = gr.Button("Replay From Bundle", variant="primary")
225
  with gr.Row():
 
228
  replay_gif = gr.File(label="Replayed GIF (if exported)")
229
  replay_msg = gr.Textbox(label="Replay result", interactive=False)
230
 
 
231
  btn_new.click(
232
  ui_new,
233
  inputs=[seed, size, walls_pct, coins, hazards, pov_radius],
 
266
 
267
  btn_replay.click(
268
  ui_replay,
269
+ inputs=[replay_upload, replay_export_gif_flag, replay_watermark],
270
  outputs=[replay_world, replay_pov, replay_gif, replay_msg],
271
  )
272