Repository: Quantum-Accelerators/quacc
Pull request #2023 (2024-04-21 04:19:50)

Remove double `_` methods
## Summary of Changes

No need for us to hide methods that are already hidden.

### Checklist

- [ ] I have read the ["Guidelines" section](https://quantum-accelerators.github.io/quacc/dev/contributing.html#guidelines) of the contributing guide. Don't lie! 😉
- [ ] My PR is on a custom branch and is _not_ named `main`.
- [ ] I have added relevant, comprehensive [unit tests](https://quantum-accelerators.github.io/quacc/dev/contributing.html#unit-tests).

### Notes

- Your PR will likely not be merged without proper and thorough tests.
- If you are an external contributor, you will see a comment from [@buildbot-princeton](https://github.com/buildbot-princeton). This is solely for the maintainers.
- When your code is ready for review, ping one of the [active maintainers](https://quantum-accelerators.github.io/quacc/about/contributors.html#active-maintainers).



Patch:
diff --git a/src/quacc/recipes/espresso/_base.py b/src/quacc/recipes/espresso/_base.py
index d1a3ea5b..c9fbc61a 100644
--- a/src/quacc/recipes/espresso/_base.py
+++ b/src/quacc/recipes/espresso/_base.py
@@ -76,7 +76,7 @@ def run_and_summarize(
     RunSchema
         Dictionary of results from [quacc.schemas.ase.summarize_run][]
     """
-    atoms = _prepare_atoms(
+    atoms = prepare_atoms(
         atoms=atoms,
         preset=preset,
         template=template,
@@ -86,7 +86,7 @@ def run_and_summarize(
         parallel_info=parallel_info,
     )
 
-    updated_copy_files = _prepare_copy(
+    updated_copy_files = prepare_copy(
         copy_files=copy_files,
         calc_params=atoms.calc.user_calc_params,
         binary=atoms.calc.template.binary,
@@ -159,7 +159,7 @@ def run_and_summarize_opt(
     RunSchema
         Dictionary of results from [quacc.schemas.ase.summarize_run][]
     """
-    atoms = _prepare_atoms(
+    atoms = prepare_atoms(
         atoms=atoms,
         preset=preset,
         template=template,
@@ -169,7 +169,7 @@ def run_and_summarize_opt(
         parallel_info=parallel_info,
     )
 
-    updated_copy_files = _prepare_copy(
+    updated_copy_files = prepare_copy(
         copy_files=copy_files,
         calc_params=atoms.calc.user_calc_params,
         binary=atoms.calc.template.binary,
@@ -186,7 +186,7 @@ def run_and_summarize_opt(
     )
 
 
-def _prepare_atoms(
+def prepare_atoms(
     atoms: Atoms | None = None,
     preset: str | None = None,
     template: EspressoTemplate | None = None,
@@ -252,7 +252,7 @@ def _prepare_atoms(
     return atoms
 
 
-def _prepare_copy(
+def prepare_copy(
     copy_files: (
         SourceDirectory
         | list[SourceDirectory]
diff --git a/src/quacc/schemas/ase.py b/src/quacc/schemas/ase.py
index d57d3808..b7825eda 100644
--- a/src/quacc/schemas/ase.py
+++ b/src/quacc/schemas/ase.py
@@ -279,19 +279,17 @@ def summarize_vib_and_thermo(
     vib_task_doc = _summarize_vib_run(
         vib,
         charge_and_multiplicity=charge_and_multiplicity,
-        store=None,
-        additional_fields=additional_fields,
     )
     thermo_task_doc = _summarize_ideal_gas_thermo(
         igt,
         temperature=temperature,
         pressure=pressure,
         charge_and_multiplicity=charge_and_multiplicity,
-        store=None,
-        additional_fields=additional_fields,
     )
 
-    unsorted_task_doc = recursive_dict_merge(vib_task_doc, thermo_task_doc)
+    unsorted_task_doc = recursive_dict_merge(
+        vib_task_doc, thermo_task_doc, additional_fields
+    )
     task_doc = clean_task_doc(unsorted_task_doc)
 
     if isinstance(vib, Vibrations):
@@ -312,8 +310,6 @@ def summarize_vib_and_thermo(
 def _summarize_vib_run(
     vib: Vibrations | VibrationsData,
     charge_and_multiplicity: tuple[int, int] | None = None,
-    additional_fields: dict[str, Any] | None = None,
-    store: Store | None = None,
 ) -> VibSchema:
     """
     Get tabulated results from an ASE Vibrations object and store them in a database-
@@ -326,19 +322,12 @@ def _summarize_vib_run(
     charge_and_multiplicity
         Charge and spin multiplicity of the Atoms object, only used for Molecule
         metadata.
-    additional_fields
-        Additional fields to add to the task document.
-    store
-        Maggma Store object to store the results in. Defaults to `SETTINGS.STORE`.
 
     Returns
     -------
     VibSchema
         Dictionary representation of the task document
     """
-    additional_fields = additional_fields or {}
-    store = SETTINGS.STORE if store == _DEFAULT_SETTING else store
-
     vib_freqs_raw = vib.get_frequencies().tolist()
     vib_energies_raw = vib.get_energies().tolist()
 
@@ -411,13 +400,9 @@ def _summarize_vib_run(
         }
     }
 
-    unsorted_task_doc = atoms_metadata | inputs | results | additional_fields
-    task_doc = clean_task_doc(unsorted_task_doc)
-
-    if store:
-        results_to_db(store, task_doc)
+    unsorted_task_doc = atoms_metadata | inputs | results
 
-    return task_doc
+    return clean_task_doc(unsorted_task_doc)
 
 
 def _summarize_ideal_gas_thermo(
@@ -425,8 +410,6 @@ def _summarize_ideal_gas_thermo(
     temperature: float = 298.15,
     pressure: float = 1.0,
     charge_and_multiplicity: tuple[int, int] | None = None,
-    additional_fields: dict[str, Any] | None = None,
-    store: Store | None = _DEFAULT_SETTING,
 ) -> ThermoSchema:
     """
     Get tabulated results from an ASE IdealGasThermo object and store them in a
@@ -445,17 +428,12 @@ def _summarize_ideal_gas_thermo(
         metadata.
     additional_fields
         Additional fields to add to the task document.
-    store
-        Maggma Store object to store the results in. Defaults to `SETTINGS.STORE`
 
     Returns
     -------
     ThermoSchema
         Dictionary representation of the task document
     """
-    additional_fields = additional_fields or {}
-    store = SETTINGS.STORE if store == _DEFAULT_SETTING else store
-
     spin_multiplicity = round(2 * igt.spin + 1)
 
     inputs = {
@@ -494,10 +472,6 @@ def _summarize_ideal_gas_thermo(
         igt.atoms, charge_and_multiplicity=charge_and_multiplicity
     )
 
-    unsorted_task_doc = atoms_metadata | inputs | results | additional_fields
-    task_doc = clean_task_doc(unsorted_task_doc)
+    unsorted_task_doc = atoms_metadata | inputs | results
 
-    if store:
-        results_to_db(store, task_doc)
-
-    return task_doc
+    return clean_task_doc(unsorted_task_doc)


Test patch:
diff --git a/tests/core/schemas/test_ase.py b/tests/core/schemas/test_ase.py
index 7e577aa8..ef97b797 100644
--- a/tests/core/schemas/test_ase.py
+++ b/tests/core/schemas/test_ase.py
@@ -234,10 +234,6 @@ def test_summarize_vib_run(tmp_path, monkeypatch):
     vib = Vibrations(atoms)
     vib.run()
 
-    store = MemoryStore()
-    _summarize_vib_run(vib, store=store)
-    assert store.count() == 1
-
     # Make sure info tags are handled appropriately
     atoms = molecule("N2")
     atoms.info["test_dict"] = {"hi": "there", "foo": "bar"}
@@ -287,9 +283,6 @@ def test_summarize_ideal_gas_thermo(tmp_path, monkeypatch):
     atoms = molecule("N2")
     igt = IdealGasThermo([0.34], "linear", atoms=atoms, spin=0, symmetrynumber=2)
     _summarize_ideal_gas_thermo(igt)
-    store = MemoryStore()
-    _summarize_ideal_gas_thermo(igt, store=store)
-    assert store.count() == 1
 
     # Make sure right number of vib energies are reported
     atoms = molecule("N2")