diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d8c201e9c..3b43f52aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.7] + +### Changed + +- Recipes now take `Atoms` instead of `Atoms | dict` as input +- Recipes no longer require the use of `fetch_atoms` + +### Removed + +- Removed the `fetch_atoms` function + ## [0.3.6] ### Added diff --git a/pyproject.toml b/pyproject.toml index 2ea9612412..83e6326d56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ defects = ["pymatgen-analysis-defects>=2023.8.22", "shakenbreak>=3.2.0"] jobflow = ["jobflow>=0.1.14", "fireworks>=2.0.3"] newtonnet = ["torch>=2.0.1", "scikit-learn>=1.3.0"] sella = ["sella>=2.3.2"] -parsl = ["parsl>=2023.8.14"] +parsl = ["parsl@git+https://github.com/Parsl/parsl.git@benc-lifted-dict"] prefect = ["prefect>=2.13.1", "prefect-dask>=0.2.4", "dask-jobqueue>=0.8.2"] redun = ["redun>=0.16.2"] tblite = ["tblite[ase]>=0.3.0; platform_system=='Linux'"] diff --git a/src/quacc/__init__.py b/src/quacc/__init__.py index 4ed8e040fa..794443034e 100644 --- a/src/quacc/__init__.py +++ b/src/quacc/__init__.py @@ -7,11 +7,10 @@ from ase import __version__ as ase_version from ase.io.jsonio import decode, encode -from quacc.schemas.atoms import fetch_atoms from quacc.settings import QuaccSettings from quacc.wflow.decorators import flow, job, subflow -__all__ = ["flow", "job", "subflow", "fetch_atoms"] +__all__ = ["flow", "job", "subflow"] def atoms_as_dict(s: Atoms) -> dict: diff --git a/src/quacc/recipes/dftb/core.py b/src/quacc/recipes/dftb/core.py index f1c63df803..89de06cf7c 100644 --- a/src/quacc/recipes/dftb/core.py +++ b/src/quacc/recipes/dftb/core.py @@ -5,7 +5,7 @@ from ase.calculators.dftb import Dftb -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.runners.calc import run_calc from quacc.schemas.ase import summarize_run from quacc.utils.dicts import merge_dicts @@ -24,7 +24,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, method: Literal["GFN1-xTB", "GFN2-xTB", "DFTB"] = "GFN2-xTB", kpts: tuple | list[tuple] | dict | None = None, calc_swaps: dict | None = None, @@ -48,8 +48,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object method Method to use. kpts @@ -89,7 +88,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, method: Literal["GFN1-xTB", "GFN2-xTB", "DFTB"] = "GFN2-xTB", kpts: tuple | list[tuple] | dict | None = None, relax_cell: bool = False, @@ -118,8 +117,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object method Method to use. kpts @@ -165,7 +163,7 @@ def relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, defaults: dict | None = None, calc_swaps: dict | None = None, additional_fields: dict | None = None, @@ -177,8 +175,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object defaults The default calculator parameters to use. calc_swaps @@ -195,7 +192,6 @@ def _base_job( Dictionary of results, specified in [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) flags = merge_dicts(defaults, calc_swaps) atoms.calc = Dftb(**flags) diff --git a/src/quacc/recipes/emt/core.py b/src/quacc/recipes/emt/core.py index b1fbc507a3..4c2b2ee4ef 100644 --- a/src/quacc/recipes/emt/core.py +++ b/src/quacc/recipes/emt/core.py @@ -10,7 +10,7 @@ from ase.calculators.emt import EMT from ase.optimize import FIRE -from quacc import fetch_atoms, job +from quacc import job from quacc.runners.calc import run_ase_opt, run_calc from quacc.schemas.ase import summarize_opt_run, summarize_run from quacc.utils.dicts import merge_dicts @@ -23,7 +23,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, calc_swaps: dict | None = None, copy_files: list[str] | None = None, ) -> RunSchema: @@ -41,8 +41,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object calc_swaps Dictionary of custom kwargs for the EMT calculator. copy_files @@ -53,7 +52,6 @@ def static_job( RunSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) calc_swaps = calc_swaps or {} atoms.calc = EMT(**calc_swaps) @@ -68,7 +66,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, relax_cell: bool = False, calc_swaps: dict | None = None, opt_swaps: dict | None = None, @@ -94,8 +92,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object relax_cell Whether to relax the cell calc_swaps @@ -111,7 +108,6 @@ def relax_job( OptSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_opt_run][] """ - atoms = fetch_atoms(atoms) calc_swaps = calc_swaps or {} opt_defaults = {"fmax": 0.01, "max_steps": 1000, "optimizer": FIRE} diff --git a/src/quacc/recipes/emt/defects.py b/src/quacc/recipes/emt/defects.py index d0ae460471..b961cbb18d 100644 --- a/src/quacc/recipes/emt/defects.py +++ b/src/quacc/recipes/emt/defects.py @@ -5,7 +5,7 @@ from pymatgen.analysis.defects.generators import VacancyGenerator -from quacc import fetch_atoms, flow, job, subflow +from quacc import flow, job, subflow from quacc.atoms.defects import make_defects_from_bulk from quacc.recipes.emt.core import relax_job, static_job @@ -24,7 +24,7 @@ @flow def bulk_to_defects_flow( - atoms: Atoms | dict, + atoms: Atoms, defect_gen: ( AntiSiteGenerator | ChargeInterstitialGenerator @@ -80,7 +80,6 @@ def bulk_to_defects_flow( @job def _make_defects(atoms): - atoms = fetch_atoms(atoms) return make_defects_from_bulk( atoms, defect_gen=defect_gen, @@ -96,7 +95,7 @@ def _relax_distributed(defects): def _relax_and_static_distributed(defects): return [ static_job( - relax_job(defect, **defect_relax_kwargs), + relax_job(defect, **defect_relax_kwargs)["atoms"], **defect_static_kwargs, ) for defect in defects diff --git a/src/quacc/recipes/emt/slabs.py b/src/quacc/recipes/emt/slabs.py index c6c58dec3c..eb1029d156 100644 --- a/src/quacc/recipes/emt/slabs.py +++ b/src/quacc/recipes/emt/slabs.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING -from quacc import fetch_atoms, flow, job, subflow +from quacc import flow, job, subflow from quacc.atoms.slabs import make_slabs_from_bulk from quacc.recipes.emt.core import relax_job, static_job @@ -15,7 +15,7 @@ @flow def bulk_to_slabs_flow( - atoms: Atoms | dict, + atoms: Atoms, make_slabs_kwargs: dict | None = None, run_static: bool = True, slab_relax_kwargs: dict | None = None, @@ -33,8 +33,7 @@ def bulk_to_slabs_flow( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object make_slabs_kwargs Additional keyword arguments to pass to [quacc.atoms.slabs.make_slabs_from_bulk][] @@ -60,7 +59,6 @@ def bulk_to_slabs_flow( @job def _make_slabs(atoms): - atoms = fetch_atoms(atoms) return make_slabs_from_bulk(atoms, **make_slabs_kwargs) @subflow @@ -71,7 +69,7 @@ def _relax_distributed(slabs): def _relax_and_static_distributed(slabs): return [ static_job( - relax_job(slab, **slab_relax_kwargs), + relax_job(slab, **slab_relax_kwargs)["atoms"], **slab_static_kwargs, ) for slab in slabs diff --git a/src/quacc/recipes/gaussian/core.py b/src/quacc/recipes/gaussian/core.py index 393cc19914..6258cbb3fb 100644 --- a/src/quacc/recipes/gaussian/core.py +++ b/src/quacc/recipes/gaussian/core.py @@ -6,7 +6,7 @@ from ase.calculators.gaussian import Gaussian -from quacc import fetch_atoms, job +from quacc import job from quacc.runners.calc import run_calc from quacc.schemas.cclib import cclib_summarize_run from quacc.utils.dicts import merge_dicts @@ -22,7 +22,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, xc: str = "wb97x-d", @@ -59,8 +59,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -148,8 +147,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -200,7 +198,7 @@ def relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, defaults: dict | None = None, @@ -214,8 +212,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -235,7 +232,6 @@ def _base_job( cclibSchema 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) diff --git a/src/quacc/recipes/gulp/core.py b/src/quacc/recipes/gulp/core.py index c67a97e001..bdad0c248e 100644 --- a/src/quacc/recipes/gulp/core.py +++ b/src/quacc/recipes/gulp/core.py @@ -6,7 +6,7 @@ from ase.calculators.gulp import GULP -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.runners.calc import run_calc from quacc.schemas.ase import summarize_run from quacc.utils.dicts import merge_dicts @@ -24,7 +24,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, use_gfnff: bool = True, library: str | None = None, keyword_swaps: dict | None = None, @@ -58,8 +58,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object use_gfnff True if (p)GFN-FF should be used; False if not. library @@ -97,7 +96,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, use_gfnff: bool = True, library: str | None = None, relax_cell: bool = False, @@ -135,8 +134,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object use_gfnff True if (p)GFN-FF should be used; False if not. library @@ -178,7 +176,7 @@ def relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, library: str | None = None, keyword_defaults: dict | None = None, option_defaults: dict | None = None, @@ -193,8 +191,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object library Filename of the potential library file, if required. keyword_defaults @@ -215,7 +212,6 @@ def _base_job( RunSchema Dictionary of results from [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) keyword_defaults = keyword_defaults or {} if not atoms.pbc.any(): diff --git a/src/quacc/recipes/lj/core.py b/src/quacc/recipes/lj/core.py index 3c7f7b3efd..ab271e708b 100644 --- a/src/quacc/recipes/lj/core.py +++ b/src/quacc/recipes/lj/core.py @@ -10,7 +10,7 @@ from ase.calculators.lj import LennardJones from ase.optimize import FIRE -from quacc import fetch_atoms, job +from quacc import job from quacc.builders.thermo import build_ideal_gas from quacc.runners.calc import run_ase_opt, run_ase_vib, run_calc from quacc.schemas.ase import summarize_opt_run, summarize_run, summarize_vib_and_thermo @@ -24,7 +24,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, calc_swaps: dict | None = None, copy_files: list[str] | None = None, ) -> RunSchema: @@ -42,8 +42,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object calc_swaps Dictionary of custom kwargs for the LJ calculator. copy_files @@ -54,7 +53,6 @@ def static_job( RunSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) calc_swaps = calc_swaps or {} atoms.calc = LennardJones(**calc_swaps) @@ -67,7 +65,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, calc_swaps: dict | None = None, opt_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -105,7 +103,6 @@ def relax_job( OptSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) calc_swaps = calc_swaps or {} opt_defaults = {"fmax": 0.01, "max_steps": 1000, "optimizer": FIRE} @@ -119,7 +116,7 @@ def relax_job( @job def freq_job( - atoms: Atoms | dict, + atoms: Atoms, energy: float = 0.0, temperature: float = 298.15, pressure: float = 1.0, @@ -147,8 +144,7 @@ def freq_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object energy Potential energy in eV. If 0, then the output is just the correction. temperature @@ -167,7 +163,6 @@ def freq_job( VibThermoSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_vib_and_thermo][] """ - atoms = fetch_atoms(atoms) calc_swaps = calc_swaps or {} vib_kwargs = vib_kwargs or {} diff --git a/src/quacc/recipes/newtonnet/core.py b/src/quacc/recipes/newtonnet/core.py index 94db0d1617..1a5d100b6e 100644 --- a/src/quacc/recipes/newtonnet/core.py +++ b/src/quacc/recipes/newtonnet/core.py @@ -9,7 +9,7 @@ from ase.vibrations.data import VibrationsData from monty.dev import requires -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.builders.thermo import build_ideal_gas from quacc.runners.calc import run_ase_opt, run_calc from quacc.schemas.ase import ( @@ -43,7 +43,7 @@ class FreqSchema(RunSchema): @job @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") def static_job( - atoms: Atoms | dict, + atoms: Atoms, calc_swaps: dict | None = None, copy_files: list[str] | None = None, ) -> RunSchema: @@ -64,8 +64,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object calc_swaps Dictionary of custom kwargs for the newtonnet calculator. copy_files @@ -76,7 +75,6 @@ def static_job( RunSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) defaults = { "model_path": SETTINGS.NEWTONNET_MODEL_PATH, @@ -97,7 +95,7 @@ def static_job( @job @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") def relax_job( - atoms: Atoms | dict, + atoms: Atoms, calc_swaps: dict | None = None, opt_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -125,8 +123,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object calc_swaps Dictionary of custom kwargs for the newtonnet calculator. opt_swaps @@ -139,7 +136,6 @@ def relax_job( OptSchema Dictionary of results, specified in [quacc.schemas.ase.summarize_opt_run][] """ - atoms = fetch_atoms(atoms) defaults = { "model_path": SETTINGS.NEWTONNET_MODEL_PATH, @@ -161,7 +157,7 @@ def relax_job( @job @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") def freq_job( - atoms: Atoms | dict, + atoms: Atoms, temperature: float = 298.15, pressure: float = 1.0, calc_swaps: dict | None = None, @@ -199,7 +195,6 @@ def freq_job( FreqSchema Dictionary of results """ - atoms = fetch_atoms(atoms) defaults = { "model_path": SETTINGS.NEWTONNET_MODEL_PATH, diff --git a/src/quacc/recipes/newtonnet/ts.py b/src/quacc/recipes/newtonnet/ts.py index ac4cf5bfd6..c4864f1a45 100644 --- a/src/quacc/recipes/newtonnet/ts.py +++ b/src/quacc/recipes/newtonnet/ts.py @@ -7,7 +7,7 @@ from monty.dev import requires -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.recipes.newtonnet.core import _add_stdev_and_hess, freq_job, relax_job from quacc.runners.calc import run_ase_opt from quacc.schemas.ase import summarize_opt_run @@ -46,7 +46,7 @@ class QuasiIRCSchema(OptSchema): @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") @requires(Sella, "Sella must be installed. Refer to the quacc documentation.") def ts_job( - atoms: Atoms | dict, + atoms: Atoms, use_custom_hessian: bool = False, run_freq: bool = True, freq_job_kwargs: dict | None = None, @@ -103,7 +103,6 @@ def ts_job( TSSchema Dictionary of results """ - atoms = fetch_atoms(atoms) freq_job_kwargs = freq_job_kwargs or {} defaults = { @@ -138,7 +137,9 @@ def ts_job( # Run a frequency calculation freq_summary = ( - freq_job.__wrapped__(opt_ts_summary, **freq_job_kwargs) if run_freq else None + freq_job.__wrapped__(opt_ts_summary["atoms"], **freq_job_kwargs) + if run_freq + else None ) opt_ts_summary["freq_job"] = freq_summary @@ -149,7 +150,7 @@ def ts_job( @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") @requires(Sella, "Sella must be installed. Refer to the quacc documentation.") def irc_job( - atoms: Atoms | dict, + atoms: Atoms, direction: Literal["forward", "reverse"] = "forward", run_freq: bool = True, freq_job_kwargs: dict | None = None, @@ -219,7 +220,6 @@ def irc_job( IRCSchema A dictionary containing the IRC summary and thermodynamic summary. """ - atoms = fetch_atoms(atoms) freq_job_kwargs = freq_job_kwargs or {} default_settings = SETTINGS.copy() @@ -260,7 +260,9 @@ def irc_job( # Run frequency job freq_summary = ( - freq_job.__wrapped__(opt_irc_summary, **freq_job_kwargs) if run_freq else None + freq_job.__wrapped__(opt_irc_summary["atoms"], **freq_job_kwargs) + if run_freq + else None ) opt_irc_summary["freq_job"] = freq_summary @@ -271,7 +273,7 @@ def irc_job( @requires(NewtonNet, "NewtonNet must be installed. Refer to the quacc documentation.") @requires(Sella, "Sella must be installed. Refer to the quacc documentation.") def quasi_irc_job( - atoms: Atoms | dict, + atoms: Atoms, direction: Literal["forward", "reverse"] = "forward", run_freq: bool = True, irc_job_kwargs: dict | None = None, @@ -335,11 +337,13 @@ def quasi_irc_job( ) # Run opt - relax_summary = relax_job.__wrapped__(irc_summary, **relax_job_kwargs) + relax_summary = relax_job.__wrapped__(irc_summary["atoms"], **relax_job_kwargs) # Run frequency freq_summary = ( - freq_job.__wrapped__(relax_summary, **freq_job_kwargs) if run_freq else None + freq_job.__wrapped__(relax_summary["atoms"], **freq_job_kwargs) + if run_freq + else None ) relax_summary["freq_job"] = freq_summary relax_summary["irc_job"] = irc_summary diff --git a/src/quacc/recipes/orca/core.py b/src/quacc/recipes/orca/core.py index 961a9db3a7..530744e589 100644 --- a/src/quacc/recipes/orca/core.py +++ b/src/quacc/recipes/orca/core.py @@ -7,7 +7,7 @@ from ase.calculators.orca import ORCA, OrcaProfile -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.runners.calc import run_calc from quacc.schemas.cclib import cclib_summarize_run from quacc.utils.dicts import merge_dicts @@ -24,7 +24,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, xc: str = "wb97x-d3bj", @@ -64,8 +64,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -120,7 +119,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, xc: str = "wb97x-d3bj", @@ -219,7 +218,7 @@ def relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, default_inputs: dict | None = None, @@ -235,8 +234,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -263,7 +261,6 @@ def _base_job( cclibSchema Dictionary of results from [quacc.schemas.cclib.cclib_summarize_run][] """ - atoms = fetch_atoms(atoms) inputs = merge_dicts(default_inputs, input_swaps) blocks = merge_dicts(default_blocks, block_swaps) orcasimpleinput = " ".join(list(inputs.keys())) diff --git a/src/quacc/recipes/psi4/core.py b/src/quacc/recipes/psi4/core.py index 8d13d04624..7a80efca70 100644 --- a/src/quacc/recipes/psi4/core.py +++ b/src/quacc/recipes/psi4/core.py @@ -6,7 +6,7 @@ from ase.calculators.psi4 import Psi4 from monty.dev import requires -from quacc import fetch_atoms, job +from quacc import job from quacc.runners.calc import run_calc from quacc.schemas.ase import summarize_run from quacc.utils.dicts import merge_dicts @@ -25,7 +25,7 @@ @job @requires(psi4, "Psi4 not installed. Try conda install -c psi4 psi4") def static_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97x-v", @@ -55,8 +55,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -98,7 +97,7 @@ def static_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, defaults: dict | None = None, @@ -112,8 +111,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -133,7 +131,6 @@ def _base_job( RunSchema Dictionary of results from [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) flags = merge_dicts(defaults, calc_swaps) atoms.calc = Psi4(**flags) diff --git a/src/quacc/recipes/qchem/core.py b/src/quacc/recipes/qchem/core.py index d1f7a718fe..b6a8885180 100644 --- a/src/quacc/recipes/qchem/core.py +++ b/src/quacc/recipes/qchem/core.py @@ -6,7 +6,7 @@ from ase.optimize import FIRE -from quacc import SETTINGS, fetch_atoms, job +from quacc import SETTINGS, job from quacc.calculators.qchem import QChem from quacc.runners.calc import run_ase_opt, run_calc from quacc.schemas.ase import summarize_opt_run, summarize_run @@ -27,7 +27,7 @@ @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97mv", @@ -67,8 +67,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -133,7 +132,7 @@ def static_job( @job def internal_relax_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97mv", @@ -173,8 +172,7 @@ def internal_relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -239,7 +237,7 @@ def internal_relax_job( @job def freq_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97mv", @@ -279,8 +277,7 @@ def freq_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -345,7 +342,7 @@ def freq_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97mv", @@ -391,8 +388,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -466,7 +462,7 @@ def relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, defaults: dict | None = None, @@ -480,8 +476,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -499,7 +494,6 @@ def _base_job( Dictionary of results from [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) qchem_flags = remove_dict_empties(defaults) atoms.calc = QChem(atoms, **qchem_flags) @@ -514,7 +508,7 @@ def _base_job( def _base_opt_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, qchem_defaults: dict | None = None, @@ -529,8 +523,7 @@ def _base_opt_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -552,8 +545,6 @@ def _base_opt_job( # TODO: # - passing initial Hessian? - atoms = fetch_atoms(atoms) - qchem_flags = remove_dict_empties(qchem_defaults) opt_flags = merge_dicts(opt_defaults, opt_swaps) diff --git a/src/quacc/recipes/qchem/ts.py b/src/quacc/recipes/qchem/ts.py index 9fba5f3beb..29c7192c1f 100644 --- a/src/quacc/recipes/qchem/ts.py +++ b/src/quacc/recipes/qchem/ts.py @@ -31,7 +31,7 @@ "Sella must be installed. Refer to the quacc documentation.", ) def ts_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, method: str = "wb97mv", @@ -77,8 +77,7 @@ def ts_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -160,7 +159,7 @@ def ts_job( "Sella must be installed. Refer to the quacc documentation.", ) def irc_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, direction: Literal["forward", "reverse"] = "forward", @@ -207,8 +206,7 @@ def irc_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object charge Charge of the system. spin_multiplicity @@ -292,7 +290,7 @@ def irc_job( "Sella must be installed. Refer to the quacc documentation.", ) def quasi_irc_job( - atoms: Atoms | dict, + atoms: Atoms, charge: int, spin_multiplicity: int, direction: Literal["forward", "reverse"] = "forward", @@ -374,7 +372,7 @@ def quasi_irc_job( SETTINGS.CHECK_CONVERGENCE = default_settings.CHECK_CONVERGENCE relax_summary = relax_job.__wrapped__( - irc_summary, + irc_summary["atoms"], charge, spin_multiplicity, method=method, diff --git a/src/quacc/recipes/tblite/core.py b/src/quacc/recipes/tblite/core.py index 247d0e230c..cb4359630b 100644 --- a/src/quacc/recipes/tblite/core.py +++ b/src/quacc/recipes/tblite/core.py @@ -6,7 +6,7 @@ from ase.optimize import FIRE from monty.dev import requires -from quacc import fetch_atoms, job +from quacc import job from quacc.builders.thermo import build_ideal_gas from quacc.runners.calc import run_ase_opt, run_ase_vib, run_calc from quacc.schemas.ase import summarize_opt_run, summarize_run, summarize_vib_and_thermo @@ -28,7 +28,7 @@ @job @requires(TBLite, "tblite must be installed. Refer to the quacc documentation.") def static_job( - atoms: Atoms | dict, + atoms: Atoms, method: Literal["GFN1-xTB", "GFN2-xTB", "IPEA1-xTB"] = "GFN2-xTB", calc_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -47,8 +47,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object method GFN1-xTB, GFN2-xTB, and IPEA1-xTB. calc_swaps @@ -61,7 +60,6 @@ def static_job( RunSchema Dictionary of results from [quacc.schemas.ase.summarize_run][] """ - atoms = fetch_atoms(atoms) defaults = {"method": method} flags = merge_dicts(defaults, calc_swaps) @@ -78,7 +76,7 @@ def static_job( @job @requires(TBLite, "tblite must be installed. Refer to the quacc documentation.") def relax_job( - atoms: Atoms | dict, + atoms: Atoms, method: Literal["GFN1-xTB", "GFN2-xTB", "IPEA1-xTB"] = "GFN2-xTB", relax_cell: bool = False, calc_swaps: dict | None = None, @@ -105,8 +103,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object method GFN0-xTB, GFN1-xTB, GFN2-xTB. relax_cell @@ -123,7 +120,6 @@ def relax_job( OptSchema Dictionary of results from [quacc.schemas.ase.summarize_opt_run][] """ - atoms = fetch_atoms(atoms) defaults = {"method": method} flags = merge_dicts(defaults, calc_swaps) @@ -140,7 +136,7 @@ def relax_job( @job @requires(TBLite, "tblite must be installed. Refer to the quacc documentation.") def freq_job( - atoms: Atoms | dict, + atoms: Atoms, method: Literal["GFN1-xTB", "GFN2-xTB", "IPEA1-xTB"] = "GFN2-xTB", energy: float = 0.0, temperature: float = 298.15, @@ -169,8 +165,7 @@ def freq_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object method GFN0-xTB, GFN1-xTB, GFN2-xTB, GFN-FF. energy @@ -191,7 +186,6 @@ def freq_job( VibThermoSchema Dictionary of results from [quacc.schemas.ase.summarize_vib_and_thermo][] """ - atoms = fetch_atoms(atoms) vib_kwargs = vib_kwargs or {} defaults = {"method": method} diff --git a/src/quacc/recipes/vasp/core.py b/src/quacc/recipes/vasp/core.py index b3b4830b0b..bb53b5b202 100644 --- a/src/quacc/recipes/vasp/core.py +++ b/src/quacc/recipes/vasp/core.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING -from quacc import fetch_atoms, job +from quacc import job from quacc.calculators.vasp import Vasp from quacc.runners.calc import run_calc from quacc.schemas.vasp import vasp_summarize_run @@ -20,7 +20,7 @@ class DoubleRelaxSchema(VaspSchema): @job def static_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "BulkSet", calc_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -47,8 +47,7 @@ def static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. calc_swaps @@ -84,7 +83,7 @@ def static_job( @job def relax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "BulkSet", relax_cell: bool = True, calc_swaps: dict | None = None, @@ -113,8 +112,7 @@ def relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. relax_cell @@ -154,7 +152,7 @@ def relax_job( @job def double_relax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "BulkSet", relax_cell: bool = True, calc_swaps1: dict | None = None, @@ -175,8 +173,7 @@ def double_relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. relax_cell @@ -206,7 +203,7 @@ def double_relax_job( # Run second relaxation summary2 = relax_job.__wrapped__( - summary1, + summary1["atoms"], preset=preset, relax_cell=relax_cell, calc_swaps=calc_swaps2, @@ -218,7 +215,7 @@ def double_relax_job( def _base_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = None, defaults: dict | None = None, calc_swaps: dict | None = None, @@ -232,8 +229,7 @@ def _base_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. defaults @@ -251,7 +247,6 @@ def _base_job( VaspSchema Dictionary of results from [quacc.schemas.vasp.vasp_summarize_run][] """ - atoms = fetch_atoms(atoms) flags = merge_dicts(defaults, calc_swaps, remove_nones=False) atoms.calc = Vasp(atoms, preset=preset, **flags) diff --git a/src/quacc/recipes/vasp/mp.py b/src/quacc/recipes/vasp/mp.py index 75132b1225..59ad54c1ad 100644 --- a/src/quacc/recipes/vasp/mp.py +++ b/src/quacc/recipes/vasp/mp.py @@ -33,7 +33,7 @@ class MPRelaxFlowSchema(VaspSchema): @job def mp_prerelax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "MPScanSet", bandgap: float = None, calc_swaps: dict | None = None, @@ -54,8 +54,7 @@ def mp_prerelax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. bandgap @@ -91,7 +90,7 @@ def mp_prerelax_job( @job def mp_relax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "MPScanSet", bandgap: float = None, calc_swaps: dict | None = None, @@ -112,8 +111,7 @@ def mp_relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. bandgap @@ -143,7 +141,7 @@ def mp_relax_job( @flow def mp_relax_flow( - atoms: Atoms | dict, + atoms: Atoms, prerelax_job_kwargs: dict | None = None, relax_job_kwargs: dict | None = None, ) -> MPRelaxFlowSchema: @@ -176,7 +174,7 @@ def mp_relax_flow( # Run the relax relax_results = mp_relax_job( - prerelax_results, + prerelax_results["atoms"], bandgap=prerelax_results["output"]["bandgap"], copy_files=["CHGCAR", "WAVECAR"], **relax_job_kwargs, diff --git a/src/quacc/recipes/vasp/qmof.py b/src/quacc/recipes/vasp/qmof.py index d7b39d5400..e1375a8490 100644 --- a/src/quacc/recipes/vasp/qmof.py +++ b/src/quacc/recipes/vasp/qmof.py @@ -10,7 +10,7 @@ from ase.optimize import BFGSLineSearch -from quacc import fetch_atoms, job +from quacc import job from quacc.calculators.vasp import Vasp from quacc.recipes.vasp.core import _base_job from quacc.runners.calc import run_ase_opt @@ -32,7 +32,7 @@ class QMOFRelaxSchema(VaspSchema): @job def qmof_relax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "QMOFSet", relax_cell: bool = True, run_prerelax: bool = True, @@ -56,8 +56,7 @@ def qmof_relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. Applies for all jobs. relax_cell @@ -76,7 +75,6 @@ def qmof_relax_job( QMOFRelaxSchema Dictionary of results """ - atoms = fetch_atoms(atoms) # 1. Pre-relaxation if run_prerelax: diff --git a/src/quacc/recipes/vasp/slabs.py b/src/quacc/recipes/vasp/slabs.py index f61ef1b730..768f1b94ee 100644 --- a/src/quacc/recipes/vasp/slabs.py +++ b/src/quacc/recipes/vasp/slabs.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING -from quacc import fetch_atoms, flow, job, subflow +from quacc import flow, job, subflow from quacc.atoms.slabs import make_adsorbate_structures, make_slabs_from_bulk from quacc.recipes.vasp.core import _base_job @@ -15,7 +15,7 @@ @job def slab_static_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "SlabSet", calc_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -44,8 +44,7 @@ def slab_static_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. calc_swaps @@ -83,7 +82,7 @@ def slab_static_job( @job def slab_relax_job( - atoms: Atoms | dict, + atoms: Atoms, preset: str | None = "SlabSet", calc_swaps: dict | None = None, copy_files: list[str] | None = None, @@ -112,8 +111,7 @@ def slab_relax_job( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object preset Preset to use from `quacc.calculators.presets.vasp`. calc_swaps @@ -151,7 +149,7 @@ def slab_relax_job( @flow def bulk_to_slabs_flow( - atoms: Atoms | dict, + atoms: Atoms, make_slabs_kwargs: dict | None = None, run_static: bool = True, slab_relax_kwargs: dict | None = None, @@ -169,8 +167,7 @@ def bulk_to_slabs_flow( Parameters ---------- atoms - Atoms object or a dictionary with the key "atoms" and an Atoms object as - the value + Atoms object make_slabs_kwargs Additional keyword arguments to pass to [quacc.atoms.slabs.make_slabs_from_bulk][] run_static @@ -191,7 +188,6 @@ def bulk_to_slabs_flow( @job def _make_slabs(atoms): - atoms = fetch_atoms(atoms) return make_slabs_from_bulk(atoms, **make_slabs_kwargs) @subflow @@ -202,7 +198,7 @@ def _relax_distributed(slabs): def _relax_and_static_distributed(slabs): return [ slab_static_job( - slab_relax_job(slab, **slab_relax_kwargs), + slab_relax_job(slab, **slab_relax_kwargs)["atoms"], **slab_static_kwargs, ) for slab in slabs @@ -257,7 +253,6 @@ def slab_to_ads_flow( @job def _make_ads_slabs(atoms, adsorbate): - atoms = fetch_atoms(atoms) return make_adsorbate_structures(atoms, adsorbate, **make_ads_kwargs) @subflow @@ -268,7 +263,7 @@ def _relax_distributed(slabs): def _relax_and_static_distributed(slabs): return [ slab_static_job( - slab_relax_job(slab, **slab_relax_kwargs), + slab_relax_job(slab, **slab_relax_kwargs)["atoms"], **slab_static_kwargs, ) for slab in slabs diff --git a/src/quacc/schemas/atoms.py b/src/quacc/schemas/atoms.py index 9a91ecca13..a465b24fd3 100644 --- a/src/quacc/schemas/atoms.py +++ b/src/quacc/schemas/atoms.py @@ -210,37 +210,6 @@ def atoms_to_metadata( return sort_dict(atoms_doc) -def fetch_atoms(atoms: Atoms | dict) -> Atoms: - """ - Returns an Atoms object from a typical quacc recipe input, which can either - be an `Atoms` object or a dictionary with an entry `{"atoms": Atoms}`. It - may seem a bit silly to do this, but there is a purpose. If you want to - write a workflow where the output of one recipe is passed to the input of - another recipe, you can always do `output["atoms"]` to fetch the output - Atoms object to pass to the input to the second function. However, this - process will often be its own compute step in workflow management tools - because they need to resolve the output in order to query it. Depending on - the workflow manager, this can be a waste of compute resources, so it's - oftentimes better to do this parsing inside the compute task itself, which - is why passing in the raw dictionary can be preferred. - - Parameters - ---------- - atoms - Atoms object or dictionary with an entry `{"atoms": Atoms}` - - Returns - ------- - Atoms - Atoms object - """ - - try: - return atoms["atoms"] - except Exception: - return atoms - - def _quacc_sanitize(obj: Any) -> Any: """ Sanitizes an object for storage in MongoDB. diff --git a/tests/covalent/test_covalent_tutorials.py b/tests/covalent/test_covalent_tutorials.py index f21ad84f04..da40400928 100644 --- a/tests/covalent/test_covalent_tutorials.py +++ b/tests/covalent/test_covalent_tutorials.py @@ -85,7 +85,7 @@ def workflow(atoms): result1 = relax_job(atoms) # (2)! # Define Job 2, which takes the output of Job 1 as input - return static_job(result1) + return static_job(result1["atoms"]) # Make an Atoms object of a bulk Cu structure atoms = bulk("Cu") @@ -140,7 +140,7 @@ def test_tutorial2c(tmpdir): @flow def workflow(atoms): relaxed_bulk = relax_job(atoms) - return bulk_to_slabs_flow(relaxed_bulk, run_static=False) # (1)! + return bulk_to_slabs_flow(relaxed_bulk["atoms"], run_static=False) # (1)! atoms = bulk("Cu") dispatch_id = ct.dispatch(workflow)(atoms) @@ -159,7 +159,7 @@ def test_tutorial_excecutor1(tmpdir): @flow(executor="local") def workflow4(atoms): result1 = relax_job(atoms) - return static_job(result1) + return static_job(result1["atoms"]) atoms = bulk("Cu") dispatch_id = ct.dispatch(workflow4)(atoms) @@ -181,7 +181,7 @@ def test_tutorial_excecutor2(tmpdir): @flow def workflow5(atoms): output1 = relax_job(atoms) - return static_job(output1) + return static_job(output1["atoms"]) atoms = bulk("Cu") dispatch_id = ct.dispatch(workflow5)(atoms) diff --git a/tests/parsl/test_parsl_tutorials.py b/tests/parsl/test_parsl_tutorials.py index 069d45d22c..7a461f591a 100644 --- a/tests/parsl/test_parsl_tutorials.py +++ b/tests/parsl/test_parsl_tutorials.py @@ -80,7 +80,7 @@ def workflow(atoms): future1 = relax_job(atoms) # (1)! # Define Job 2, which takes the output of Job 1 as input - return static_job(future1) + return static_job(future1["atoms"]) # Make an Atoms object of a bulk Cu structure atoms = bulk("Cu") @@ -135,7 +135,7 @@ def test_tutorial2c(tmpdir): # Define the workflow def workflow(atoms): relaxed_bulk = relax_job(atoms) - return bulk_to_slabs_flow(relaxed_bulk, run_static=False) # (1)! + return bulk_to_slabs_flow(relaxed_bulk["atoms"], run_static=False) # (1)! # Define the Atoms object atoms = bulk("Cu") diff --git a/tests/recipes/lj_recipes/test_lj_recipes.py b/tests/recipes/lj_recipes/test_lj_recipes.py index 567c6833c8..01c317c8a3 100644 --- a/tests/recipes/lj_recipes/test_lj_recipes.py +++ b/tests/recipes/lj_recipes/test_lj_recipes.py @@ -79,7 +79,7 @@ def test_freq_job(tmpdir): atoms = molecule("H2O") - output = freq_job(relax_job(atoms)) + output = freq_job(relax_job(atoms)["atoms"]) assert output["natoms"] == len(atoms) assert output["parameters"]["epsilon"] == 1.0 assert output["parameters"]["sigma"] == 1.0 diff --git a/tests/redun/test_redun_tutorials.py b/tests/redun/test_redun_tutorials.py index e0bf0f3813..e0f1dda6e7 100644 --- a/tests/redun/test_redun_tutorials.py +++ b/tests/redun/test_redun_tutorials.py @@ -59,7 +59,7 @@ def test_tutorial2a(tmpdir, scheduler): @flow def workflow(atoms): result1 = relax_job(atoms) # (1)! - return static_job(result1) # (2)! + return static_job(result1["atoms"]) # (2)! atoms = bulk("Cu") @@ -104,7 +104,7 @@ def test_tutorial2c(tmpdir, scheduler): @flow def workflow(atoms): relaxed_bulk = relax_job(atoms) - return bulk_to_slabs_flow(relaxed_bulk, run_static=False) # (1)! + return bulk_to_slabs_flow(relaxed_bulk["atoms"], run_static=False) # (1)! # Define the Atoms object atoms = bulk("Cu") diff --git a/tests/requirements-parsl.txt b/tests/requirements-parsl.txt index d8ccb491f9..edb6a84836 100644 --- a/tests/requirements-parsl.txt +++ b/tests/requirements-parsl.txt @@ -1 +1 @@ -parsl==2023.10.2 \ No newline at end of file +git+https://github.com/Parsl/parsl.git@benc-lifted-dict \ No newline at end of file