Skip to content

Commit

Permalink
Merge pull request #276 from dgasmith/mol
Browse files Browse the repository at this point in the history
Database updates
  • Loading branch information
dgasmith committed May 28, 2019
2 parents 169cb2e + 54993c5 commit 7c6949a
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
coverage:
ignore:
- */tests/*
- qcfractal/dashboard/* # early state
- qcfractal/migrations/* # difficult to test
- qcfractal/_version.py
- setup.py
status:
Expand Down
5 changes: 0 additions & 5 deletions qcfractal/interface/collections/reaction_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np
import pandas as pd
from pydantic import BaseModel
import qcelemental as qcel

from .collection_utils import nCr, register_collection
from .dataset import Dataset
Expand Down Expand Up @@ -487,10 +486,6 @@ def parse_stoichiometry(self, stoichiometry):
# What kind of molecule is it?
mol = line[0]

# This is a molecule hash, should be in the database
if isinstance(mol, qcel.models.Molecule):
mol = Molecule(**mol.dict())

if isinstance(mol, str) and (len(mol) == 40):
molecule_hash = mol

Expand Down
18 changes: 2 additions & 16 deletions qcfractal/interface/models/common_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from typing import Any, Dict, Optional, Union, List, Tuple

from pydantic import BaseModel, validator
from qcelemental.models import Provenance
import qcelemental as qcel
from qcelemental.models import Molecule, Provenance

from .model_utils import hash_dictionary, prepare_basis, recursive_normalizer

Expand Down Expand Up @@ -36,19 +35,6 @@ def validate(cls, v):
raise TypeError("The string {} is not a valid 24-character hexadecimal or integer ObjectId!".format(v))


class Molecule(qcel.models.Molecule):

id: Optional[ObjectId] = None
connectivity: List[Tuple[int, int, float]] = None

def __init__(self, **kwargs):
# print(kwargs.get("connectivity", None))
if ("connectivity" in kwargs) and (len(kwargs["connectivity"]) == 0):
del kwargs["connectivity"]
# print(kwargs.get("id", None), type(kwargs.get("id", None)))
super().__init__(**kwargs)


class DriverEnum(str, Enum):
energy = 'energy'
gradient = 'gradient'
Expand Down Expand Up @@ -82,7 +68,7 @@ class Config:
extra = "forbid"
allow_mutation = False

def form_schema_object(self, keywords: Optional['KeywordSet']=None, checks=True) -> Dict[str, Any]:
def form_schema_object(self, keywords: Optional['KeywordSet'] = None, checks=True) -> Dict[str, Any]:
if checks and self.keywords:
assert keywords.id == self.keywords

Expand Down
2 changes: 1 addition & 1 deletion qcfractal/interface/models/task_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PythonComputeSpec(BaseModel):

class TaskRecord(BaseModel):

id: Union[ObjectId, int] = None
id: ObjectId = None

spec: PythonComputeSpec
parser: str
Expand Down
6 changes: 3 additions & 3 deletions qcfractal/interface/models/torsiondrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TorsionDriveInput(BaseModel):

program: _td_constr = "torsiondrive"
procedure: _td_constr = "torsiondrive"
initial_molecule: List[Union[ObjectId, Molecule, int]]
initial_molecule: List[Union[ObjectId, Molecule]]
keywords: TDKeywords
optimization_spec: OptimizationSpecification
qc_spec: QCSpecification
Expand Down Expand Up @@ -78,15 +78,15 @@ class TorsionDriveRecord(RecordBase):
program: _td_constr = "torsiondrive"

# Input data
initial_molecule: List[Union[ObjectId, int]]
initial_molecule: List[ObjectId]
keywords: TDKeywords
optimization_spec: OptimizationSpecification
qc_spec: QCSpecification

# Output data
final_energy_dict: Dict[str, float]

optimization_history: Dict[str, List[Union[ObjectId, int]]]
optimization_history: Dict[str, List[ObjectId]]
minimum_positions: Dict[str, int]

class Config(RecordBase.Config):
Expand Down
4 changes: 0 additions & 4 deletions qcfractal/storage_sockets/sqlalchemy_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,6 @@ def get_molecules(self, id=None, molecule_hash=None, molecular_formula=None, lim

# ret["meta"]["errors"].extend(errors)

# Todo: tobe removed after bug is fixed in elemental
for d in rdata:
if d['connectivity'] is None:
d['connectivity'] = []
data = [Molecule(**d, validate=False) for d in rdata]

return {'meta': meta, 'data': data}
Expand Down
2 changes: 1 addition & 1 deletion qcfractal/tests/test_procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_procedure_optimization(fractal_compute_server):

for results in [results1, results2]:
assert len(results) == 1
assert isinstance(results[0].provenance.creator, str) # TODO: Bug in QCEngine, see molssi/qcengine#42
assert isinstance(results[0].provenance.creator, str)
assert isinstance(str(results[0]), str) # Check that repr runs
assert pytest.approx(-1.117530188962681, 1e-5) == results[0].get_final_energy()

Expand Down

0 comments on commit 7c6949a

Please sign in to comment.