How to use the maggma.stores.MemoryStore function in maggma

To help you get started, we’ve selected a few maggma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github materialsintelligence / propnet / propnet / web / layouts_correlate.py View on Github external
logger = logging.getLogger(__name__)
mpr = MPRester()

try:
    store = loadfn(
        environ["PROPNET_CORRELATION_STORE_FILE"])
    store.connect()
except (ServerSelectionTimeoutError, KeyError, FileNotFoundError) as ex:
    if isinstance(ex, ServerSelectionTimeoutError):
        logger.warning("Unable to connect to propnet correlation db!")
    if isinstance(ex, KeyError):
        logger.warning("PROPNET_CORRELATION_STORE_FILE var not set!")
    if isinstance(ex, FileNotFoundError):
        logger.warning("File specified in PROPNET_CORRELATION_STORE_FILE not found!")
    from maggma.stores import MemoryStore
    store = MemoryStore()
    store.connect()
    # layout won't work if database is down, but at least web app will stay up

correlation_funcs = list(store.query().distinct("correlation_func"))

correlation_func_info = {
            "mic": {"name": "Maximal information coefficient",
                    "bounds": lambda x: 0 <= round(x) <= 1},
            "linlsq": {"name": "Linear least squares, R-squared",
                       "bounds": lambda x: 0 <= round(x) <= 1},
            "theilsen": {"name": "Theil-Sen regression, R-squared",
                         "bounds": lambda x: -10 <= round(x) <= 1},    # Arbitrary lower bound to filter nonsense data
            "ransac": {"name": "RANSAC regression",
                       "bounds": lambda x: -10 <= round(x) <= 1},  # Arbitrary lower bound to filter nonsense data
            "pearson": {"name": "Pearson R correlation",
                        "bounds": lambda x: -1 <= round(x) <= 1},
github materialsintelligence / propnet / propnet / web / layouts_plot.py View on Github external
from propnet.dbtools.correlation import CorrelationBuilder

from pymongo.errors import ServerSelectionTimeoutError

import logging

logger = logging.getLogger(__name__)

mpr = MPRester()

try:
    store = loadfn(environ["PROPNET_STORE_FILE"])
    store.connect()
except (ServerSelectionTimeoutError, KeyError):
    from maggma.stores import MemoryStore
    store = MemoryStore()
    store.connect()
    # layout won't work if database is down, but at least web app will stay up
    scalar_symbols = {k: v for k, v in Registry("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 Registry("symbols").items()
                      if (v.category == 'property' and v.shape == 1
                          and store.query(
                              criteria={f'{k}.mean': {'$exists': True}}).count() > cut_off)}

maggma

Framework to develop datapipelines from files on disk to full dissemenation API

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis