def from_file(cls, db_file, m="materials", c="counter", t="tasks", **kwargs): """ Get a TaskMaterialsBuilder using only a db file. Args: db_file (str): path to db file m (str): name of "materials" collection c (str): name of "counter" collection t (str): name of "tasks" collection **kwargs: other params to put into TasksMaterialsBuilder """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print( "Warning: could not get read-only database; using write creds") db_read = get_database(db_file, admin=True) return cls(db_write[m], db_write[c], db_read[t], **kwargs)
def connect(self, config): """Connect to database with given configuration, which may be a dict or a path to a pymatgen-db configuration. """ if isinstance(config, str): conn = dbutil.get_database(config_file=config) elif isinstance(config, dict): conn = dbutil.get_database(settings=config) else: raise ValueError("Configuration, '{}', must be a path to " "a configuration file or dict".format(config)) return conn
def from_file(cls, db_file, m="materials", t="tasks", **kwargs): """ Get a TagsCollector using only a db file. Args: db_file (str): path to db file m (str): name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. update_all """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print("Warning: could not get read-only database; using write creds") db_read = get_database(db_file, admin=True) return cls(db_write[m], db_read[t], **kwargs)
def from_db_file(db_file, m="materials", b="boltztrap", **kwargs): """ Get a BoltztrapMaterialsBuilder using only a db file Args: db_file: (str) path to db file m: (str) name of "materials" collection b: (str) name of "boltztrap" collection **kwargs: other params to put into BoltztrapMaterialsBuilder """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print("Warning: could not get read-only database") db_read = get_database(db_file, admin=True) return BoltztrapMaterialsBuilder(db_write[m], db_read[b], **kwargs)
def from_file(cls, db_file, m="materials", t="tasks", **kwargs): """ Get a TagsCollector using only a db file. Args: db_file (str): path to db file m (str): name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. update_all """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print( "Warning: could not get read-only database; using write creds") db_read = get_database(db_file, admin=True) return cls(db_write[m], db_read[t], **kwargs)
def from_file(cls, db_file, m="materials", **kwargs): """ Get a MaterialsEhullBuilder using only a db file Args: db_file: (str) path to db file m: (str) name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. mapi_key """ db_write = get_database(db_file, admin=True) return cls(db_write[m], **kwargs)
def from_file(cls, db_file, m="materials", c="counter", t="tasks", **kwargs): """ Get a TaskMaterialsBuilder using only a db file. Args: db_file (str): path to db file m (str): name of "materials" collection c (str): name of "counter" collection t (str): name of "tasks" collection **kwargs: other params to put into TasksMaterialsBuilder """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print("Warning: could not get read-only database; using write creds") db_read = get_database(db_file, admin=True) return cls(db_write[m], db_write[c], db_read[t], **kwargs)
def from_file(cls, db_file, m="materials", b="boltztrap", **kwargs): """ Get a BoltztrapMaterialsBuilder using only a db file. Args: db_file (str): path to db file m (str): name of "materials" collection b (str): name of "boltztrap" collection **kwargs: other params to put into BoltztrapMaterialsBuilder """ db_write = get_database(db_file, admin=True) try: db_read = get_database(db_file, admin=False) db_read.collection_names() # throw error if auth failed except: print("Warning: could not get read-only database") db_read = get_database(db_file, admin=True) return cls(db_write[m], db_read[b], **kwargs)
def from_db_file(db_file, m="materials", **kwargs): """ Get a MaterialsEhullBuilder using only a db file Args: db_file: (str) path to db file m: (str) name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. mapi_key """ db_write = get_database(db_file, admin=True) return MaterialsEhullBuilder(db_write[m], **kwargs)
def from_file(cls, db_file, t="tasks", **kwargs): """ Get a FixTasksBuilder using only a db file. Args: db_file (str): path to db file t (str): name of "tasks" collection **kwargs: other params to put into FixTasksBuilder """ db_write = get_database(db_file, admin=True) return cls(db_write[t], **kwargs)
def from_file(db_file, m="materials", **kwargs): """ Get builder using only a db file. Args: db_file: (str) path to db file m: (str) name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. mapi_key Returns: BandgapEstimationBuilder """ db_write = get_database(db_file, admin=True) return BandgapEstimationBuilder(db_write[m], **kwargs)
def from_file(cls, db_file, data_file=None, m="materials", **kwargs): """ Get a FileMaterialsBuilder using only a db file. Args: db_file (str): path to db file data_file (str): path to data file m (str): name of "materials" collection **kwargs: other parameters to feed into the builder, e.g. mapi_key """ db_write = get_database(db_file, admin=True) if data_file: return cls(db_write[m], data_file, **kwargs) else: raise ValueError("data_file must be provided")