From 0e455a3254849000a298b95caf2244cd2a1e5957 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 18 Feb 2019 12:52:22 -0500 Subject: [PATCH 1/3] Psi4: Ensures output always goes to stdout field --- qcengine/programs/psi4.py | 19 ++++++++++++------- qcengine/tests/test_compute.py | 34 +++++++++++++++++----------------- qcengine/util.py | 9 +++++---- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/qcengine/programs/psi4.py b/qcengine/programs/psi4.py index 1635db3d5..f17c3c008 100644 --- a/qcengine/programs/psi4.py +++ b/qcengine/programs/psi4.py @@ -29,10 +29,10 @@ def _parse_psi_version(version): input_data["nthreads"] = config.ncores input_data["memory"] = int(config.memory * 1024 * 1024 * 1024 * 0.95) # Memory in bytes input_data["success"] = False - reset_schema = False + input_data["return_output"] = True + if input_data["schema_name"] == "qcschema_input": input_data["schema_name"] = "qc_schema_input" - reset_schema = True scratch = config.scratch_directory if scratch is not None: @@ -51,8 +51,9 @@ def _parse_psi_version(version): else: raise TypeError("Psi4 version '{}' not understood.".format(psi_version)) - if reset_schema: - output_data["schema_name"] = "qcschema_input" + # Reset the schema if required + output_data["schema_name"] = "qcschema_output" + # Dispatch errors, PSIO Errors are not recoverable for future runs if output_data["success"] is False: @@ -61,9 +62,13 @@ def _parse_psi_version(version): # Move several pieces up a level if output_data["success"]: - output_data["provenance"]["memory"] = round(input_data["memory"] / (1024**3), 3) - output_data["provenance"]["nthreads"] = input_data["nthreads"] - del output_data["memory"], input_data["nthreads"] + output_data["provenance"]["memory"] = round(output_data.pop("memory") / (1024**3), 3) # Move back to GB + output_data["provenance"]["nthreads"] = output_data.pop("nthreads") + output_data["stdout"] = output_data.pop("raw_output", None) + + # Delete keys + output_data.pop("return_ouput", None) + return Result(**output_data) return FailedOperation( success=output_data.pop("success", False), error=output_data.pop("error"), input_data=output_data) diff --git a/qcengine/tests/test_compute.py b/qcengine/tests/test_compute.py index 9c5c50475..b0be3a819 100644 --- a/qcengine/tests/test_compute.py +++ b/qcengine/tests/test_compute.py @@ -29,10 +29,11 @@ def test_psi4_task(): json_data["keywords"] = {"scf_type": "df"} json_data["return_output"] = False - ret = dc.compute(json_data, "psi4", raise_error=True) + ret = dc.compute(json_data, "psi4", raise_error=True, capture_output=False) assert ret["driver"] == "energy" assert "provenance" in ret + assert "Final Energy" in ret["stdout"] for key in ["cpu", "hostname", "username", "wall_time"]: assert key in ret["provenance"] @@ -42,22 +43,21 @@ def test_psi4_task(): @addons.using_psi4 def test_psi4_ref_switch(): - inp = ResultInput( - **{ - "molecule": { - "symbols": ["Li"], - "geometry": [0, 0, 0], - "molecular_multiplicity": 2 - }, - "driver": "energy", - "model": { - "method": "SCF", - "basis": "sto-3g" - }, - "keywords": { - "scf_type": "df" - } - }) + inp = ResultInput(**{ + "molecule": { + "symbols": ["Li"], + "geometry": [0, 0, 0], + "molecular_multiplicity": 2 + }, + "driver": "energy", + "model": { + "method": "SCF", + "basis": "sto-3g" + }, + "keywords": { + "scf_type": "df" + } + }) ret = dc.compute(inp, "psi4", raise_error=True, return_dict=False) diff --git a/qcengine/util.py b/qcengine/util.py index 02f4afdb7..7880a2bb3 100644 --- a/qcengine/util.py +++ b/qcengine/util.py @@ -128,8 +128,10 @@ def handle_output_metadata(output_data, metadata, raise_error=False, return_dict else: output_fusion = output_data.dict() - output_fusion["stdout"] = metadata["stdout"] - output_fusion["stderr"] = metadata["stderr"] + # Do not override if computer generates + output_fusion["stdout"] = output_fusion.pop("stdout", metadata["stdout"]) + output_fusion["stderr"] = output_fusion.pop("stderr", metadata["stderr"]) + if metadata["success"] is not True: output_fusion["success"] = False output_fusion["error"] = {"error_type": "meta_error", "error_message": metadata["error_message"]} @@ -142,9 +144,8 @@ def handle_output_metadata(output_data, metadata, raise_error=False, return_dict raise ValueError(output_fusion["error"]["error_message"]) # Fill out provenance datadata - wall_time = metadata["wall_time"] provenance_augments = config.get_provenance_augments() - provenance_augments["wall_time"] = wall_time + provenance_augments["wall_time"] = metadata["wall_time"] if "provenance" in output_fusion: output_fusion["provenance"].update(provenance_augments) else: From 866e67d3fa6f714d25ea2ad29c0337602722a22b Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 18 Feb 2019 17:18:02 -0500 Subject: [PATCH 2/3] CI: Bumps QCElemental version --- devtools/conda-envs/psi.yaml | 2 +- devtools/conda-envs/rdkit.yaml | 2 +- devtools/conda-envs/torchani.yaml | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/devtools/conda-envs/psi.yaml b/devtools/conda-envs/psi.yaml index f51768409..387749a8e 100644 --- a/devtools/conda-envs/psi.yaml +++ b/devtools/conda-envs/psi.yaml @@ -9,7 +9,7 @@ dependencies: - pyyaml - py-cpuinfo - psutil - - qcelemental >=0.2.2 + - qcelemental >=0.2.6 - pydantic >=0.18.1 # Testing diff --git a/devtools/conda-envs/rdkit.yaml b/devtools/conda-envs/rdkit.yaml index 53a10c736..5bb3d41bf 100644 --- a/devtools/conda-envs/rdkit.yaml +++ b/devtools/conda-envs/rdkit.yaml @@ -9,7 +9,7 @@ dependencies: - pyyaml - py-cpuinfo - psutil - - qcelemental >=0.2.2 + - qcelemental >=0.2.6 - pydantic >=0.18.1 # Testing diff --git a/devtools/conda-envs/torchani.yaml b/devtools/conda-envs/torchani.yaml index 57b08c146..631a386c7 100644 --- a/devtools/conda-envs/torchani.yaml +++ b/devtools/conda-envs/torchani.yaml @@ -10,7 +10,7 @@ dependencies: - pyyaml - py-cpuinfo - psutil - - qcelemental >=0.2.2 + - qcelemental >=0.2.6 - pydantic >=0.18.1 # Testing diff --git a/setup.py b/setup.py index b71f458e8..cf6423b51 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ 'pyyaml', 'py-cpuinfo', 'psutil', - 'qcelemental>=0.2.2', + 'qcelemental>=0.2.6', 'pydantic>=0.18.0' ], entry_points={"console_scripts": [ From fb023864c7593570ef94108c240df7e675bc9caf Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 18 Feb 2019 20:18:46 -0500 Subject: [PATCH 3/3] Changelog v0.5.2 --- docs/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 1c3438d1b..0033a9110 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -21,6 +21,7 @@ Enhancements - (:pr:`24`) Improves load times dramatically by delaying imports and cpuutils. - (:pr:`25`) Code base linting. +- (:pr:`30`) Ensures Psi4 output is already returned and Pydantic v0.20+ changes. v0.5.1 / 2019-01-29 -------------------