From 962e837974bef6c377364943a442739312d7af09 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 17 May 2023 11:49:29 -0700 Subject: [PATCH 1/4] add final molecule to schema --- src/atomate2/common/schemas/cclib.py | 1 + tests/common/schemas/test_cclib.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/atomate2/common/schemas/cclib.py b/src/atomate2/common/schemas/cclib.py index 9f8fe6be5..6844951d9 100644 --- a/src/atomate2/common/schemas/cclib.py +++ b/src/atomate2/common/schemas/cclib.py @@ -249,6 +249,7 @@ def from_logfile( attributes=attributes, metadata=metadata, ) + doc["molecule"] = final_molecule doc = doc.copy(update=additional_fields) return doc diff --git a/tests/common/schemas/test_cclib.py b/tests/common/schemas/test_cclib.py index af2f6d939..da480e834 100644 --- a/tests/common/schemas/test_cclib.py +++ b/tests/common/schemas/test_cclib.py @@ -36,6 +36,7 @@ def test_cclib_taskdoc(test_dir): assert doc["attributes"]["molecule_final"][0].coords == pytest.approx( [0.397382, 0.0, 0.0] ) + assert doc["molecule"] == doc["attributes"]["molecule_final"] assert doc["last_updated"] is not None assert doc["attributes"]["homo_energies"] == pytest.approx( [-7.054007346511501, -11.618445074798501] @@ -86,6 +87,7 @@ def test_cclib_taskdoc(test_dir): assert len(doc["attributes"]["trajectory"]) == 7 assert doc["attributes"]["trajectory"][0] == doc["attributes"]["molecule_initial"] assert doc["attributes"]["trajectory"][-1] == doc["attributes"]["molecule_final"] + assert doc["molecule"] == doc["attributes"]["molecule_final"] # Make sure additional fields can be stored doc = TaskDocument.from_logfile(p, ".log", additional_fields={"test": "hi"}) From 58035b6b40ab71eca4e41ce17e56d3ab5c77f530 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 17 May 2023 11:51:21 -0700 Subject: [PATCH 2/4] Update cclib schema --- src/atomate2/common/schemas/cclib.py | 1 - tests/common/schemas/test_cclib.py | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/atomate2/common/schemas/cclib.py b/src/atomate2/common/schemas/cclib.py index 6844951d9..85ae66215 100644 --- a/src/atomate2/common/schemas/cclib.py +++ b/src/atomate2/common/schemas/cclib.py @@ -200,7 +200,6 @@ def from_logfile( initial_molecule = molecules[0] final_molecule = molecules[-1] attributes["molecule_initial"] = initial_molecule - attributes["molecule_final"] = final_molecule if store_trajectory: attributes["trajectory"] = molecules diff --git a/tests/common/schemas/test_cclib.py b/tests/common/schemas/test_cclib.py index da480e834..35fbe59c9 100644 --- a/tests/common/schemas/test_cclib.py +++ b/tests/common/schemas/test_cclib.py @@ -33,10 +33,9 @@ def test_cclib_taskdoc(test_dir): assert doc.get("metadata", None) is not None assert doc["metadata"]["success"] is True assert doc["attributes"]["molecule_initial"][0].coords == pytest.approx([0, 0, 0]) - assert doc["attributes"]["molecule_final"][0].coords == pytest.approx( + assert doc["molecule"][0].coords == pytest.approx( [0.397382, 0.0, 0.0] ) - assert doc["molecule"] == doc["attributes"]["molecule_final"] assert doc["last_updated"] is not None assert doc["attributes"]["homo_energies"] == pytest.approx( [-7.054007346511501, -11.618445074798501] @@ -86,8 +85,7 @@ def test_cclib_taskdoc(test_dir): doc = TaskDocument.from_logfile(p, ".log", store_trajectory=True).dict() assert len(doc["attributes"]["trajectory"]) == 7 assert doc["attributes"]["trajectory"][0] == doc["attributes"]["molecule_initial"] - assert doc["attributes"]["trajectory"][-1] == doc["attributes"]["molecule_final"] - assert doc["molecule"] == doc["attributes"]["molecule_final"] + assert doc["attributes"]["trajectory"][-1] == doc["molecule"] # Make sure additional fields can be stored doc = TaskDocument.from_logfile(p, ".log", additional_fields={"test": "hi"}) From 0d068930cedcde35f59e367d142d45bb03672f88 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 17 May 2023 11:54:33 -0700 Subject: [PATCH 3/4] `black .` --- tests/common/schemas/test_cclib.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/common/schemas/test_cclib.py b/tests/common/schemas/test_cclib.py index 35fbe59c9..a48144749 100644 --- a/tests/common/schemas/test_cclib.py +++ b/tests/common/schemas/test_cclib.py @@ -33,9 +33,7 @@ def test_cclib_taskdoc(test_dir): assert doc.get("metadata", None) is not None assert doc["metadata"]["success"] is True assert doc["attributes"]["molecule_initial"][0].coords == pytest.approx([0, 0, 0]) - assert doc["molecule"][0].coords == pytest.approx( - [0.397382, 0.0, 0.0] - ) + assert doc["molecule"][0].coords == pytest.approx([0.397382, 0.0, 0.0]) assert doc["last_updated"] is not None assert doc["attributes"]["homo_energies"] == pytest.approx( [-7.054007346511501, -11.618445074798501] From 96fa4c72c150ea2c85c1913cde6214a3296dccc4 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 17 May 2023 12:06:03 -0700 Subject: [PATCH 4/4] Fix cclib object --- src/atomate2/common/schemas/cclib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atomate2/common/schemas/cclib.py b/src/atomate2/common/schemas/cclib.py index 85ae66215..8ab42bbbd 100644 --- a/src/atomate2/common/schemas/cclib.py +++ b/src/atomate2/common/schemas/cclib.py @@ -248,7 +248,7 @@ def from_logfile( attributes=attributes, metadata=metadata, ) - doc["molecule"] = final_molecule + doc.molecule = final_molecule doc = doc.copy(update=additional_fields) return doc