Skip to content

Commit

Permalink
Compute: Catches error where program key is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
dgasmith committed Oct 30, 2018
1 parent 4aeb6bb commit 5081fb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions qcengine/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import copy
import time
import traceback

from . import config
from . import util

# Single computes
Expand Down Expand Up @@ -46,6 +44,7 @@ def compute(input_data, program, raise_error=False, capture_output=True):
elif program == "rdkit":
output_data = rdkit_compute.run_rdkit(input_data)
else:
output_data = input_data
output_data["success"] = False
output_data["error_message"] = "QCEngine Call Error:\nProgram {} not understood".format(program)

Expand Down Expand Up @@ -75,12 +74,11 @@ def compute_procedure(input_data, procedure, raise_error=False, capture_output=T
input_data = copy.deepcopy(input_data)

# Run the procedure
comp_time = time.time()
with util.compute_wrapper(capture_output=capture_output) as metadata:
output_data = {}
if procedure == "geometric":
output_data = util.get_module_function("geometric", "run_json.geometric_run_json")(input_data)
else:
output_data = input_data
output_data["success"] = False
output_data["error_message"] = "QCEngine Call Error:\nProcedure {} not understood".format(program)

Expand Down
6 changes: 6 additions & 0 deletions qcengine/tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
_base_json = {"schema_name": "qc_schema_input", "schema_version": 1}


def test_missing_key():
ret = dc.compute({"hello": "hi"}, "bleh")
assert ret["success"] is False
assert "hello" in ret


@addons.using_psi4
def test_psi4_task():
json_data = copy.deepcopy(_base_json)
Expand Down

0 comments on commit 5081fb8

Please sign in to comment.