Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psi4 random fail restarts #409

Merged
merged 6 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devtools/conda-envs/openmm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- py-cpuinfo
- psutil
- qcelemental >=0.11.1
- pydantic >=0.30.1
- pydantic >=1.8.2

# Testing
- pytest
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/qcore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- py-cpuinfo
- psutil
- qcelemental >=0.24
- pydantic >=0.30.1
- pydantic >=1.8.2
- tbb<2021

# Testing
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-envs/xtb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- py-cpuinfo
- psutil
- qcelemental >=0.11.1
- pydantic >=0.30.1
- pydantic >=1.8.2

# Extras
- gcp-correction
Expand Down
2 changes: 1 addition & 1 deletion qcengine/programs/psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions qcengine/tests/test_harness_canonical.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests the DQM compute dispatch module
"""
import msgpack
import numpy as np
import pytest
from qcelemental.models import AtomicInput, BasisSet
Expand Down Expand Up @@ -148,3 +149,27 @@ 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
"""
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):
"""
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})
Loading