Skip to content

Commit

Permalink
Merge pull request #971 from esoteric-ephemera/taskdoc
Browse files Browse the repository at this point in the history
TaskDoc refactor
  • Loading branch information
tsmathis authored May 21, 2024
2 parents d9d7d21 + f717131 commit ec4d0b5
Show file tree
Hide file tree
Showing 21 changed files with 213 additions and 71 deletions.
2 changes: 1 addition & 1 deletion emmet-api/requirements/ubuntu-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# emmet-core
# pymatgen-analysis-alloys
Expand Down
2 changes: 1 addition & 1 deletion emmet-api/requirements/ubuntu-latest_py3.11_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# emmet-core
# pymatgen-analysis-alloys
Expand Down
2 changes: 1 addition & 1 deletion emmet-api/requirements/ubuntu-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# emmet-core
# pymatgen-analysis-alloys
Expand Down
16 changes: 10 additions & 6 deletions emmet-builders/emmet/builders/vasp/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from emmet.core.utils import group_structures, jsanitize, undeform_structure
from emmet.core.vasp.calc_types import TaskType
from emmet.core.vasp.material import MaterialsDoc
from emmet.core.vasp.task_valid import TaskDocument
from emmet.core.tasks import TaskDoc

__author__ = "Shyam Dwaraknath <[email protected]>"

Expand Down Expand Up @@ -176,7 +176,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 @@ -190,9 +190,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 Expand Up @@ -222,7 +224,9 @@ def process_item(self, items: List[Dict]) -> List[Dict]:
were processed
"""

tasks = [TaskDocument(**task) for task in items]
tasks = [
TaskDoc(**task) for task in items
] # [TaskDoc(**task) for task in items]
formula = tasks[0].formula_pretty
task_ids = [task.task_id for task in tasks]

Expand Down Expand Up @@ -290,8 +294,8 @@ def update_targets(self, items: List[List[Dict]]):
self.logger.info("No items to update")

def filter_and_group_tasks(
self, tasks: List[TaskDocument], task_transformations: List[Union[Dict, None]]
) -> Iterator[List[TaskDocument]]:
self, tasks: List[TaskDoc], task_transformations: List[Union[Dict, None]]
) -> Iterator[List[TaskDoc]]:
"""
Groups tasks by structure matching
"""
Expand Down
6 changes: 3 additions & 3 deletions emmet-builders/emmet/builders/vasp/task_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from emmet.builders.settings import EmmetBuildSettings
from emmet.builders.utils import get_potcar_stats
from emmet.core.tasks import TaskDoc
from emmet.core.vasp.calc_types.enums import CalcType
from emmet.core.vasp.task_valid import TaskDocument
from emmet.core.vasp.validation import DeprecationMessage, ValidationDoc


Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(
# Set up potcar cache if appropriate
if self.settings.VASP_VALIDATE_POTCAR_STATS:
if not self.potcar_stats:
self.potcar_stats = get_potcar_stats()
self.potcar_stats = get_potcar_stats(strict=False)
else:
self.potcar_stats = None

Expand All @@ -65,7 +65,7 @@ def unary_function(self, item):
Args:
item (dict): a (projection of a) task doc
"""
task_doc = TaskDocument(**item)
task_doc = TaskDoc(**item)
validation_doc = ValidationDoc.from_task_doc(
task_doc=task_doc,
kpts_tolerance=self.settings.VASP_KPTS_TOLERANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# chgnet
# emmet-core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# chgnet
# emmet-core
Expand Down
2 changes: 1 addition & 1 deletion emmet-builders/requirements/ubuntu-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ pygments==2.18.0
# via
# mkdocs-material
# rich
pymatgen==2024.5.1
pymatgen==2024.4.13
# via
# chgnet
# emmet-core
Expand Down
2 changes: 1 addition & 1 deletion emmet-builders/tests/test_corrected_entries_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def thermo_store():

@pytest.fixture
def phase_diagram_store():
return MemoryStore(key="chemsys")
return MemoryStore(key="phase_diagram_id")


def test_corrected_entries_builder(corrected_entries_store, materials_store):
Expand Down
3 changes: 2 additions & 1 deletion emmet-core/emmet/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from emmet.core import __version__
from emmet.core.common import convert_datetime
from emmet.core.utils import utcnow

T = TypeVar("T", bound="EmmetBaseModel")

Expand All @@ -34,7 +35,7 @@ class EmmetMeta(BaseModel):
)

build_date: Optional[datetime] = Field( # type: ignore
default_factory=datetime.utcnow,
default_factory=utcnow,
description="The build date for this document.",
)

Expand Down
Loading

0 comments on commit ec4d0b5

Please sign in to comment.