msiron commited on
Commit
2af7535
·
1 Parent(s): c61d5b5
Files changed (2) hide show
  1. app.py +27 -15
  2. requirements.txt +1 -2
app.py CHANGED
@@ -1,15 +1,16 @@
1
  import os
2
 
3
  import gradio as gr
4
- from gradio_banner import Banner
5
  import numpy as np
6
  import plotly.graph_objs as go
7
  from datasets import load_dataset
8
  from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram
9
  from pymatgen.core import Composition, Structure
10
  from pymatgen.core.composition import Composition
11
- from pymatgen.entries.computed_entries import (ComputedStructureEntry,
12
- GibbsComputedStructureEntry)
 
 
13
 
14
  HF_TOKEN = os.environ.get("HF_TOKEN")
15
 
@@ -36,8 +37,13 @@ del dataset
36
 
37
 
38
  def create_phase_diagram(
39
- elements, max_e_above_hull, color_scheme, plot_style, functional, finite_temp,
40
- **kwargs
 
 
 
 
 
41
  ):
42
  # Split elements and remove any whitespace
43
  element_list = [el.strip() for el in elements.split("-")]
@@ -125,15 +131,21 @@ plot_style_dropdown = gr.Dropdown(choices=["2D", "3D"], label="Plot Style")
125
  functional_dropdown = gr.Dropdown(choices=["PBE", "PBESol", "SCAN"], label="Functional")
126
  finite_temp_toggle = gr.Checkbox(label="Enable Finite Temperature Estimation")
127
 
128
- banner = Banner(value="This application uses energy correction schemes directly" +
129
- " from the data providers (Alexandria, MP) and has the 2020 MP"+
130
- " Compatibility scheme applied to OQMD. However, because we did"+
131
- " not directly apply the compatibility schemes to Alexandria, MP"+
132
- " we have noticed discrepencies in the data. While the correction"+
133
- " scheme will be standardized in a soon to be released update, for"+
134
- " now please take caution when analyzing the results of this"+
135
- " application.",
136
- variant="warning")
 
 
 
 
 
 
137
 
138
  # Create Gradio interface
139
  iface = gr.Interface(
@@ -145,7 +157,7 @@ iface = gr.Interface(
145
  plot_style_dropdown,
146
  functional_dropdown,
147
  finite_temp_toggle,
148
- banner,
149
  ],
150
  outputs=gr.Plot(label="Phase Diagram"),
151
  title="LeMaterial - Phase Diagram Viewer",
 
1
  import os
2
 
3
  import gradio as gr
 
4
  import numpy as np
5
  import plotly.graph_objs as go
6
  from datasets import load_dataset
7
  from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram
8
  from pymatgen.core import Composition, Structure
9
  from pymatgen.core.composition import Composition
10
+ from pymatgen.entries.computed_entries import (
11
+ ComputedStructureEntry,
12
+ GibbsComputedStructureEntry,
13
+ )
14
 
15
  HF_TOKEN = os.environ.get("HF_TOKEN")
16
 
 
37
 
38
 
39
  def create_phase_diagram(
40
+ elements,
41
+ max_e_above_hull,
42
+ color_scheme,
43
+ plot_style,
44
+ functional,
45
+ finite_temp,
46
+ **kwargs,
47
  ):
48
  # Split elements and remove any whitespace
49
  element_list = [el.strip() for el in elements.split("-")]
 
131
  functional_dropdown = gr.Dropdown(choices=["PBE", "PBESol", "SCAN"], label="Functional")
132
  finite_temp_toggle = gr.Checkbox(label="Enable Finite Temperature Estimation")
133
 
134
+ warning_message = "This application uses energy correction schemes directly"
135
+ warning_message += " from the data providers (Alexandria, MP) and has the 2020 MP"
136
+ warning_message += " Compatibility scheme applied to OQMD. However, because we did"
137
+ warning_message += " not directly apply the compatibility schemes to Alexandria, MP"
138
+ warning_message += " we have noticed discrepencies in the data. While the correction"
139
+ warning_message += " scheme will be standardized in a soon to be released update, for"
140
+ warning_message += " now please take caution when analyzing the results of this"
141
+ warning_message += " application."
142
+
143
+ with gr.Blocks() as banner:
144
+ message = gr.HTML(
145
+ '<div class="alert"><span class="closebtn" onclick="this.parentElement.style.display="none";">&times;</span>{}</div>'.format(
146
+ warning_message
147
+ )
148
+ )
149
 
150
  # Create Gradio interface
151
  iface = gr.Interface(
 
157
  plot_style_dropdown,
158
  functional_dropdown,
159
  finite_temp_toggle,
160
+ message,
161
  ],
162
  outputs=gr.Plot(label="Phase Diagram"),
163
  title="LeMaterial - Phase Diagram Viewer",
requirements.txt CHANGED
@@ -1,5 +1,4 @@
1
  plotly
2
  pymatgen
3
  gradio==5.8.0
4
- datasets==3.1.0
5
- gradio_banner
 
1
  plotly
2
  pymatgen
3
  gradio==5.8.0
4
+ datasets==3.1.0