feiyang-cai commited on
Commit
4360500
·
verified ·
1 Parent(s): 8a10e7f

Show generation alert in UI

Browse files
Files changed (1) hide show
  1. app.py +40 -5
app.py CHANGED
@@ -453,6 +453,7 @@ def ui_clear_design_outputs():
453
  None,
454
  "",
455
  "",
 
456
  gr.update(choices=[], value=None),
457
  NO_SELECTED_DESIGN,
458
  "",
@@ -531,10 +532,8 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
531
  exc_text = str(exc)
532
  if "ZeroGPU quota" in exc_text or "quota" in exc_text.lower():
533
  title = "ZeroGPU quota is exhausted or unavailable."
534
- gr.Warning("ZeroGPU quota is exhausted or unavailable. Switch to Nvidia T4 small or retry after quota is restored.")
535
  else:
536
  title = "Generation failed before candidate simulation."
537
- gr.Warning("Generation failed before candidate simulation. See the run log for details.")
538
  message = (
539
  f"{title}\n\n"
540
  f"Error: {type(exc).__name__}: {exc_text}\n\n"
@@ -547,6 +546,7 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
547
  None,
548
  message,
549
  message,
 
550
  gr.update(choices=[], value=None),
551
  title,
552
  "",
@@ -599,6 +599,7 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
599
  fig,
600
  ((gt_summary + "\n") if gt_summary else "") + "\n".join(summaries),
601
  "\n".join(logs) if logs else "Done.",
 
602
  gr.update(choices=choices, value=choices[0]),
603
  _design_markdown(selected),
604
  payload,
@@ -609,6 +610,7 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
609
  fig,
610
  "No valid generated designs were scored.",
611
  "\n".join(logs) if logs else "Generation failed.",
 
612
  gr.update(choices=[], value=None),
613
  "No selected design is available.",
614
  "",
@@ -759,6 +761,7 @@ def build_app():
759
  gr.Markdown("## 2. Material Inverse Design")
760
  design_plot = gr.Plot(label="Conditioned vs Generated Curves")
761
  design_summary = gr.Textbox(label="Generated Designs", lines=6)
 
762
  run_log = gr.Textbox(label="Run Log", lines=8, interactive=False)
763
 
764
  gr.Markdown("## 3. Choose the Closest Generated Design")
@@ -792,6 +795,7 @@ def build_app():
792
  req_plot,
793
  design_plot,
794
  design_summary,
 
795
  run_log,
796
  design_choice,
797
  selected_design_md,
@@ -814,6 +818,7 @@ def build_app():
814
  req_plot,
815
  design_plot,
816
  design_summary,
 
817
  run_log,
818
  design_choice,
819
  selected_design_md,
@@ -835,6 +840,7 @@ def build_app():
835
  req_plot,
836
  design_plot,
837
  design_summary,
 
838
  run_log,
839
  design_choice,
840
  selected_design_md,
@@ -855,7 +861,17 @@ def build_app():
855
  show_progress=False,
856
  ).then(
857
  fn=ui_clear_design_outputs,
858
- outputs=[design_plot, design_summary, run_log, design_choice, selected_design_md, design_payload, thermo_selected_md, thermo_result_md],
 
 
 
 
 
 
 
 
 
 
859
  show_progress=False,
860
  ).then(
861
  fn=ui_after_requirement_ready,
@@ -873,7 +889,17 @@ def build_app():
873
  outputs=[req_plot, exact_test_coeffs],
874
  ).then(
875
  fn=ui_clear_design_outputs,
876
- outputs=[design_plot, design_summary, run_log, design_choice, selected_design_md, design_payload, thermo_selected_md, thermo_result_md],
 
 
 
 
 
 
 
 
 
 
877
  show_progress=False,
878
  ).then(
879
  fn=ui_after_requirement_ready,
@@ -888,7 +914,16 @@ def build_app():
888
  ).then(
889
  fn=ui_inverse_design,
890
  inputs=[n_generate, input_mode, load_test_idx] + input_components,
891
- outputs=[req_plot, design_plot, design_summary, run_log, design_choice, selected_design_md, design_payload],
 
 
 
 
 
 
 
 
 
892
  ).then(
893
  fn=ui_after_design_complete,
894
  inputs=[input_mode, design_payload],
 
453
  None,
454
  "",
455
  "",
456
+ "",
457
  gr.update(choices=[], value=None),
458
  NO_SELECTED_DESIGN,
459
  "",
 
532
  exc_text = str(exc)
533
  if "ZeroGPU quota" in exc_text or "quota" in exc_text.lower():
534
  title = "ZeroGPU quota is exhausted or unavailable."
 
535
  else:
536
  title = "Generation failed before candidate simulation."
 
537
  message = (
538
  f"{title}\n\n"
539
  f"Error: {type(exc).__name__}: {exc_text}\n\n"
 
546
  None,
547
  message,
548
  message,
549
+ f"### {title}\n\n{message}",
550
  gr.update(choices=[], value=None),
551
  title,
552
  "",
 
599
  fig,
600
  ((gt_summary + "\n") if gt_summary else "") + "\n".join(summaries),
601
  "\n".join(logs) if logs else "Done.",
602
+ "",
603
  gr.update(choices=choices, value=choices[0]),
604
  _design_markdown(selected),
605
  payload,
 
610
  fig,
611
  "No valid generated designs were scored.",
612
  "\n".join(logs) if logs else "Generation failed.",
613
+ "### No valid generated designs were scored.\n\nSee the run log for simulation details.",
614
  gr.update(choices=[], value=None),
615
  "No selected design is available.",
616
  "",
 
761
  gr.Markdown("## 2. Material Inverse Design")
762
  design_plot = gr.Plot(label="Conditioned vs Generated Curves")
763
  design_summary = gr.Textbox(label="Generated Designs", lines=6)
764
+ generation_alert = gr.Markdown("")
765
  run_log = gr.Textbox(label="Run Log", lines=8, interactive=False)
766
 
767
  gr.Markdown("## 3. Choose the Closest Generated Design")
 
795
  req_plot,
796
  design_plot,
797
  design_summary,
798
+ generation_alert,
799
  run_log,
800
  design_choice,
801
  selected_design_md,
 
818
  req_plot,
819
  design_plot,
820
  design_summary,
821
+ generation_alert,
822
  run_log,
823
  design_choice,
824
  selected_design_md,
 
840
  req_plot,
841
  design_plot,
842
  design_summary,
843
+ generation_alert,
844
  run_log,
845
  design_choice,
846
  selected_design_md,
 
861
  show_progress=False,
862
  ).then(
863
  fn=ui_clear_design_outputs,
864
+ outputs=[
865
+ design_plot,
866
+ design_summary,
867
+ generation_alert,
868
+ run_log,
869
+ design_choice,
870
+ selected_design_md,
871
+ design_payload,
872
+ thermo_selected_md,
873
+ thermo_result_md,
874
+ ],
875
  show_progress=False,
876
  ).then(
877
  fn=ui_after_requirement_ready,
 
889
  outputs=[req_plot, exact_test_coeffs],
890
  ).then(
891
  fn=ui_clear_design_outputs,
892
+ outputs=[
893
+ design_plot,
894
+ design_summary,
895
+ generation_alert,
896
+ run_log,
897
+ design_choice,
898
+ selected_design_md,
899
+ design_payload,
900
+ thermo_selected_md,
901
+ thermo_result_md,
902
+ ],
903
  show_progress=False,
904
  ).then(
905
  fn=ui_after_requirement_ready,
 
914
  ).then(
915
  fn=ui_inverse_design,
916
  inputs=[n_generate, input_mode, load_test_idx] + input_components,
917
+ outputs=[
918
+ req_plot,
919
+ design_plot,
920
+ design_summary,
921
+ run_log,
922
+ generation_alert,
923
+ design_choice,
924
+ selected_design_md,
925
+ design_payload,
926
+ ],
927
  ).then(
928
  fn=ui_after_design_complete,
929
  inputs=[input_mode, design_payload],