Skip to content

Commit

Permalink
fixed validation and setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmshn committed Mar 3, 2021
1 parent 30142b5 commit b123e8a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
9 changes: 7 additions & 2 deletions emmet-builders/emmet/builders/vasp/materials.py
Expand Up @@ -10,7 +10,9 @@
from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher

from emmet.builders.utils import maximal_spanning_non_intersecting_subsets
from emmet.core import SETTINGS

# from emmet.core import SETTINGS
from emmet.builders import SETTINGS
from emmet.core.utils import group_structures, jsanitize
from emmet.core.vasp.calc_types import TaskType
from emmet.core.vasp.material import MaterialsDoc
Expand Down Expand Up @@ -49,6 +51,7 @@ def __init__(
ltol: float = SETTINGS.LTOL,
stol: float = SETTINGS.STOL,
angle_tol: float = SETTINGS.ANGLE_TOL,
build_tags: List[str] = SETTINGS.BUILD_TAGS,
**kwargs,
):
"""
Expand All @@ -75,6 +78,7 @@ def __init__(

self._allowed_task_types = {TaskType(t) for t in self.allowed_task_types}

self.build_tags = build_tags if build_tags else []
self.query = query if query else {}
self.symprec = symprec
self.ltol = ltol
Expand Down Expand Up @@ -132,6 +136,8 @@ def get_items(self) -> Iterator[List[Dict]]:
# Get all processed tasks:
temp_query = dict(self.query)
temp_query["state"] = "successful"
if self.build_tags:
temp_query["tags"] = {"$in": self.build_tags}

self.logger.info("Finding tasks to process")
all_tasks = {
Expand Down Expand Up @@ -183,7 +189,6 @@ def get_items(self) -> Iterator[List[Dict]]:
for formula in to_process_forms:
tasks_query = dict(temp_query)
tasks_query["formula_pretty"] = formula
tasks_query[""]
tasks = list(
self.tasks.query(criteria=tasks_query, properties=projected_fields)
)
Expand Down
1 change: 1 addition & 0 deletions emmet-builders/emmet/builders/vasp/task_validator.py
Expand Up @@ -63,6 +63,7 @@ def unary_function(self, item):
input_sets=self.settings.VASP_DEFAULT_INPUT_SETS,
LDAU_fields=self.settings.VASP_CHECKED_LDAU_FIELDS,
max_allowed_scf_gradient=self.settings.VASP_MAX_SCF_GRADIENT,
deprecated_tags=self.settings.DEPRECATED_TAGS,
)

bad_tags = list(set(task_doc.tags).intersection(self.settings.DEPRECATED_TAGS))
Expand Down
4 changes: 3 additions & 1 deletion emmet-core/emmet/core/settings.py
Expand Up @@ -76,11 +76,13 @@ class Config:
extra = "ignore"

@root_validator(pre=True)
def load_default_settings(cls, values):
def load_default_settings(cls, values: dict = None):
"""
Loads settings from a root file if available and uses that as defaults in
place of built in defaults
"""
if values is None:
values = dict()
config_file_path: str = values.get("config_file", DEFAULT_CONFIG_FILE_PATH)

new_values = {}
Expand Down
6 changes: 6 additions & 0 deletions emmet-core/emmet/core/vasp/validation.py
Expand Up @@ -5,6 +5,7 @@
from pydantic import BaseModel, Field, PyObject
from pymatgen.core import Structure

from emmet.builders import EmmetBuildSettings
from emmet.core import SETTINGS
from emmet.core.mpid import MPID
from emmet.core.utils import DocEnum
Expand Down Expand Up @@ -56,6 +57,7 @@ def from_task_doc(
input_sets: Dict[str, PyObject] = SETTINGS.VASP_DEFAULT_INPUT_SETS,
LDAU_fields: List[str] = SETTINGS.VASP_CHECKED_LDAU_FIELDS,
max_allowed_scf_gradient: float = SETTINGS.VASP_MAX_SCF_GRADIENT,
deprecated_tags: List["str"] = None,
) -> "ValidationDoc":
"""
Determines if a calculation is valid based on expected input parameters from a pymatgen inputset
Expand All @@ -73,6 +75,7 @@ def from_task_doc(

reasons = []
data = {}
dep_tags_ = [] if deprecated_tags is None else deprecated_tags

if task_type in input_sets:
valid_input_set = input_sets[task_type](structure)
Expand Down Expand Up @@ -133,6 +136,9 @@ def from_task_doc(
if max_gradient > max_allowed_scf_gradient:
reasons.append(DeprecationMessage.MAX_SCF)

if set(task_doc.tags) | set(dep_tags_):
reasons.append(DeprecationMessage.MANUAL)

doc = ValidationDoc(
task_id=task_doc.task_id,
task_type=task_doc.task_type,
Expand Down

0 comments on commit b123e8a

Please sign in to comment.