コード例 #1
0
def test_procedure_pagination(storage_socket):
    """
        Test procedure pagination
    """

    assert len(storage_socket.get_procedures()['data']) == 0

    proc_template = {
        "initial_molecule": bad_id1,
        "program": "something",
        "qc_spec": {
            "driver": "gradient",
            "method": "HF",
            "basis": "sto-3g",
            "keywords": None,
            "program": "psi4"
        },
    }

    total = 1000

    procedures = []
    for i in range(total):
        tmp = proc_template.copy()
        tmp['hash_index'] = str(i)
        procedures.append(ptl.models.OptimizationRecord(**tmp))

    inserted = storage_socket.add_procedures(procedures)
    assert inserted['meta']['n_inserted'] == total

    ret = storage_socket.get_procedures(procedure='optimization', status=None, skip=400)

    # count is total, but actual data size is the limit
    assert ret['meta']['n_found'] == total
    assert len(ret['data']) == storage_socket._max_limit - 400
コード例 #2
0
def test_procedure_pagination(storage_socket):
    """
        Test procedure pagination
    """

    water = ptl.data.get_molecule("water_dimer_minima.psimol")
    mol = storage_socket.add_molecules([water])['data'][0]

    assert len(
        storage_socket.get_procedures(procedure='optimization')['data']) == 0

    proc_template = {
        "initial_molecule": mol,
        "program": "something",
        "qc_spec": {
            "driver": "gradient",
            "method": "HF",
            "basis": "sto-3g",
            "keywords": None,
            "program": "psi4"
        },
    }

    total = 10
    limit = 5
    skip = 4

    procedures = []
    for i in range(total):
        tmp = proc_template.copy()
        tmp['hash_index'] = str(i)
        procedures.append(ptl.models.OptimizationRecord(**tmp))

    inserted = storage_socket.add_procedures(procedures)
    assert inserted['meta']['n_inserted'] == total

    ret = storage_socket.get_procedures(procedure='optimization',
                                        status=None,
                                        limit=limit,
                                        skip=skip)

    # count is total, but actual data size is the limit
    assert ret['meta']['n_found'] == total
    assert len(ret['data']) == limit

    storage_socket.del_procedures(inserted['data'])
    storage_socket.del_molecules(mol)
コード例 #3
0
def test_procedure_sql(storage_socket, storage_results):

    results = storage_results.get_results()['data']

    assert len(storage_socket.get_procedures(procedure='optimization', status=None)['data']) == 0
    water = ptl.data.get_molecule("water_dimer_minima.psimol")

    # Add once
    mol_id = storage_socket.add_molecules([water])['data'][0]

    proc_template = {
        "procedure": "optimization",
        "initial_molecule": mol_id,
        "program": "something",
        "hash_index": 123,
        # "trajectory": [results[0]['id'], results[1]['id']],
        "qc_spec": {
            "driver": "gradient",
            "method": "HF",
            "basis": "sto-3g",
            # "keywords": None,
            "program": "psi4"
        },
    }

    torsion_proc = {
        "procedure": "torsiondrive",
        "keywords": {
            "dihedrals": [[0, 1, 2, 3]],
            "grid_spacing": [10]
        },
        "hash_index": 456,
        "optimization_spec": {
            "program": "geometric",
            "keywords": {
            "coordsys": "tric",
        }},
        "qc_spec": {
            "driver": "gradient",
            "method": "HF",
            "basis": "sto-3g",
            # "keywords": None,
            "program": "psi4"
        },
        "initial_molecule": [mol_id],
        "final_energy_dict": {},
        "optimization_history": {},
        "minimum_positions": {},
        "provenance": {
            "creator": ""
        }
    }


    # Optimization
    inserted = storage_socket.add_procedures([ptl.models.OptimizationRecord(**proc_template)])
    assert inserted['meta']['n_inserted'] == 1

    ret = storage_socket.get_procedures(procedure='optimization', status=None)
    assert len(ret['data']) == 1
    # print(ret['data'][0]['trajectory'])

    # # Torsiondrive
    # inserted = storage_socket.add_procedures([ptl.models.TorsionDriveRecord(**torsion_proc)])
    # assert inserted['meta']['n_inserted'] == 1
    #
    # ret = storage_socket.get_procedures(procedure='torsiondrive', status=None)
    # assert len(ret['data']) == 1
    #
    # ret = storage_socket.get_procedures(status=None)
    # assert len(ret['data']) == 2

    # clean up
    storage_socket.del_procedures(inserted['data'])