From 197d414361ba74e9185cfa659a3f52fb2a541571 Mon Sep 17 00:00:00 2001 From: Tyler Mathis <35553152+tsmathis@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:05:57 -0700 Subject: [PATCH 1/3] add completed_at field to TaskDoc --- emmet-core/emmet/core/tasks.py | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/emmet-core/emmet/core/tasks.py b/emmet-core/emmet/core/tasks.py index 1879be666..dba9044c2 100644 --- a/emmet-core/emmet/core/tasks.py +++ b/emmet-core/emmet/core/tasks.py @@ -8,41 +8,36 @@ from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union import numpy as np +from monty.json import MontyDecoder +from monty.serialization import loadfn +from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator +from pymatgen.analysis.structure_analyzer import oxide_type +from pymatgen.core.structure import Structure +from pymatgen.core.trajectory import Trajectory +from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry +from pymatgen.io.vasp import Incar, Kpoints, Poscar +from pymatgen.io.vasp import Potcar as VaspPotcar + from emmet.core.common import convert_datetime from emmet.core.mpid import MPID from emmet.core.structure import StructureMetadata from emmet.core.utils import utcnow from emmet.core.vasp.calc_types import ( CalcType, - calc_type, + RunType, TaskType, + calc_type, run_type, - RunType, task_type, ) from emmet.core.vasp.calculation import ( - CalculationInput, Calculation, + CalculationInput, PotcarSpec, RunStatistics, VaspObject, ) from emmet.core.vasp.task_valid import TaskState -from monty.json import MontyDecoder -from monty.serialization import loadfn -from pydantic import ( - BaseModel, - ConfigDict, - Field, - field_validator, - model_validator, -) -from pymatgen.analysis.structure_analyzer import oxide_type -from pymatgen.core.structure import Structure -from pymatgen.core.trajectory import Trajectory -from pymatgen.entries.computed_entries import ComputedEntry, ComputedStructureEntry -from pymatgen.io.vasp import Incar, Kpoints, Poscar -from pymatgen.io.vasp import Potcar as VaspPotcar monty_decoder = MontyDecoder() logger = logging.getLogger(__name__) @@ -430,6 +425,10 @@ class TaskDoc(StructureMetadata, extra="allow"): description="Timestamp for the most recent calculation for this task document", ) + completed_at: Optional[datetime] = Field( + None, description="Timestamp for when this task was completed" + ) + batch_id: Optional[str] = Field( None, description="Identifier for this calculation; should provide rough information about the calculation origin and purpose.", From 2b80091630a2ec5aed2f7f371ecb5252224a6dd7 Mon Sep 17 00:00:00 2001 From: esoteric-ephemera Date: Wed, 25 Sep 2024 16:47:24 -0700 Subject: [PATCH 2/3] add check for potcar test to be skipped if no POTCAR library available --- emmet-builders/tests/test_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/emmet-builders/tests/test_utils.py b/emmet-builders/tests/test_utils.py index 82d509e10..b0d35076e 100644 --- a/emmet-builders/tests/test_utils.py +++ b/emmet-builders/tests/test_utils.py @@ -68,7 +68,9 @@ def test_get_potcar_stats(method: str, tmp_path): try: potcar_stats = get_potcar_stats(method=method) except Exception as exc: - if "No POTCAR for" in str(exc): + if any( + exc_str in str(exc) for exc_str in ("Set PMG_VASP_PSP_DIR", "No POTCAR for") + ): # No Potcar library available, skip test return else: From 02838e41e0dff6fe4a5dc370e4a4034e8980d3fc Mon Sep 17 00:00:00 2001 From: Tyler Mathis <35553152+tsmathis@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:50:26 -0700 Subject: [PATCH 3/3] bring run_stats in as root level field --- emmet-core/emmet/core/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/emmet-core/emmet/core/tasks.py b/emmet-core/emmet/core/tasks.py index dba9044c2..2d994dd58 100644 --- a/emmet-core/emmet/core/tasks.py +++ b/emmet-core/emmet/core/tasks.py @@ -434,6 +434,11 @@ class TaskDoc(StructureMetadata, extra="allow"): description="Identifier for this calculation; should provide rough information about the calculation origin and purpose.", ) + run_stats: Optional[RunStatistics] = Field( + None, + description="Summary of runtime statistics for each calculation in this task", + ) + # Note that private fields are needed because TaskDoc permits extra info # added to the model, unlike TaskDocument. Because of this, when pydantic looks up # attrs on the model, it searches for them in the model extra dict first, and if it