feiyang-cai commited on
Commit
2e9a997
·
verified ·
1 Parent(s): 35fc23d

Use inline ZeroGPU status panel

Browse files
Files changed (1) hide show
  1. app.py +8 -51
app.py CHANGED
@@ -452,7 +452,6 @@ def ui_clear_design_outputs():
452
  return (
453
  None,
454
  "",
455
- gr.update(visible=False),
456
  "",
457
  "",
458
  gr.update(choices=[], value=None),
@@ -478,7 +477,6 @@ def ui_generation_started():
478
  return (
479
  None,
480
  "Requesting ZeroGPU allocation...",
481
- gr.update(visible=True),
482
  message,
483
  "Requesting ZeroGPU allocation for candidate generation.",
484
  gr.update(choices=[], value=None),
@@ -493,10 +491,6 @@ def ui_generation_started():
493
  )
494
 
495
 
496
- def ui_close_generation_modal():
497
- return gr.update(visible=False)
498
-
499
-
500
  def ui_manual_requirements_changed():
501
  return (
502
  "",
@@ -582,7 +576,6 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
582
  req_plot,
583
  None,
584
  message,
585
- gr.update(visible=True),
586
  f"### {title}\n\n{message}",
587
  message,
588
  gr.update(choices=[], value=None),
@@ -637,7 +630,6 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
637
  fig,
638
  ((gt_summary + "\n") if gt_summary else "") + "\n".join(summaries),
639
  "\n".join(logs) if logs else "Done.",
640
- gr.update(visible=False),
641
  "",
642
  gr.update(choices=choices, value=choices[0]),
643
  _design_markdown(selected),
@@ -649,7 +641,6 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
649
  fig,
650
  "No valid generated designs were scored.",
651
  "\n".join(logs) if logs else "Generation failed.",
652
- gr.update(visible=True),
653
  "### No valid generated designs were scored.\n\nSee the run log for simulation details.",
654
  gr.update(choices=[], value=None),
655
  "No selected design is available.",
@@ -739,25 +730,6 @@ def build_app():
739
  width: 96px !important;
740
  min-width: 96px !important;
741
  }
742
- #generation-modal {
743
- position: fixed !important;
744
- inset: 0 !important;
745
- z-index: 10000 !important;
746
- background: rgba(15, 23, 42, 0.42) !important;
747
- display: flex !important;
748
- align-items: center !important;
749
- justify-content: center !important;
750
- padding: 24px !important;
751
- }
752
- #generation-modal > div {
753
- max-width: 640px !important;
754
- width: min(640px, calc(100vw - 48px)) !important;
755
- background: #fffaf0 !important;
756
- border: 1px solid #f59e0b !important;
757
- border-radius: 16px !important;
758
- box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32) !important;
759
- padding: 18px !important;
760
- }
761
  """
762
 
763
  with gr.Blocks(css=css) as demo:
@@ -820,9 +792,7 @@ def build_app():
820
  gr.Markdown("## 2. Material Inverse Design")
821
  design_plot = gr.Plot(label="Conditioned vs Generated Curves")
822
  design_summary = gr.Textbox(label="Generated Designs", lines=6)
823
- with gr.Group(visible=False, elem_id="generation-modal") as generation_modal:
824
- generation_modal_md = gr.Markdown("")
825
- generation_modal_close = gr.Button("Close", variant="secondary")
826
  run_log = gr.Textbox(label="Run Log", lines=8, interactive=False)
827
 
828
  gr.Markdown("## 3. Choose the Closest Generated Design")
@@ -845,12 +815,6 @@ def build_app():
845
  thermo_selected_md = gr.Markdown(NO_SELECTED_DESIGN)
846
  thermo_result_md = gr.Markdown(THERMO_NOT_RUN)
847
 
848
- generation_modal_close.click(
849
- fn=ui_close_generation_modal,
850
- outputs=[generation_modal],
851
- show_progress=False,
852
- )
853
-
854
  input_mode.change(
855
  fn=ui_input_mode_changed,
856
  inputs=[input_mode],
@@ -862,8 +826,7 @@ def build_app():
862
  req_plot,
863
  design_plot,
864
  design_summary,
865
- generation_modal,
866
- generation_modal_md,
867
  run_log,
868
  design_choice,
869
  selected_design_md,
@@ -890,8 +853,7 @@ def build_app():
890
  req_plot,
891
  design_plot,
892
  design_summary,
893
- generation_modal,
894
- generation_modal_md,
895
  run_log,
896
  design_choice,
897
  selected_design_md,
@@ -917,8 +879,7 @@ def build_app():
917
  req_plot,
918
  design_plot,
919
  design_summary,
920
- generation_modal,
921
- generation_modal_md,
922
  run_log,
923
  design_choice,
924
  selected_design_md,
@@ -946,8 +907,7 @@ def build_app():
946
  outputs=[
947
  design_plot,
948
  design_summary,
949
- generation_modal,
950
- generation_modal_md,
951
  run_log,
952
  design_choice,
953
  selected_design_md,
@@ -979,8 +939,7 @@ def build_app():
979
  outputs=[
980
  design_plot,
981
  design_summary,
982
- generation_modal,
983
- generation_modal_md,
984
  run_log,
985
  design_choice,
986
  selected_design_md,
@@ -1008,8 +967,7 @@ def build_app():
1008
  outputs=[
1009
  design_plot,
1010
  design_summary,
1011
- generation_modal,
1012
- generation_modal_md,
1013
  run_log,
1014
  design_choice,
1015
  selected_design_md,
@@ -1030,8 +988,7 @@ def build_app():
1030
  design_plot,
1031
  design_summary,
1032
  run_log,
1033
- generation_modal,
1034
- generation_modal_md,
1035
  design_choice,
1036
  selected_design_md,
1037
  design_payload,
 
452
  return (
453
  None,
454
  "",
 
455
  "",
456
  "",
457
  gr.update(choices=[], value=None),
 
477
  return (
478
  None,
479
  "Requesting ZeroGPU allocation...",
 
480
  message,
481
  "Requesting ZeroGPU allocation for candidate generation.",
482
  gr.update(choices=[], value=None),
 
491
  )
492
 
493
 
 
 
 
 
494
  def ui_manual_requirements_changed():
495
  return (
496
  "",
 
576
  req_plot,
577
  None,
578
  message,
 
579
  f"### {title}\n\n{message}",
580
  message,
581
  gr.update(choices=[], value=None),
 
630
  fig,
631
  ((gt_summary + "\n") if gt_summary else "") + "\n".join(summaries),
632
  "\n".join(logs) if logs else "Done.",
 
633
  "",
634
  gr.update(choices=choices, value=choices[0]),
635
  _design_markdown(selected),
 
641
  fig,
642
  "No valid generated designs were scored.",
643
  "\n".join(logs) if logs else "Generation failed.",
 
644
  "### No valid generated designs were scored.\n\nSee the run log for simulation details.",
645
  gr.update(choices=[], value=None),
646
  "No selected design is available.",
 
730
  width: 96px !important;
731
  min-width: 96px !important;
732
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
733
  """
734
 
735
  with gr.Blocks(css=css) as demo:
 
792
  gr.Markdown("## 2. Material Inverse Design")
793
  design_plot = gr.Plot(label="Conditioned vs Generated Curves")
794
  design_summary = gr.Textbox(label="Generated Designs", lines=6)
795
+ generation_alert = gr.Markdown("")
 
 
796
  run_log = gr.Textbox(label="Run Log", lines=8, interactive=False)
797
 
798
  gr.Markdown("## 3. Choose the Closest Generated Design")
 
815
  thermo_selected_md = gr.Markdown(NO_SELECTED_DESIGN)
816
  thermo_result_md = gr.Markdown(THERMO_NOT_RUN)
817
 
 
 
 
 
 
 
818
  input_mode.change(
819
  fn=ui_input_mode_changed,
820
  inputs=[input_mode],
 
826
  req_plot,
827
  design_plot,
828
  design_summary,
829
+ generation_alert,
 
830
  run_log,
831
  design_choice,
832
  selected_design_md,
 
853
  req_plot,
854
  design_plot,
855
  design_summary,
856
+ generation_alert,
 
857
  run_log,
858
  design_choice,
859
  selected_design_md,
 
879
  req_plot,
880
  design_plot,
881
  design_summary,
882
+ generation_alert,
 
883
  run_log,
884
  design_choice,
885
  selected_design_md,
 
907
  outputs=[
908
  design_plot,
909
  design_summary,
910
+ generation_alert,
 
911
  run_log,
912
  design_choice,
913
  selected_design_md,
 
939
  outputs=[
940
  design_plot,
941
  design_summary,
942
+ generation_alert,
 
943
  run_log,
944
  design_choice,
945
  selected_design_md,
 
967
  outputs=[
968
  design_plot,
969
  design_summary,
970
+ generation_alert,
 
971
  run_log,
972
  design_choice,
973
  selected_design_md,
 
988
  design_plot,
989
  design_summary,
990
  run_log,
991
+ generation_alert,
 
992
  design_choice,
993
  selected_design_md,
994
  design_payload,