Use modal prompt and reset thermo inputs
Browse files
app.py
CHANGED
|
@@ -452,6 +452,7 @@ def ui_clear_design_outputs():
|
|
| 452 |
return (
|
| 453 |
None,
|
| 454 |
"",
|
|
|
|
| 455 |
"",
|
| 456 |
"",
|
| 457 |
gr.update(choices=[], value=None),
|
|
@@ -459,6 +460,10 @@ def ui_clear_design_outputs():
|
|
| 459 |
"",
|
| 460 |
NO_SELECTED_DESIGN,
|
| 461 |
THERMO_NOT_RUN,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
)
|
| 463 |
|
| 464 |
|
|
@@ -473,6 +478,7 @@ def ui_generation_started():
|
|
| 473 |
return (
|
| 474 |
None,
|
| 475 |
"Requesting ZeroGPU allocation...",
|
|
|
|
| 476 |
message,
|
| 477 |
"Requesting ZeroGPU allocation for candidate generation.",
|
| 478 |
gr.update(choices=[], value=None),
|
|
@@ -480,9 +486,17 @@ def ui_generation_started():
|
|
| 480 |
"",
|
| 481 |
NO_SELECTED_DESIGN,
|
| 482 |
THERMO_NOT_RUN,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 483 |
)
|
| 484 |
|
| 485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
def ui_manual_requirements_changed():
|
| 487 |
return (
|
| 488 |
"",
|
|
@@ -568,8 +582,9 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
|
|
| 568 |
req_plot,
|
| 569 |
None,
|
| 570 |
message,
|
| 571 |
-
|
| 572 |
f"### {title}\n\n{message}",
|
|
|
|
| 573 |
gr.update(choices=[], value=None),
|
| 574 |
title,
|
| 575 |
"",
|
|
@@ -622,6 +637,7 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
|
|
| 622 |
fig,
|
| 623 |
((gt_summary + "\n") if gt_summary else "") + "\n".join(summaries),
|
| 624 |
"\n".join(logs) if logs else "Done.",
|
|
|
|
| 625 |
"",
|
| 626 |
gr.update(choices=choices, value=choices[0]),
|
| 627 |
_design_markdown(selected),
|
|
@@ -633,6 +649,7 @@ def ui_inverse_design(n_generate: float, mode: str, load_idx: float, *values: fl
|
|
| 633 |
fig,
|
| 634 |
"No valid generated designs were scored.",
|
| 635 |
"\n".join(logs) if logs else "Generation failed.",
|
|
|
|
| 636 |
"### No valid generated designs were scored.\n\nSee the run log for simulation details.",
|
| 637 |
gr.update(choices=[], value=None),
|
| 638 |
"No selected design is available.",
|
|
@@ -722,6 +739,25 @@ def build_app():
|
|
| 722 |
width: 96px !important;
|
| 723 |
min-width: 96px !important;
|
| 724 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 725 |
"""
|
| 726 |
|
| 727 |
with gr.Blocks(css=css) as demo:
|
|
@@ -784,7 +820,9 @@ def build_app():
|
|
| 784 |
gr.Markdown("## 2. Material Inverse Design")
|
| 785 |
design_plot = gr.Plot(label="Conditioned vs Generated Curves")
|
| 786 |
design_summary = gr.Textbox(label="Generated Designs", lines=6)
|
| 787 |
-
|
|
|
|
|
|
|
| 788 |
run_log = gr.Textbox(label="Run Log", lines=8, interactive=False)
|
| 789 |
|
| 790 |
gr.Markdown("## 3. Choose the Closest Generated Design")
|
|
@@ -807,6 +845,12 @@ def build_app():
|
|
| 807 |
thermo_selected_md = gr.Markdown(NO_SELECTED_DESIGN)
|
| 808 |
thermo_result_md = gr.Markdown(THERMO_NOT_RUN)
|
| 809 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
input_mode.change(
|
| 811 |
fn=ui_input_mode_changed,
|
| 812 |
inputs=[input_mode],
|
|
@@ -818,13 +862,18 @@ def build_app():
|
|
| 818 |
req_plot,
|
| 819 |
design_plot,
|
| 820 |
design_summary,
|
| 821 |
-
|
|
|
|
| 822 |
run_log,
|
| 823 |
design_choice,
|
| 824 |
selected_design_md,
|
| 825 |
design_payload,
|
| 826 |
thermo_selected_md,
|
| 827 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
preview_btn,
|
| 829 |
load_btn,
|
| 830 |
design_btn,
|
|
@@ -841,13 +890,18 @@ def build_app():
|
|
| 841 |
req_plot,
|
| 842 |
design_plot,
|
| 843 |
design_summary,
|
| 844 |
-
|
|
|
|
| 845 |
run_log,
|
| 846 |
design_choice,
|
| 847 |
selected_design_md,
|
| 848 |
design_payload,
|
| 849 |
thermo_selected_md,
|
| 850 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
preview_btn,
|
| 852 |
load_btn,
|
| 853 |
design_btn,
|
|
@@ -863,13 +917,18 @@ def build_app():
|
|
| 863 |
req_plot,
|
| 864 |
design_plot,
|
| 865 |
design_summary,
|
| 866 |
-
|
|
|
|
| 867 |
run_log,
|
| 868 |
design_choice,
|
| 869 |
selected_design_md,
|
| 870 |
design_payload,
|
| 871 |
thermo_selected_md,
|
| 872 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
preview_btn,
|
| 874 |
load_btn,
|
| 875 |
design_btn,
|
|
@@ -887,13 +946,18 @@ def build_app():
|
|
| 887 |
outputs=[
|
| 888 |
design_plot,
|
| 889 |
design_summary,
|
| 890 |
-
|
|
|
|
| 891 |
run_log,
|
| 892 |
design_choice,
|
| 893 |
selected_design_md,
|
| 894 |
design_payload,
|
| 895 |
thermo_selected_md,
|
| 896 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 897 |
],
|
| 898 |
show_progress=False,
|
| 899 |
).then(
|
|
@@ -915,13 +979,18 @@ def build_app():
|
|
| 915 |
outputs=[
|
| 916 |
design_plot,
|
| 917 |
design_summary,
|
| 918 |
-
|
|
|
|
| 919 |
run_log,
|
| 920 |
design_choice,
|
| 921 |
selected_design_md,
|
| 922 |
design_payload,
|
| 923 |
thermo_selected_md,
|
| 924 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
],
|
| 926 |
show_progress=False,
|
| 927 |
).then(
|
|
@@ -939,13 +1008,18 @@ def build_app():
|
|
| 939 |
outputs=[
|
| 940 |
design_plot,
|
| 941 |
design_summary,
|
| 942 |
-
|
|
|
|
| 943 |
run_log,
|
| 944 |
design_choice,
|
| 945 |
selected_design_md,
|
| 946 |
design_payload,
|
| 947 |
thermo_selected_md,
|
| 948 |
thermo_result_md,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 949 |
],
|
| 950 |
show_progress=False,
|
| 951 |
).then(
|
|
@@ -956,7 +1030,8 @@ def build_app():
|
|
| 956 |
design_plot,
|
| 957 |
design_summary,
|
| 958 |
run_log,
|
| 959 |
-
|
|
|
|
| 960 |
design_choice,
|
| 961 |
selected_design_md,
|
| 962 |
design_payload,
|
|
|
|
| 452 |
return (
|
| 453 |
None,
|
| 454 |
"",
|
| 455 |
+
gr.update(visible=False),
|
| 456 |
"",
|
| 457 |
"",
|
| 458 |
gr.update(choices=[], value=None),
|
|
|
|
| 460 |
"",
|
| 461 |
NO_SELECTED_DESIGN,
|
| 462 |
THERMO_NOT_RUN,
|
| 463 |
+
gr.update(value=0.0),
|
| 464 |
+
gr.update(value=0.0),
|
| 465 |
+
gr.update(value=0.0),
|
| 466 |
+
gr.update(value=0.0),
|
| 467 |
)
|
| 468 |
|
| 469 |
|
|
|
|
| 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),
|
|
|
|
| 486 |
"",
|
| 487 |
NO_SELECTED_DESIGN,
|
| 488 |
THERMO_NOT_RUN,
|
| 489 |
+
gr.update(value=0.0),
|
| 490 |
+
gr.update(value=0.0),
|
| 491 |
+
gr.update(value=0.0),
|
| 492 |
+
gr.update(value=0.0),
|
| 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 |
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),
|
| 589 |
title,
|
| 590 |
"",
|
|
|
|
| 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 |
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 |
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 |
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 |
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 |
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,
|
| 870 |
design_payload,
|
| 871 |
thermo_selected_md,
|
| 872 |
thermo_result_md,
|
| 873 |
+
angle_a,
|
| 874 |
+
angle_b,
|
| 875 |
+
angle_c,
|
| 876 |
+
max_stress,
|
| 877 |
preview_btn,
|
| 878 |
load_btn,
|
| 879 |
design_btn,
|
|
|
|
| 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,
|
| 898 |
design_payload,
|
| 899 |
thermo_selected_md,
|
| 900 |
thermo_result_md,
|
| 901 |
+
angle_a,
|
| 902 |
+
angle_b,
|
| 903 |
+
angle_c,
|
| 904 |
+
max_stress,
|
| 905 |
preview_btn,
|
| 906 |
load_btn,
|
| 907 |
design_btn,
|
|
|
|
| 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,
|
| 925 |
design_payload,
|
| 926 |
thermo_selected_md,
|
| 927 |
thermo_result_md,
|
| 928 |
+
angle_a,
|
| 929 |
+
angle_b,
|
| 930 |
+
angle_c,
|
| 931 |
+
max_stress,
|
| 932 |
preview_btn,
|
| 933 |
load_btn,
|
| 934 |
design_btn,
|
|
|
|
| 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,
|
| 954 |
design_payload,
|
| 955 |
thermo_selected_md,
|
| 956 |
thermo_result_md,
|
| 957 |
+
angle_a,
|
| 958 |
+
angle_b,
|
| 959 |
+
angle_c,
|
| 960 |
+
max_stress,
|
| 961 |
],
|
| 962 |
show_progress=False,
|
| 963 |
).then(
|
|
|
|
| 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,
|
| 987 |
design_payload,
|
| 988 |
thermo_selected_md,
|
| 989 |
thermo_result_md,
|
| 990 |
+
angle_a,
|
| 991 |
+
angle_b,
|
| 992 |
+
angle_c,
|
| 993 |
+
max_stress,
|
| 994 |
],
|
| 995 |
show_progress=False,
|
| 996 |
).then(
|
|
|
|
| 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,
|
| 1016 |
design_payload,
|
| 1017 |
thermo_selected_md,
|
| 1018 |
thermo_result_md,
|
| 1019 |
+
angle_a,
|
| 1020 |
+
angle_b,
|
| 1021 |
+
angle_c,
|
| 1022 |
+
max_stress,
|
| 1023 |
],
|
| 1024 |
show_progress=False,
|
| 1025 |
).then(
|
|
|
|
| 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,
|