maskil commited on
Commit
39c43e1
Β·
verified Β·
1 Parent(s): c1aea49

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -40
app.py CHANGED
@@ -243,7 +243,7 @@ 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=600, margin=dict(l=50, r=30, t=50, b=50),
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
@@ -520,8 +520,8 @@ def refresh_analytics():
520
  taggers = list(MONGO_COL.aggregate(tp))
521
  tr = "\n".join(f"| {t['_id']} | {t['c']} |" for t in taggers) or "| β€” | β€” |"
522
 
523
- clf_s = MONGO_DB['experiments_clf_success'].count_documents({}) if MONGO_DB else 0
524
- clf_f = MONGO_DB['experiments_clf_failed'].count_documents({}) if MONGO_DB else 0
525
 
526
  return f"""### πŸ“ˆ Platform Statistics
527
  | Metric | Count |
@@ -711,9 +711,7 @@ CSS = """
711
  .rating-radio label:nth-child(3):has(input:checked) {
712
  background: #22c55e !important; color: #fff !important; }
713
 
714
- .clear-btn { min-width: 36px !important; max-width: 36px !important;
715
- height: 36px !important; padding: 0 !important; font-size: 16px !important;
716
- border-radius: 8px !important; margin-top: 28px !important; }
717
  """
718
 
719
  # JavaScript to enable click-to-toggle on radio buttons
@@ -787,27 +785,22 @@ def build_ui():
787
  ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
788
 
789
  gr.Markdown("---")
790
- gr.Markdown("πŸ’‘ **Leave a rating empty = accept model prediction** (implicit agreement). "
791
- "Select an option only to **correct** the model. Click an option again or press βœ• to deselect.")
792
 
793
- # Data Quality row
794
- with gr.Row():
795
- with gr.Column(scale=9):
796
- gr.Markdown("### πŸ“Š Data Quality")
797
- ws_dr = gr.Radio(choices=RATING_CHOICES, value=None,
798
- label="Rate raw data:", elem_classes=["rating-radio"])
799
- dr_clr = gr.Button("βœ•", size="sm", elem_classes=["clear-btn"], scale=0)
800
 
 
 
 
 
801
  ws_cd = gr.Textbox(label="Data notes (optional)", lines=2)
802
 
803
  # Fit Quality β€” SINGLE (overlap)
804
  with gr.Column(visible=True) as ws_fs_col:
805
- with gr.Row():
806
- with gr.Column(scale=9):
807
- gr.Markdown("### πŸ“ Fit Quality (Combined)")
808
- ws_fs = gr.Radio(choices=RATING_CHOICES, value=None,
809
- label="Rate the fit:", elem_classes=["rating-radio"])
810
- fs_clr = gr.Button("βœ•", size="sm", elem_classes=["clear-btn"], scale=0)
811
  ws_cs = gr.Textbox(label="Fit notes (optional)", lines=2)
812
 
813
  # Fit Quality β€” DUAL (diverge)
@@ -816,32 +809,18 @@ def build_ui():
816
  with gr.Row():
817
  with gr.Column():
818
  gr.Markdown("#### 🟦 Regular Fit")
819
- with gr.Row():
820
- ws_fr = gr.Radio(choices=RATING_CHOICES, value=None,
821
- label="Regular Fit:", elem_classes=["rating-radio"],
822
- scale=9)
823
- fr_clr = gr.Button("βœ•", size="sm", elem_classes=["clear-btn"], scale=0)
824
  ws_cr = gr.Textbox(label="Regular fit notes", lines=2)
825
  with gr.Column():
826
  gr.Markdown("#### 🟩 AI Fit")
827
- with gr.Row():
828
- ws_fa = gr.Radio(choices=RATING_CHOICES, value=None,
829
- label="AI Fit:", elem_classes=["rating-radio"],
830
- scale=9)
831
- fa_clr = gr.Button("βœ•", size="sm", elem_classes=["clear-btn"], scale=0)
832
  ws_ca = gr.Textbox(label="AI fit notes", lines=2)
833
 
834
  gr.Markdown("---")
 
835
 
836
- with gr.Row():
837
- ws_reset = gr.Button("πŸ”„ Clear All Ratings", size="sm", scale=1)
838
- ws_submit = gr.Button("πŸš€ Submit Feedback & Next", variant="primary", scale=3)
839
-
840
- # Wire clear buttons (individual toggle deselection)
841
- dr_clr.click(lambda: None, [], [ws_dr])
842
- fs_clr.click(lambda: None, [], [ws_fs])
843
- fr_clr.click(lambda: None, [], [ws_fr])
844
- fa_clr.click(lambda: None, [], [ws_fa])
845
  ws_reset.click(reset_ratings, [], [ws_dr, ws_fs, ws_fr, ws_fa])
846
 
847
  # Output list β€” 18 components
 
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
 
520
  taggers = list(MONGO_COL.aggregate(tp))
521
  tr = "\n".join(f"| {t['_id']} | {t['c']} |" for t in taggers) or "| β€” | β€” |"
522
 
523
+ clf_s = MONGO_DB['experiments_clf_success'].count_documents({}) if MONGO_DB is not None else 0
524
+ clf_f = MONGO_DB['experiments_clf_failed'].count_documents({}) if MONGO_DB is not None else 0
525
 
526
  return f"""### πŸ“ˆ Platform Statistics
527
  | Metric | Count |
 
711
  .rating-radio label:nth-child(3):has(input:checked) {
712
  background: #22c55e !important; color: #fff !important; }
713
 
714
+
 
 
715
  """
716
 
717
  # JavaScript to enable click-to-toggle on radio buttons
 
785
  ws_conf = gr.HTML("<p style='color:#888'>Fetch an experiment to begin.</p>")
786
 
787
  gr.Markdown("---")
788
+ gr.Markdown("πŸ’‘ **Leave a rating empty = accept model prediction.** "
789
+ "Select only to correct the model.")
790
 
791
+ ws_reset = gr.Button("πŸ”„ Clear All Ratings", size="sm")
 
 
 
 
 
 
792
 
793
+ # Data Quality
794
+ gr.Markdown("### πŸ“Š Data Quality")
795
+ ws_dr = gr.Radio(choices=RATING_CHOICES, value=None,
796
+ label="Rate raw data:", elem_classes=["rating-radio"])
797
  ws_cd = gr.Textbox(label="Data notes (optional)", lines=2)
798
 
799
  # Fit Quality β€” SINGLE (overlap)
800
  with gr.Column(visible=True) as ws_fs_col:
801
+ gr.Markdown("### πŸ“ Fit Quality (Combined)")
802
+ ws_fs = gr.Radio(choices=RATING_CHOICES, value=None,
803
+ label="Rate the fit:", elem_classes=["rating-radio"])
 
 
 
804
  ws_cs = gr.Textbox(label="Fit notes (optional)", lines=2)
805
 
806
  # Fit Quality β€” DUAL (diverge)
 
809
  with gr.Row():
810
  with gr.Column():
811
  gr.Markdown("#### 🟦 Regular Fit")
812
+ ws_fr = gr.Radio(choices=RATING_CHOICES, value=None,
813
+ label="Regular Fit:", elem_classes=["rating-radio"])
 
 
 
814
  ws_cr = gr.Textbox(label="Regular fit notes", lines=2)
815
  with gr.Column():
816
  gr.Markdown("#### 🟩 AI Fit")
817
+ ws_fa = gr.Radio(choices=RATING_CHOICES, value=None,
818
+ label="AI Fit:", elem_classes=["rating-radio"])
 
 
 
819
  ws_ca = gr.Textbox(label="AI fit notes", lines=2)
820
 
821
  gr.Markdown("---")
822
+ ws_submit = gr.Button("πŸš€ Submit Feedback & Next", variant="primary", size="lg")
823
 
 
 
 
 
 
 
 
 
 
824
  ws_reset.click(reset_ratings, [], [ws_dr, ws_fs, ws_fr, ws_fa])
825
 
826
  # Output list β€” 18 components