コード例 #1
0
ファイル: database.py プロジェクト: libAtoms/abcd
    def setUpClass(cls):
        logging.basicConfig(level=logging.INFO)
        url = 'mongodb://localhost'
        abcd = ABCD.from_url(url)
        abcd.print_info()

        cls.abcd = abcd
コード例 #2
0
    def wrapper(*args, config, **kwargs):
        url = config.get('url', None)

        if url is None:
            print('Please use abcd login first!')
            exit(1)

        db = ABCD.from_url(url=url)

        # TODO: AST.from_string() ?!
        # TODO: parser should accept list
        # TODO: better ast optimisation

        query_list = []
        for q in kwargs.pop('default_query', []):
            query_list.append(parser(q))

        for q in kwargs.pop('query', []):
            query_list.append(parser(q))

        if not query_list:
            query = None
        elif len(query_list) == 1:
            query = query_list[0]
        else:
            query = ('AND', *query_list)

        func(*args, db=db, query=query, **kwargs)
コード例 #3
0
def login(*, config, name, url, **kwargs):
    logger.info('login args: \nconfig:{}, name:{}, url:{}, kwargs:{}'.format(
        config, name, url, kwargs))
    from abcd import ABCD

    db = ABCD.from_url(url=url)
    info = db.info()

    config['url'] = url
    config.save()

    print('Successfully connected to the database!')
    print(" type:       {type}\n"
          " hostname:   {host}\n"
          " port:       {port}\n"
          " database:   {db}\n"
          " # of confs: {number of confs}".format(**info))
コード例 #4
0
import numpy as np
from collections import Counter

from abcd import ABCD

if __name__ == '__main__':
    abcd = ABCD(url='mongodb://localhost:27017')
    print(abcd)
    abcd.print_info()
コード例 #5
0
ファイル: test_db.py プロジェクト: libAtoms/abcd
from ase.io import iread, read

from abcd import ABCD

if __name__ == '__main__':
    # http requests
    # url = 'http://*****:*****@localhost:27018/?authSource=admin'

    # Mongoengine
    # https://stackoverflow.com/questions/36200288/mongolab-pymongo-connection-error
    url = 'mongodb://*****:*****@localhost:27018/?authSource=admin'

    abcd = ABCD(url, db='abcd', collection='default')
    print(abcd)

    abcd.print_info()

    with abcd as db:
        db.destroy()

    abcd.destroy()

    direcotry = Path('../tutorials/data/')
    file = direcotry / 'bcc_bulk_54_expanded_2_high.xyz'
    # file = direcotry / 'GAP_6.xyz'

    traj = read(file.as_posix(), index=slice(None))
    abcd.print_info()
コード例 #6
0
import sys
from pathlib import Path

sys.path.append('..')

from abcd import ABCD
from utils.ext_xyz import XYZReader

if __name__ == '__main__':

    url = 'mongodb://localhost:27017'
    abcd = ABCD(url)

    for file in Path('GB_alphaFe_001/tilt/').glob('*.xyz'):
        print(file)
        gb_params = {
            'name': 'alphaFe',
            'type': 'tilt',
            'params': file.name[:-4]
        }
        with abcd as db, XYZReader(file) as reader:
            db.push(reader.read_atoms(), extra_info={'GB_params': gb_params})