maskil commited on
Commit
4836e99
·
verified ·
1 Parent(s): 39c43e1

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -243,8 +243,12 @@ def create_plot(data, label, reg_p, ai_p, overlap):
243
  tag = " ✅ OVERLAP" if overlap else ""
244
  fig.update_layout(title=f"{label}{tag}",
245
  xaxis_title='Drive Amplitude (a.u.)', yaxis_title='Signal (a.u.)',
246
- height=650, margin=dict(l=60, r=40, t=60, b=60),
247
- legend=dict(x=0.01, y=0.99), font=dict(size=13),
 
 
 
 
248
  paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
249
  return fig
250
  except Exception as e:
@@ -388,7 +392,7 @@ def _empty_ws(msg=""):
388
  def fetch_next(username):
389
  if not username or not username.strip():
390
  return _empty_ws("⚠ Enter your username first.")
391
- username = username.strip()
392
  if MONGO_COL is None:
393
  return _empty_ws("❌ MongoDB not connected.")
394
 
@@ -443,7 +447,7 @@ def submit_feedback(username, doc_id, overlap, model_preds,
443
  data_r, c_data, fit_s, fit_reg, fit_ai, c_single, c_reg, c_ai):
444
  if not username or not username.strip():
445
  return _empty_ws("⚠ Enter your username.")
446
- username = username.strip()
447
  if doc_id is None:
448
  return _empty_ws("⚠ No experiment loaded. Fetch first.")
449
  if MONGO_COL is None:
@@ -596,7 +600,7 @@ def _format_votes(evals, overlap):
596
  def fetch_conflict(username):
597
  if not username or not username.strip():
598
  return _empty_cr("⚠ Enter your username.")
599
- username = username.strip()
600
  if MONGO_COL is None:
601
  return _empty_cr("❌ MongoDB not connected.")
602
  doc = MONGO_COL.find_one({'status': 'conflict'})
@@ -628,7 +632,7 @@ def fetch_conflict(username):
628
  def concede_vote(username, doc_id, evals_state):
629
  if not username or not doc_id or not evals_state:
630
  return _empty_cr("⚠ Invalid state.")
631
- username = username.strip()
632
  other = next((ev for ev in evals_state if ev.get('username') != username), None)
633
  if not other:
634
  return _empty_cr("⚠ Could not find peer's vote.")
@@ -651,7 +655,7 @@ def submit_tiebreaker(username, doc_id, overlap, evals_state,
651
  tb_data, tb_fit_s, tb_fit_r, tb_fit_a):
652
  if not username or not doc_id:
653
  return _empty_cr("⚠ Invalid state.")
654
- username = username.strip()
655
  d = RATING_MAP.get(tb_data)
656
  if d is None:
657
  return _empty_cr("⚠ Rate Data Quality.")
@@ -776,12 +780,15 @@ def build_ui():
776
 
777
  ws_status = gr.Markdown("")
778
 
779
- # Plot + sidebar
 
 
 
780
  with gr.Row():
781
- ws_plot = gr.Plot(scale=3)
782
  with gr.Column(scale=1):
783
  ws_info = gr.Markdown("")
784
  ws_ov_msg = gr.Markdown("")
 
785
  ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
786
 
787
  gr.Markdown("---")
 
243
  tag = " ✅ OVERLAP" if overlap else ""
244
  fig.update_layout(title=f"{label}{tag}",
245
  xaxis_title='Drive Amplitude (a.u.)', yaxis_title='Signal (a.u.)',
246
+ autosize=True, height=580,
247
+ margin=dict(l=60, r=160, t=60, b=60),
248
+ legend=dict(x=1.02, y=1, xanchor='left', yanchor='top',
249
+ bgcolor='rgba(255,255,255,0.8)', borderwidth=1),
250
+ font=dict(size=13),
251
+ xaxis=dict(autorange=True), yaxis=dict(autorange=True),
252
  paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)')
253
  return fig
254
  except Exception as e:
 
392
  def fetch_next(username):
393
  if not username or not username.strip():
394
  return _empty_ws("⚠ Enter your username first.")
395
+ username = username.strip().title()
396
  if MONGO_COL is None:
397
  return _empty_ws("❌ MongoDB not connected.")
398
 
 
447
  data_r, c_data, fit_s, fit_reg, fit_ai, c_single, c_reg, c_ai):
448
  if not username or not username.strip():
449
  return _empty_ws("⚠ Enter your username.")
450
+ username = username.strip().title()
451
  if doc_id is None:
452
  return _empty_ws("⚠ No experiment loaded. Fetch first.")
453
  if MONGO_COL is None:
 
600
  def fetch_conflict(username):
601
  if not username or not username.strip():
602
  return _empty_cr("⚠ Enter your username.")
603
+ username = username.strip().title()
604
  if MONGO_COL is None:
605
  return _empty_cr("❌ MongoDB not connected.")
606
  doc = MONGO_COL.find_one({'status': 'conflict'})
 
632
  def concede_vote(username, doc_id, evals_state):
633
  if not username or not doc_id or not evals_state:
634
  return _empty_cr("⚠ Invalid state.")
635
+ username = username.strip().title()
636
  other = next((ev for ev in evals_state if ev.get('username') != username), None)
637
  if not other:
638
  return _empty_cr("⚠ Could not find peer's vote.")
 
655
  tb_data, tb_fit_s, tb_fit_r, tb_fit_a):
656
  if not username or not doc_id:
657
  return _empty_cr("⚠ Invalid state.")
658
+ username = username.strip().title()
659
  d = RATING_MAP.get(tb_data)
660
  if d is None:
661
  return _empty_cr("⚠ Rate Data Quality.")
 
780
 
781
  ws_status = gr.Markdown("")
782
 
783
+ # Graph full width
784
+ ws_plot = gr.Plot()
785
+
786
+ # Experiment info + model confidence below graph
787
  with gr.Row():
 
788
  with gr.Column(scale=1):
789
  ws_info = gr.Markdown("")
790
  ws_ov_msg = gr.Markdown("")
791
+ with gr.Column(scale=2):
792
  ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
793
 
794
  gr.Markdown("---")