From 59246e59dbd7e41323029b3ce2978ca975a69995 Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Thu, 27 Jul 2023 20:32:45 +0100 Subject: [PATCH 1/6] add mocked error test --- qcengine/tests/test_harness_canonical.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qcengine/tests/test_harness_canonical.py b/qcengine/tests/test_harness_canonical.py index ca4c19db..5b10c569 100644 --- a/qcengine/tests/test_harness_canonical.py +++ b/qcengine/tests/test_harness_canonical.py @@ -148,3 +148,24 @@ def test_compute_bad_models(program, model): with pytest.raises(qcng.exceptions.InputError) as exc: ret = qcng.compute(inp, program, raise_error=True) + +def test_psi4_restarts(monkeypatch): + """ + Make sure that a random error is raised which can be restarted if psi4 fails with no error message + """ + import msgpack + # create the psi4 task + inp = AtomicInput(molecule=qcng.get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"}) + def mock_execute(*args, **kwargs): + "mock the output of a failed psi4 task with missing error message" + + mock_output = { + "sucess": False, + "outfiles": {"data.msgpack": msgpack.dumps({"missing": "data"})} + } + return True, mock_output + + monkeypatch.setattr("qcengine.programs.psi4.execute", mock_execute) + + with pytest.raises(qcng.exceptions.RandomError): + _ = qcng.compute(input_data=inp, program="psi4", raise_error=True, task_config={"retries": 0}) \ No newline at end of file From 9dfb5970a3861b06480f0dc26e64e167f590dedd Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Thu, 27 Jul 2023 20:36:47 +0100 Subject: [PATCH 2/6] update psi4 error message --- qcengine/programs/psi4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcengine/programs/psi4.py b/qcengine/programs/psi4.py index 7dd4d5e1..45c072fd 100644 --- a/qcengine/programs/psi4.py +++ b/qcengine/programs/psi4.py @@ -108,7 +108,7 @@ def _handle_errors(self, output_data): error_message = output_data["error"]["error_message"] error_type = output_data["error"].get("error_type", "unknown_error") else: - error_message = "Unknown error, error message is not found, possibly segfaulted" + error_message = "Unknown error, error message is not found, possible segmentation fault" error_type = "internal_error" return error_message, error_type From aa14f100ba00f0e0e8db902074287c019d9d24f0 Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Thu, 27 Jul 2023 20:44:56 +0100 Subject: [PATCH 3/6] formatting --- qcengine/programs/psi4.py | 2 +- qcengine/tests/test_harness_canonical.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qcengine/programs/psi4.py b/qcengine/programs/psi4.py index 45c072fd..99b725c6 100644 --- a/qcengine/programs/psi4.py +++ b/qcengine/programs/psi4.py @@ -108,7 +108,7 @@ def _handle_errors(self, output_data): error_message = output_data["error"]["error_message"] error_type = output_data["error"].get("error_type", "unknown_error") else: - error_message = "Unknown error, error message is not found, possible segmentation fault" + error_message = "Unknown error, error message is not found, possible segmentation fault!" error_type = "internal_error" return error_message, error_type diff --git a/qcengine/tests/test_harness_canonical.py b/qcengine/tests/test_harness_canonical.py index 5b10c569..0dea6985 100644 --- a/qcengine/tests/test_harness_canonical.py +++ b/qcengine/tests/test_harness_canonical.py @@ -157,7 +157,9 @@ def test_psi4_restarts(monkeypatch): # create the psi4 task inp = AtomicInput(molecule=qcng.get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"}) def mock_execute(*args, **kwargs): - "mock the output of a failed psi4 task with missing error message" + """ + Mock the output of a failed psi4 task with missing error message. + """ mock_output = { "sucess": False, From 9b814ea61a43faa76f784f1b944620af86f6355b Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Fri, 28 Jul 2023 08:56:31 +0100 Subject: [PATCH 4/6] skip test if psi4 not installed --- qcengine/tests/test_harness_canonical.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qcengine/tests/test_harness_canonical.py b/qcengine/tests/test_harness_canonical.py index 0dea6985..eab62ba5 100644 --- a/qcengine/tests/test_harness_canonical.py +++ b/qcengine/tests/test_harness_canonical.py @@ -1,6 +1,7 @@ """ Tests the DQM compute dispatch module """ +import msgpack import numpy as np import pytest from qcelemental.models import AtomicInput, BasisSet @@ -153,7 +154,9 @@ def test_psi4_restarts(monkeypatch): """ Make sure that a random error is raised which can be restarted if psi4 fails with no error message """ - import msgpack + if not has_program("psi4"): + pytest.skip("Program psi4 not found.") + # create the psi4 task inp = AtomicInput(molecule=qcng.get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"}) def mock_execute(*args, **kwargs): From 895897fe4e598056d3b8674c67212c225fca2d84 Mon Sep 17 00:00:00 2001 From: Josh Horton Date: Fri, 28 Jul 2023 09:20:56 +0100 Subject: [PATCH 5/6] update pydantic maximum version --- devtools/conda-envs/openmm.yaml | 2 +- devtools/conda-envs/qcore.yaml | 2 +- devtools/conda-envs/xtb.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devtools/conda-envs/openmm.yaml b/devtools/conda-envs/openmm.yaml index e47dba7c..ae463022 100644 --- a/devtools/conda-envs/openmm.yaml +++ b/devtools/conda-envs/openmm.yaml @@ -16,7 +16,7 @@ dependencies: - py-cpuinfo - psutil - qcelemental >=0.11.1 - - pydantic >=0.30.1 + - pydantic >=1.8.2 # Testing - pytest diff --git a/devtools/conda-envs/qcore.yaml b/devtools/conda-envs/qcore.yaml index 151a52cc..8e848bc2 100644 --- a/devtools/conda-envs/qcore.yaml +++ b/devtools/conda-envs/qcore.yaml @@ -11,7 +11,7 @@ dependencies: - py-cpuinfo - psutil - qcelemental >=0.24 - - pydantic >=0.30.1 + - pydantic >=1.8.2 - tbb<2021 # Testing diff --git a/devtools/conda-envs/xtb.yaml b/devtools/conda-envs/xtb.yaml index 974f2d02..fb710e50 100644 --- a/devtools/conda-envs/xtb.yaml +++ b/devtools/conda-envs/xtb.yaml @@ -11,7 +11,7 @@ dependencies: - py-cpuinfo - psutil - qcelemental >=0.11.1 - - pydantic >=0.30.1 + - pydantic >=1.8.2 # Extras - gcp-correction From e6dc76168d57f0883d9b0c9cab05a332c6ba63e7 Mon Sep 17 00:00:00 2001 From: "Lori A. Burns" Date: Wed, 2 Aug 2023 18:21:18 -0400 Subject: [PATCH 6/6] lint --- qcengine/tests/test_harness_canonical.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qcengine/tests/test_harness_canonical.py b/qcengine/tests/test_harness_canonical.py index eab62ba5..ed482ceb 100644 --- a/qcengine/tests/test_harness_canonical.py +++ b/qcengine/tests/test_harness_canonical.py @@ -150,6 +150,7 @@ def test_compute_bad_models(program, model): with pytest.raises(qcng.exceptions.InputError) as exc: ret = qcng.compute(inp, program, raise_error=True) + def test_psi4_restarts(monkeypatch): """ Make sure that a random error is raised which can be restarted if psi4 fails with no error message @@ -159,18 +160,16 @@ def test_psi4_restarts(monkeypatch): # create the psi4 task inp = AtomicInput(molecule=qcng.get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"}) + def mock_execute(*args, **kwargs): """ Mock the output of a failed psi4 task with missing error message. """ - mock_output = { - "sucess": False, - "outfiles": {"data.msgpack": msgpack.dumps({"missing": "data"})} - } + mock_output = {"sucess": False, "outfiles": {"data.msgpack": msgpack.dumps({"missing": "data"})}} return True, mock_output monkeypatch.setattr("qcengine.programs.psi4.execute", mock_execute) with pytest.raises(qcng.exceptions.RandomError): - _ = qcng.compute(input_data=inp, program="psi4", raise_error=True, task_config={"retries": 0}) \ No newline at end of file + _ = qcng.compute(input_data=inp, program="psi4", raise_error=True, task_config={"retries": 0})