-
Notifications
You must be signed in to change notification settings - Fork 62
/
task_validator.py
57 lines (46 loc) · 1.67 KB
/
task_validator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from typing import Dict, List, Union
import numpy as np
from maggma.builders import MapBuilder
from maggma.core import Store
from pymatgen import Structure
from emmet.core import SETTINGS
from emmet.core.vasp.calc_types import run_type, task_type
from emmet.core.vasp.validation import DeprecationMessage, ValidationDoc
from emmet.core.vasp.task import TaskDocument
__author__ = "Shyam Dwaraknath"
__email__ = "shyamd@lbl.gov"
class TaskValidator(MapBuilder):
def __init__(
self,
tasks: Store,
task_validation: Store,
kpts_tolerance: float = SETTINGS.VASP_KPTS_TOLERANCE,
**kwargs,
):
"""
Creates task_types from tasks and type definitions
Args:
tasks: Store of task documents
task_validation: Store of task_types for tasks
input_sets: dictionary of task_type and pymatgen input set to validate against
kpts_tolerance: the minimum kpt density as dictated by the InputSet to require
LDAU_fields: LDAU fields to check for consistency
"""
self.tasks = tasks
self.task_validation = task_validation
self.kpts_tolerance = kpts_tolerance
self.kwargs = kwargs
super().__init__(
source=tasks,
target=task_validation,
projection=["orig_inputs", "output.structure", "input.parameters"],
**kwargs,
)
def unary_function(self, item):
"""
Find the task_type for the item
Args:
item (dict): a (projection of a) task doc
"""
task_doc = TaskDocument(**item)
return ValidationDoc.from_task_doc(task_doc=task_doc).dict()