from pydash import get from pymatgen import MPRester from pymatgen.util.string import unicodeify mpr = MPRester() from pymongo.errors import ServerSelectionTimeoutError store = loadfn(environ["PROPNET_STORE_FILE"]) try: store.connect() except ServerSelectionTimeoutError: # layout won't work if database is down, but at least web app will stay up scalar_symbols = {k: v for k, v in DEFAULT_SYMBOLS.items() if (v.category == 'property' and v.shape == 1)} warning_layout = html.Div('No database connection could be established.', style={'font-family': 'monospace', 'color': 'rgb(211, 84, 0)', 'text-align': 'left', 'font-size': '1.2em'}) else: cut_off = 100 # need at least this many available quantities for plot scalar_symbols = {k: v for k, v in DEFAULT_SYMBOLS.items() if (v.category == 'property' and v.shape == 1 and store.query( criteria={f'{k}.mean': {'$exists': True}}).count() > cut_off)} warning_layout = html.Div()
from collections import OrderedDict from propnet.symbols import DEFAULT_SYMBOLS from propnet import ureg from propnet.core.quantity import Quantity from propnet.core.materials import Material from propnet.core.graph import Graph from pydash import get # explicitly making this an OrderedDict so we can go back from the display name to # the symbol name SCALAR_SYMBOLS = OrderedDict({ k: v for k, v in sorted(DEFAULT_SYMBOLS.items(), key=lambda x: x[1].display_names[0]) if (v.category == 'property' and v.shape == 1) }) ROW_IDX_TO_SYMBOL_NAME = [symbol for symbol in SCALAR_SYMBOLS.keys()] DEFAULT_ROWS = [{ 'Property': symbol.display_names[0], 'Value': None } for symbol in SCALAR_SYMBOLS.values()] def interactive_layout(app): layout = html.Div([ dcc.Markdown('## Input'),
from dash.dependencies import Input, Output, State from pydash import get from pymatgen import MPRester from pymatgen.util.string import unicodeify mpr = MPRester() store = loadfn(environ["PROPNET_STORE_FILE"]) store.connect() cut_off = 100 # need at least this many available quantities for plot scalar_symbols = { k: v for k, v in DEFAULT_SYMBOLS.items() if (v.category == 'property' and v.shape == 1 and store.query(criteria={ f'{k}.mean': { '$exists': True } }).count() > cut_off) } # this is dependent on the schema format def _ensure_indices(): for property_name in scalar_symbols.keys(): store.ensure_index(property_name) def ashby_layout(app):
from propnet.symbols import DEFAULT_SYMBOLS from propnet import ureg, logger from propnet.core.quantity import Quantity from propnet.core.materials import Material from propnet.core.graph import Graph from propnet.ext.matproj import MPRester MPR = MPRester() # explicitly making this an OrderedDict so we can go back from the # display name to the symbol name SCALAR_SYMBOLS = OrderedDict({k: v for k, v in sorted(DEFAULT_SYMBOLS.items(), key=lambda x: x[1].display_names[0]) if ((v.category == 'property' or v.category == 'condition') and v.shape == 1)}) ROW_IDX_TO_SYMBOL_NAME = [symbol for symbol in SCALAR_SYMBOLS.keys()] DEFAULT_ROWS = [ { 'Property': symbol.display_names[0], 'Editable Value': None } for symbol in SCALAR_SYMBOLS.values() ] REMAINING_SYMBOLS = OrderedDict({k: v for k, v in sorted(DEFAULT_SYMBOLS.items(), key=lambda x: x[1].display_names[0]) if not ((v.category == 'property' or v.category == 'condition')