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

Add missing molecule field to cclib TaskDocument #353

Merged
merged 4 commits into from
May 23, 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 src/atomate2/common/schemas/cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -249,6 +248,7 @@ def from_logfile(
attributes=attributes,
metadata=metadata,
)
doc.molecule = final_molecule
doc = doc.copy(update=additional_fields)
return doc

Expand Down
6 changes: 2 additions & 4 deletions tests/common/schemas/test_cclib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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["attributes"]["molecule_final"][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]
Expand Down Expand Up @@ -85,7 +83,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["attributes"]["trajectory"][-1] == doc["molecule"]

# Make sure additional fields can be stored
doc = TaskDocument.from_logfile(p, ".log", additional_fields={"test": "hi"})
Expand Down
Loading