Skip to content

Commit bc57982

Browse files
committed
Inject API key via env variable
1 parent 19ce6c5 commit bc57982

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

components.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PeriodicContext is a top-level that provides a model for the periodic table that
2626
PeriodicFilter allows you to use filter some elements on table, by groups/periods/properties.
2727
It updates the PeriodicContext, which in turn is mirrored on the table.
2828
```
29-
//TODO
29+
//TODO example file
3030
```
3131

3232
#3D Scene
@@ -52,7 +52,7 @@ The JSON of the object will be passed as an argument
5252

5353
## CameraContext
5454

55-
Camera context allows you to wire the camera of multiple SimpleScenes together.
55+
Camera context allows you to wire the camera of multiple SimpleScenes together. See `scene_usage.py`
5656

5757
```
5858
dash_mp_components.CameraContext(children=[
@@ -87,12 +87,15 @@ dash_mp_components.CameraContext(children=[
8787

8888
## SearchGrid
8989

90-
This is the whole search interface, wrapped in a React component. Everything happens in the frontend.
90+
This is the whole search interface, wrapped in a React component. From a dash point of view, this
91+
component is opaque. Everything happens in the frontend.
9192

92-
## MatSearchGrid / MatPrintViewContext / MAtMaterialsTable
93+
## MatSearchGrid / MatPrintViewContext / MatMaterialsTable
9394

9495
This is the same interface. The search funnel and the result table are decoupled. The REST call
95-
happens in dash. See usage.py for more details
96+
happens in dash. See `usage.py`. The whole search is implemented there
97+
98+
See `search_usage.py` for a very simple example of a card
9699

97100
```
98101
dash_mp_components.MatPrintViewContext(children=[

usage.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
import functools
88
from dash.exceptions import PreventUpdate
99
from pymatgen import MPRester
10+
import os
11+
12+
try:
13+
os.environ["MP_API_KEY"]
14+
except KeyError:
15+
print("Please set the environment variable MP_API_KEY")
16+
sys.exit(1)
1017

1118
app = dash.Dash(__name__)
1219

@@ -99,7 +106,7 @@ def display_output2(c):
99106
]
100107

101108
# This should be setted as an env variable instead
102-
with MPRester("fJcpJy6hRNF3DzBo") as m:
109+
with MPRester(os.environ["MP_API_KEY"]) as m:
103110
q = m.query(criteria=query, properties=properties)
104111

105112
#print('RESULT', len(q))

0 commit comments

Comments
 (0)