diff --git a/pyproject.toml b/pyproject.toml index e418276ca6..d278649a29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,13 +31,13 @@ dependencies = [ "cclib>=1.8", # for I/O parsing of molecular DFT codes "custodian>=2024.3.12", # for automated error corrections "emmet-core>=0.80.0", # for pre-made schemas - "maggma<=0.63.4", # for database handling + "maggma>=0.64.0", # for database handling "monty>=2024.2.26", # miscellaneous Python utilities "numpy>=1.25.0", # for array handling "psutil", # for getting compute architecture details "pydantic>=2.0.1", # for settings management "pydantic-settings>=2.2.0", # for settings management - "pymatgen>=2024.2.20", # for structure manipulation + "pymatgen>=2024.4.12", # for structure manipulation "typer>=0.12.1", # for the CLI ] diff --git a/src/quacc/schemas/atoms.py b/src/quacc/schemas/atoms.py index 34fd5a8c89..2a0f0d8dde 100644 --- a/src/quacc/schemas/atoms.py +++ b/src/quacc/schemas/atoms.py @@ -2,10 +2,10 @@ from __future__ import annotations +from copy import deepcopy from typing import TYPE_CHECKING from emmet.core.structure import MoleculeMetadata, StructureMetadata -from monty.json import jsanitize from pymatgen.io.ase import AseAtomsAdaptor from quacc.atoms.core import ( @@ -83,9 +83,7 @@ def atoms_to_metadata( metadata = {} # Copy the info flags as a separate entry in the DB for easy querying - results["atoms_info"] = jsanitize( - atoms.info, enum_values=True, recursive_msonable=True - ) + results["atoms_info"] = deepcopy(atoms.info) # Store Atoms object results["atoms"] = atoms diff --git a/src/quacc/schemas/cclib.py b/src/quacc/schemas/cclib.py index da88230eae..2c9a928bad 100644 --- a/src/quacc/schemas/cclib.py +++ b/src/quacc/schemas/cclib.py @@ -13,7 +13,6 @@ import cclib from ase.atoms import Atoms from cclib.io import ccread -from monty.json import jsanitize from quacc import SETTINGS from quacc.atoms.core import get_final_atoms_from_dynamics @@ -328,7 +327,7 @@ def _make_cclib_schema( raise RuntimeError(msg) # Fetch all the attributes (i.e. all input/outputs from cclib) - attributes = jsanitize(cclib_obj.getattributes()) + attributes = cclib_obj.getattributes() # monty datetime bug workaround: # github.com/materialsvirtuallab/monty/issues/275 diff --git a/src/quacc/wflow_tools/db.py b/src/quacc/wflow_tools/db.py index f537663e14..53b7a6a7df 100644 --- a/src/quacc/wflow_tools/db.py +++ b/src/quacc/wflow_tools/db.py @@ -5,6 +5,8 @@ import uuid from typing import TYPE_CHECKING +from monty.json import jsanitize + if TYPE_CHECKING: from typing import Any @@ -31,8 +33,13 @@ def results_to_db(store: Store, results: dict[str, Any] | list[dict]) -> None: if not isinstance(results, list): results = [results] - for result in results: + sanitized_results = [ + jsanitize(result, enum_values=True, recursive_msonable=True) + for result in results + ] + + for result in sanitized_results: result["uuid"] = str(uuid.uuid4()) with store: - store.update(results, key="uuid") + store.update(sanitized_results, key="uuid") diff --git a/tests/core/schemas/test_ase.py b/tests/core/schemas/test_ase.py index 96d571ada1..8db978a0ea 100644 --- a/tests/core/schemas/test_ase.py +++ b/tests/core/schemas/test_ase.py @@ -44,13 +44,11 @@ def test_summarize_run(tmpdir, monkeypatch): with gzip.open(Path(results["dir_name"], "quacc_results.pkl.gz"), "rb") as f: pickle_results = pickle.load(f) - output = results.copy() - output.pop("uuid") - assert pickle_results.keys() == output.keys() + assert pickle_results.keys() == results.keys() - assert pickle_results["nsites"] == output["nsites"] - assert pickle_results["results"]["energy"] == output["results"]["energy"] - assert pickle_results["atoms"].info == output["atoms"].info + assert pickle_results["nsites"] == results["nsites"] + assert pickle_results["results"]["energy"] == results["results"]["energy"] + assert pickle_results["atoms"].info == results["atoms"].info def test_summarize_run2(tmp_path, monkeypatch): @@ -143,16 +141,13 @@ def test_summarize_opt_run(tmp_path, monkeypatch): with gzip.open(Path(results["dir_name"], "quacc_results.pkl.gz"), "rb") as f: pickle_results = pickle.load(f) - output = results.copy() - output.pop("uuid") - - assert pickle_results.keys() == output.keys() + assert pickle_results.keys() == results.keys() # assert things on the trajectory are the same - assert pickle_results["trajectory"] == output["trajectory"] + assert pickle_results["trajectory"] == results["trajectory"] assert ( pickle_results["trajectory_results"][-1]["energy"] - == output["trajectory_results"][-1]["energy"] + == results["trajectory_results"][-1]["energy"] ) # Test DB diff --git a/tests/core/wflow/test_db.py b/tests/core/wflow/test_db.py index 4e4277b453..a984456e3b 100644 --- a/tests/core/wflow/test_db.py +++ b/tests/core/wflow/test_db.py @@ -12,3 +12,4 @@ def test_results_to_db(): results_to_db(store, {"atoms": atoms}) with store: assert store.count() == 1 + assert store.query_one().get("uuid") diff --git a/tests/requirements.txt b/tests/requirements.txt index 65cafd2bc8..2daa33920f 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,11 +2,11 @@ ase @ https://gitlab.com/ase/ase/-/archive/master/ase-master.zip cclib==1.8.1 custodian==2024.3.12 emmet-core==0.82.1 -maggma==0.63.4 +maggma==0.64.0 monty==2024.3.31 numpy==1.26.4 psutil==5.9.8 pydantic==2.6.4 pydantic-settings==2.2.1 -pymatgen==2024.3.1 +pymatgen==2024.4.12 typer==0.12.2