Skip to content

Commit

Permalink
Rename VASP and cclib summarizers (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen authored Sep 17, 2023
1 parent 71c9e7e commit 65bc32d
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 51 deletions.
10 changes: 5 additions & 5 deletions src/quacc/recipes/gaussian/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from quacc import job
from quacc.schemas import fetch_atoms
from quacc.schemas.cclib import summarize_cclib_run
from quacc.schemas.cclib import cclib_summarize_run
from quacc.utils.calc import run_calc
from quacc.utils.dicts import merge_dicts

Expand Down Expand Up @@ -78,7 +78,7 @@ def static_job(
Returns
-------
cclibSchema
Dictionary of results, as specified in [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results, as specified in [quacc.schemas.cclib.cclib_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -168,7 +168,7 @@ def relax_job(
Returns
-------
cclibSchema
Dictionary of results, as specified in [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results, as specified in [quacc.schemas.cclib.cclib_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -231,15 +231,15 @@ def _base_job(
Returns
-------
cclibSchema
Dictionary of results, as specified in [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results, as specified in [quacc.schemas.cclib.cclib_summarize_run][]
"""
atoms = fetch_atoms(atoms)
flags = merge_dicts(defaults, calc_swaps)

atoms.calc = Gaussian(**flags)
atoms = run_calc(atoms, geom_file=GEOM_FILE, copy_files=copy_files)

return summarize_cclib_run(
return cclib_summarize_run(
atoms,
LOG_FILE,
charge_and_multiplicity=(charge, spin_multiplicity),
Expand Down
10 changes: 5 additions & 5 deletions src/quacc/recipes/orca/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from quacc import SETTINGS, job
from quacc.schemas import fetch_atoms
from quacc.schemas.cclib import summarize_cclib_run
from quacc.schemas.cclib import cclib_summarize_run
from quacc.utils.calc import run_calc
from quacc.utils.dicts import merge_dicts

Expand Down Expand Up @@ -89,7 +89,7 @@ def static_job(
Returns
-------
cclibSchema
Dictionary of results from [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results from [quacc.schemas.cclib.cclib_summarize_run][]
"""

default_inputs = {
Expand Down Expand Up @@ -188,7 +188,7 @@ def relax_job(
Returns
-------
cclibSchema
Dictionary of results from [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results from [quacc.schemas.cclib.cclib_summarize_run][]
"""

default_inputs = {
Expand Down Expand Up @@ -262,7 +262,7 @@ def _base_job(
Returns
-------
cclibSchema
Dictionary of results from [quacc.schemas.cclib.summarize_cclib_run][]
Dictionary of results from [quacc.schemas.cclib.cclib_summarize_run][]
"""
atoms = fetch_atoms(atoms)
inputs = merge_dicts(default_inputs, input_swaps)
Expand All @@ -279,7 +279,7 @@ def _base_job(
)
atoms = run_calc(atoms, geom_file=GEOM_FILE, copy_files=copy_files)

return summarize_cclib_run(
return cclib_summarize_run(
atoms,
LOG_FILE,
charge_and_multiplicity=(charge, spin_multiplicity),
Expand Down
10 changes: 5 additions & 5 deletions src/quacc/recipes/vasp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from quacc import job
from quacc.calculators.vasp import Vasp
from quacc.schemas import fetch_atoms
from quacc.schemas.vasp import summarize_vasp_run
from quacc.schemas.vasp import vasp_summarize_run
from quacc.utils.calc import run_calc
from quacc.utils.dicts import merge_dicts

Expand Down Expand Up @@ -60,7 +60,7 @@ def static_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -127,7 +127,7 @@ def relax_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -245,12 +245,12 @@ def _base_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""
atoms = fetch_atoms(atoms)
flags = merge_dicts(defaults, calc_swaps, remove_empties=False)

atoms.calc = Vasp(atoms, preset=preset, **flags)
atoms = run_calc(atoms, copy_files=copy_files)

return summarize_vasp_run(atoms, additional_fields=additional_fields)
return vasp_summarize_run(atoms, additional_fields=additional_fields)
4 changes: 2 additions & 2 deletions src/quacc/recipes/vasp/mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def mp_prerelax_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

defaults = {"ediffg": -0.05, "xc": "pbesol"}
Expand Down Expand Up @@ -104,7 +104,7 @@ def mp_relax_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

return _base_job(
Expand Down
8 changes: 4 additions & 4 deletions src/quacc/recipes/vasp/qmof.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _loose_relax_positions(
Returns
-------
VaspSchema
Dictionary of results from quacc.schemas.vasp.summarize_vasp_run
Dictionary of results from quacc.schemas.vasp.vasp_summarize_run
"""

defaults = {
Expand Down Expand Up @@ -215,7 +215,7 @@ def _loose_relax_cell(
Returns
-------
VaspSchema
Dictionary of results from quacc.schemas.vasp.summarize_vasp_run
Dictionary of results from quacc.schemas.vasp.vasp_summarize_run
"""

defaults = {
Expand Down Expand Up @@ -261,7 +261,7 @@ def _double_relax(
Returns
-------
list[VaspSchema]
List of dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
List of dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

# Run first relaxation
Expand Down Expand Up @@ -321,7 +321,7 @@ def _static(
Returns
-------
VaspSchema
Dictionary of results from quacc.schemas.vasp.summarize_vasp_run
Dictionary of results from quacc.schemas.vasp.vasp_summarize_run
"""

defaults = {
Expand Down
8 changes: 4 additions & 4 deletions src/quacc/recipes/vasp/slabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def slab_static_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -123,7 +123,7 @@ def slab_relax_job(
Returns
-------
VaspSchema
Dictionary of results from [quacc.schemas.vasp.summarize_vasp_run][]
Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

defaults = {
Expand Down Expand Up @@ -180,7 +180,7 @@ def bulk_to_slabs_flow(
Returns
-------
list[VaspSchema]
List of dictionary results from [quacc.schemas.vasp.summarize_vasp_run][]
List of dictionary results from [quacc.schemas.vasp.vasp_summarize_run][]
"""
slab_relax_kwargs = slab_relax_kwargs or {}
slab_static_kwargs = slab_static_kwargs or {}
Expand Down Expand Up @@ -245,7 +245,7 @@ def slab_to_ads_flow(
Returns
-------
list[VaspSchema]
List of dictionaries of results from [quacc.schemas.vasp.summarize_vasp_run][]
List of dictionaries of results from [quacc.schemas.vasp.vasp_summarize_run][]
"""

slab_relax_kwargs = slab_relax_kwargs or {}
Expand Down
2 changes: 1 addition & 1 deletion src/quacc/schemas/cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
cclibSchema = TypeVar("cclibSchema")


def summarize_cclib_run(
def cclib_summarize_run(
atoms: Atoms,
logfile_extensions: str | list[str],
dir_path: str | None = None,
Expand Down
2 changes: 1 addition & 1 deletion src/quacc/schemas/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
VaspSchema = TypeVar("VaspSchema")


def summarize_vasp_run(
def vasp_summarize_run(
atoms: Atoms,
dir_path: str | None = None,
prep_next_run: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion tests/recipes/vasp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ def patch_summarize_run(monkeypatch):
# Monkeypatch the summarize_run() function so that we aren't relying on real
# VASP files to be in the working directory during the test.
monkeypatch.setattr(
"quacc.recipes.vasp.core.summarize_vasp_run", mock_summarize_run
"quacc.recipes.vasp.core.vasp_summarize_run", mock_summarize_run
)
22 changes: 11 additions & 11 deletions tests/schemas/test_cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from quacc.schemas.cclib import (
_cclib_calculate,
_cclibTaskDocument,
summarize_cclib_run,
cclib_summarize_run,
)

FILE_DIR = Path(__file__).resolve().parent
Expand Down Expand Up @@ -45,10 +45,10 @@ def bad_mock_cclib_calculate(*args, **kwargs):
raise ValueError(msg)


def test_summarize_cclib_run():
def test_cclib_summarize_run():
# Make sure metadata is made
atoms = read(log1)
results = summarize_cclib_run(atoms, ".log", dir_path=run1)
results = cclib_summarize_run(atoms, ".log", dir_path=run1)
assert results["natoms"] == len(atoms)
assert results["atoms"] == atoms
assert results["spin_multiplicity"] == 1
Expand All @@ -63,19 +63,19 @@ def test_summarize_cclib_run():
# Make sure default dir works
cwd = os.getcwd()
os.chdir(run1)
summarize_cclib_run(atoms, ".log")
cclib_summarize_run(atoms, ".log")
os.chdir(cwd)

# Test DB
atoms = read(log1)
store = MemoryStore()
summarize_cclib_run(atoms, ".log", dir_path=run1, store=store)
cclib_summarize_run(atoms, ".log", dir_path=run1, store=store)
assert store.count() == 1

# Make sure info tags are handled appropriately
atoms = read(log1)
atoms.info["test_dict"] = {"hi": "there", "foo": "bar"}
results = summarize_cclib_run(atoms, ".log", dir_path=run1)
results = cclib_summarize_run(atoms, ".log", dir_path=run1)
assert atoms.info.get("test_dict", None) == {"hi": "there", "foo": "bar"}
assert results.get("atoms_info", {}) != {}
assert results["atoms_info"].get("test_dict", None) == {"hi": "there", "foo": "bar"}
Expand All @@ -85,7 +85,7 @@ def test_summarize_cclib_run():
atoms = read(os.path.join(run1, log1))
atoms.set_initial_magnetic_moments([3.14] * len(atoms))
atoms.calc.results["magmoms"] = [2.0] * len(atoms)
results = summarize_cclib_run(atoms, ".log", dir_path=run1)
results = cclib_summarize_run(atoms, ".log", dir_path=run1)

assert atoms.calc is not None
assert atoms.get_initial_magnetic_moments().tolist() == [3.14] * len(atoms)
Expand All @@ -98,7 +98,7 @@ def test_summarize_cclib_run():
# Make sure Atoms magmoms were not moved if specified
atoms = read(os.path.join(run1, log1))
atoms.set_initial_magnetic_moments([3.14] * len(atoms))
results = summarize_cclib_run(atoms, ".log", dir_path=run1, prep_next_run=False)
results = cclib_summarize_run(atoms, ".log", dir_path=run1, prep_next_run=False)
assert atoms.get_initial_magnetic_moments().tolist() == [3.14] * len(atoms)
assert results["atoms"].get_initial_magnetic_moments().tolist() == [3.14] * len(
atoms
Expand All @@ -107,7 +107,7 @@ def test_summarize_cclib_run():
# Test remove_empties
# Make sure metadata is made
atoms = read(log1)
results = summarize_cclib_run(atoms, ".log", dir_path=run1, remove_empties=True)
results = cclib_summarize_run(atoms, ".log", dir_path=run1, remove_empties=True)
assert results["natoms"] == len(atoms)
assert results["atoms"] == atoms
assert results["spin_multiplicity"] == 1
Expand All @@ -119,12 +119,12 @@ def test_summarize_cclib_run():
def test_errors():
atoms = bulk("Cu")
with pytest.raises(ValueError):
summarize_cclib_run(atoms, ".log", dir_path=run1)
cclib_summarize_run(atoms, ".log", dir_path=run1)

calc = Vasp(atoms)
atoms.calc = calc
with pytest.raises(ValueError):
summarize_cclib_run(atoms, ".log", dir_path=run1)
cclib_summarize_run(atoms, ".log", dir_path=run1)


def test_cclib_taskdoc(tmpdir):
Expand Down
Loading

0 comments on commit 65bc32d

Please sign in to comment.