From 31b16914be275e6771b66bc16327dee32cb39243 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 19 Jun 2024 17:17:43 -0700 Subject: [PATCH 1/2] Safer MP tests --- src/quacc/wflow_tools/decorators.py | 1 - .../vasp_recipes/mocked/test_vasp_recipes.py | 25 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/quacc/wflow_tools/decorators.py b/src/quacc/wflow_tools/decorators.py index 3794622480..8fe7faa541 100644 --- a/src/quacc/wflow_tools/decorators.py +++ b/src/quacc/wflow_tools/decorators.py @@ -154,7 +154,6 @@ def wrapper(*f_args, **f_kwargs): return _func(*f_args, **f_kwargs) return Delayed_(delayed(wrapper, **kwargs)) - elif SETTINGS.WORKFLOW_ENGINE == "jobflow": from jobflow import job as jf_job diff --git a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py index 0ae4d60912..050d5d3dfa 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -10,6 +10,7 @@ ) # this works locally on Windows, but no clue why it fails on GitHub Actions import logging +from importlib import util from pathlib import Path import numpy as np @@ -38,6 +39,8 @@ from quacc.recipes.vasp.slabs import relax_job as slab_relax_job from quacc.recipes.vasp.slabs import static_job as slab_static_job +has_atomate2 = util.find_spec("atomate2") is not None + FILE_DIR = Path(__file__).parent MOCKED_DIR = FILE_DIR / "mocked_vasp_runs" LOGGER = logging.getLogger(__name__) @@ -449,7 +452,7 @@ def test_qmof(patch_nonmetallic_taskdoc): assert output["double_relax"][0]["parameters"]["isif"] == 2 assert output["double_relax"][1]["parameters"]["isif"] == 2 - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_prerelax_job_metallic(patch_metallic_taskdoc): atoms = bulk("Al") output = mp_metagga_prerelax_job(atoms) @@ -495,7 +498,7 @@ def test_mp_metagga_prerelax_job_metallic(patch_metallic_taskdoc): assert output["parameters"]["pp"] == "pbe" assert "metagga" not in output["parameters"] - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_prerelax_job_nonmetallic(patch_nonmetallic_taskdoc): atoms = bulk("Si") output = mp_metagga_prerelax_job(atoms, prev_dir=MOCKED_DIR / "nonmetallic") @@ -509,7 +512,7 @@ def test_mp_metagga_prerelax_job_nonmetallic(patch_nonmetallic_taskdoc): assert output["parameters"]["pp"] == "pbe" assert "metagga" not in output["parameters"] - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_job_metallic(patch_metallic_taskdoc): atoms = bulk("Al") ref_parameters = { @@ -558,7 +561,7 @@ def test_mp_metagga_relax_job_metallic(patch_metallic_taskdoc): assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "pbe" - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_job_nonmetallic(patch_nonmetallic_taskdoc): atoms = bulk("Si") output = mp_metagga_relax_job(atoms, prev_dir=MOCKED_DIR / "nonmetallic") @@ -571,7 +574,7 @@ def test_mp_metagga_relax_job_nonmetallic(patch_nonmetallic_taskdoc): assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "pbe" - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_static_job(patch_metallic_taskdoc): atoms = bulk("Al") @@ -604,7 +607,7 @@ def test_mp_metagga_static_job(patch_metallic_taskdoc): "setups": {"Al": ""}, } - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_flow_metallic(tmp_path, patch_metallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): copy_r(MOCKED_DIR / "metallic", tmp_path) @@ -625,7 +628,7 @@ def test_mp_metagga_relax_flow_metallic(tmp_path, patch_metallic_taskdoc): assert output["relax2"]["parameters"]["kspacing"] == 0.22 assert output["relax2"]["parameters"]["pp"] == "pbe" - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_flow_nonmetallic(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): copy_r(MOCKED_DIR / "nonmetallic", tmp_path) @@ -671,7 +674,7 @@ def test_mp_metagga_relax_flow_nonmetallic(tmp_path, patch_nonmetallic_taskdoc): assert output["static"]["parameters"]["algo"] == "fast" assert output["static"]["parameters"]["magmom"] == [0.0, 0.0] - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_relax_job(patch_nonmetallic_taskdoc): atoms = bulk("Ni") * (2, 1, 1) atoms[0].symbol = "O" @@ -711,7 +714,7 @@ def test_mp_gga_relax_job(patch_nonmetallic_taskdoc): } assert output["atoms"].get_chemical_symbols() == ["O", "Ni"] - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_static_job(patch_nonmetallic_taskdoc): atoms = bulk("Ni") * (2, 1, 1) atoms[0].symbol = "O" @@ -747,7 +750,7 @@ def test_mp_gga_static_job(patch_nonmetallic_taskdoc): "setups": {"Ni": "_pv", "O": ""}, } - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_relax_flow(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): copy_r(MOCKED_DIR / "nonmetallic", tmp_path) @@ -820,7 +823,7 @@ def test_mp_gga_relax_flow(tmp_path, patch_nonmetallic_taskdoc): "setups": {"Ni": "_pv", "O": ""}, } - +@pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_relax_flow_custom(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): copy_r(MOCKED_DIR / "nonmetallic", tmp_path) From 6d471688e152cbb9d4b38753239219a5e0ef2e7b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:18:09 +0000 Subject: [PATCH 2/2] pre-commit auto-fixes --- .../recipes/vasp_recipes/mocked/test_vasp_recipes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py index 050d5d3dfa..1a65211ed8 100644 --- a/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py +++ b/tests/core/recipes/vasp_recipes/mocked/test_vasp_recipes.py @@ -452,6 +452,7 @@ def test_qmof(patch_nonmetallic_taskdoc): assert output["double_relax"][0]["parameters"]["isif"] == 2 assert output["double_relax"][1]["parameters"]["isif"] == 2 + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_prerelax_job_metallic(patch_metallic_taskdoc): atoms = bulk("Al") @@ -498,6 +499,7 @@ def test_mp_metagga_prerelax_job_metallic(patch_metallic_taskdoc): assert output["parameters"]["pp"] == "pbe" assert "metagga" not in output["parameters"] + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_prerelax_job_nonmetallic(patch_nonmetallic_taskdoc): atoms = bulk("Si") @@ -512,6 +514,7 @@ def test_mp_metagga_prerelax_job_nonmetallic(patch_nonmetallic_taskdoc): assert output["parameters"]["pp"] == "pbe" assert "metagga" not in output["parameters"] + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_job_metallic(patch_metallic_taskdoc): atoms = bulk("Al") @@ -561,6 +564,7 @@ def test_mp_metagga_relax_job_metallic(patch_metallic_taskdoc): assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "pbe" + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_job_nonmetallic(patch_nonmetallic_taskdoc): atoms = bulk("Si") @@ -574,6 +578,7 @@ def test_mp_metagga_relax_job_nonmetallic(patch_nonmetallic_taskdoc): assert output["parameters"]["sigma"] == 0.05 assert output["parameters"]["pp"] == "pbe" + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_static_job(patch_metallic_taskdoc): atoms = bulk("Al") @@ -607,6 +612,7 @@ def test_mp_metagga_static_job(patch_metallic_taskdoc): "setups": {"Al": ""}, } + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_flow_metallic(tmp_path, patch_metallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): @@ -628,6 +634,7 @@ def test_mp_metagga_relax_flow_metallic(tmp_path, patch_metallic_taskdoc): assert output["relax2"]["parameters"]["kspacing"] == 0.22 assert output["relax2"]["parameters"]["pp"] == "pbe" + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_metagga_relax_flow_nonmetallic(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): @@ -674,6 +681,7 @@ def test_mp_metagga_relax_flow_nonmetallic(tmp_path, patch_nonmetallic_taskdoc): assert output["static"]["parameters"]["algo"] == "fast" assert output["static"]["parameters"]["magmom"] == [0.0, 0.0] + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_relax_job(patch_nonmetallic_taskdoc): atoms = bulk("Ni") * (2, 1, 1) @@ -714,6 +722,7 @@ def test_mp_gga_relax_job(patch_nonmetallic_taskdoc): } assert output["atoms"].get_chemical_symbols() == ["O", "Ni"] + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_static_job(patch_nonmetallic_taskdoc): atoms = bulk("Ni") * (2, 1, 1) @@ -750,6 +759,7 @@ def test_mp_gga_static_job(patch_nonmetallic_taskdoc): "setups": {"Ni": "_pv", "O": ""}, } + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_gga_relax_flow(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}): @@ -823,6 +833,7 @@ def test_mp_gga_relax_flow(tmp_path, patch_nonmetallic_taskdoc): "setups": {"Ni": "_pv", "O": ""}, } + @pytest.mark.skipif(not has_atomate2, reason="atomate2 not installed") def test_mp_relax_flow_custom(tmp_path, patch_nonmetallic_taskdoc): with change_settings({"CREATE_UNIQUE_DIR": False, "RESULTS_DIR": tmp_path}):