Skip to content

Commit

Permalink
Cleanup to emulate old style returns
Browse files Browse the repository at this point in the history
Ensures the compute dicts are returned as python primatives and let
pydantic serialize the objects

Also ensure output_data exists in all error catching. Told LGTM to
ignore this particular error because its expected
  • Loading branch information
Lnaden committed Jan 28, 2019
1 parent 78cf861 commit 72c545b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions qcengine/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def compute_procedure(input_data,
# Run the procedure
with compute_wrapper(capture_output=capture_output) as metadata:
# Create a base output data in case of errors
output_data = input_data.copy() # lgtm[py/multiple-definition]
if procedure == "geometric":
# Augment the input
geometric_input = input_data.dict()
Expand Down
3 changes: 2 additions & 1 deletion qcengine/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import importlib
import io
import json
import operator
import sys
import time
Expand Down Expand Up @@ -161,6 +162,6 @@ def handle_output_metadata(output_data, metadata, raise_error=False, return_dict
ret = FailedOperation(
success=output_fusion.pop("success", False), error=output_fusion.pop("error"), input_data=output_fusion)
if return_dict:
return ret.dict()
return json.loads(ret.json()) # Use Pydantic to serialize, then reconstruct as Python dict of Python Primals
else:
return ret

0 comments on commit 72c545b

Please sign in to comment.