Skip to content

Commit

Permalink
get around bad serialization loop
Browse files Browse the repository at this point in the history
pymatgen entry serialization deserialization causes problems with dates for now
  • Loading branch information
shyamd committed Jun 24, 2021
1 parent 3c419b7 commit 9109d4a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions emmet-core/emmet/core/vasp/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Core definition of a VASP Task Document """
from typing import Any, ClassVar, Dict, List, Union

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, validator
from pymatgen.analysis.structure_analyzer import oxide_type
from pymatgen.core import Structure
from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry
Expand Down Expand Up @@ -167,7 +167,24 @@ def entry(self) -> ComputedEntry:
@property
def structure_entry(self) -> ComputedStructureEntry:
"""Turns a Task Doc into a ComputedStructureEntry"""
entry_dict = self.entry.as_dict()
entry_dict["structure"] = self.output.structure
entry_dict = {
"correction": 0.0,
"entry_id": self.task_id,
"composition": self.output.structure.composition,
"energy": self.output.energy,
"parameters": {
"potcar_spec": self.input.potcar_spec,
"is_hubbard": self.input.is_hubbard,
"hubbards": self.input.hubbards,
# This is done to be compatible with MontyEncoder for the ComputedEntry
"run_type": str(self.run_type),
},
"data": {
"oxide_type": oxide_type(self.output.structure),
"aspherical": self.input.parameters.get("LASPH", True),
"last_updated": self.last_updated,
},
"structure": self.output.structure,
}

return ComputedStructureEntry.from_dict(entry_dict)

0 comments on commit 9109d4a

Please sign in to comment.