Skip to content

Commit

Permalink
fix materials docs / build
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-ephemera committed Mar 20, 2024
1 parent a49c457 commit a9a6622
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 4 additions & 2 deletions emmet-builders/emmet/builders/vasp/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def get_items(self) -> Iterator[List[Dict]]:
invalid_ids = set()

projected_fields = [
"last_updated",
# "last_updated",
"completed_at",
"task_id",
"formula_pretty",
Expand All @@ -195,9 +195,11 @@ def get_items(self) -> Iterator[List[Dict]]:
"input.structure",
# needed for entry from task_doc
"output.energy",
"calcs_reversed.output.energy",
"input.is_hubbard",
"input.hubbards",
"input.potcar_spec",
"calcs_reversed.input.potcar_spec",
"calcs_reversed.output.structure",
# needed for transform deformation structure back for grouping
"transformations",
# misc info for materials doc
Expand Down
12 changes: 9 additions & 3 deletions emmet-core/emmet/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class TaskDoc(StructureMetadata, extra="allow"):
)

last_updated: Optional[datetime] = Field(
None,
datetime.utcnow(),
description="Timestamp for the most recent calculation for this task document",
)

Expand Down Expand Up @@ -437,6 +437,9 @@ def model_post_init(self, __context: Any) -> None:
if self.task_type is None:
self.task_type = task_type(self.orig_inputs)

if self.structure is None:
self.structure = self.calcs_reversed[0].output.structure

# Make sure that the datetime field is properly formatted
# (Unclear when this is not the case, please leave comment if observed)
@field_validator("last_updated", mode="before")
Expand Down Expand Up @@ -662,7 +665,10 @@ def get_entry(
"energy": calcs_reversed[0].output.energy,
"parameters": {
# Cannot be PotcarSpec document, pymatgen expects a dict
"potcar_spec": [dict(d) for d in calcs_reversed[0].input.potcar_spec],
# Note that `potcar_spec` is optional
"potcar_spec": [dict(d) for d in calcs_reversed[0].input.potcar_spec]
if calcs_reversed[0].input.potcar_spec
else [],
# Required to be compatible with MontyEncoder for the ComputedEntry
"run_type": str(calcs_reversed[0].run_type),
"is_hubbard": calcs_reversed[0].input.is_hubbard,
Expand Down Expand Up @@ -716,7 +722,7 @@ def structure_entry(self) -> ComputedStructureEntry:
The TaskDoc.entry with corresponding TaskDoc.structure added.
"""
self.private_structure_entry = ComputedStructureEntry(
structure=self.output.structure,
structure=self.structure,
energy=self.entry.energy,
correction=self.entry.correction,
composition=self.entry.composition,
Expand Down
10 changes: 5 additions & 5 deletions emmet-core/emmet/core/vasp/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from emmet.core.settings import EmmetSettings
from emmet.core.structure import StructureMetadata
from emmet.core.vasp.calc_types import CalcType, RunType, TaskType
from emmet.core.vasp.task_valid import TaskDocument
from emmet.core.tasks import TaskDoc

SETTINGS = EmmetSettings()

Expand Down Expand Up @@ -51,7 +51,7 @@ class MaterialsDoc(CoreMaterialsDoc, StructureMetadata):
@classmethod
def from_tasks(
cls,
task_group: List[TaskDocument],
task_group: List[TaskDoc],
structure_quality_scores: Dict[
str, int
] = SETTINGS.VASP_STRUCTURE_QUALITY_SCORES,
Expand Down Expand Up @@ -101,7 +101,7 @@ def from_tasks(
# Always prefer a static over a structure opt
structure_task_quality_scores = {"Structure Optimization": 1, "Static": 2}

def _structure_eval(task: TaskDocument):
def _structure_eval(task: TaskDoc):
"""
Helper function to order structures optimization and statics calcs by
- Functional Type
Expand Down Expand Up @@ -155,7 +155,7 @@ def _structure_eval(task: TaskDocument):
# Always prefer a static over a structure opt
entry_task_quality_scores = {"Structure Optimization": 1, "Static": 2}

def _entry_eval(task: TaskDocument):
def _entry_eval(task: TaskDoc):
"""
Helper function to order entries and statics calcs by
- Spin polarization
Expand Down Expand Up @@ -222,7 +222,7 @@ def _entry_eval(task: TaskDocument):
@classmethod
def construct_deprecated_material(
cls,
task_group: List[TaskDocument],
task_group: List[TaskDoc],
commercial_license: bool = True,
) -> "MaterialsDoc":
"""
Expand Down

0 comments on commit a9a6622

Please sign in to comment.