Skip to content

Commit

Permalink
convert tags to sandboxes in builder
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamd committed Sep 29, 2020
1 parent bce263f commit 6f78510
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion emmet-builders/emmet/builders/vasp/materials.py
Expand Up @@ -51,6 +51,7 @@ def __init__(
task_validation: Optional[Store] = None,
query: Optional[Dict] = None,
allowed_task_types: Optional[List[str]] = None,
tags_to_sandoxes: Optional[Dict[str, List[str]]] = None,
symprec: float = SETTINGS.SYMPREC,
ltol: float = SETTINGS.LTOL,
stol: float = SETTINGS.STOL,
Expand All @@ -63,6 +64,7 @@ def __init__(
materials: Store of materials documents to generate
query: dictionary to limit tasks to be analyzed
allowed_task_types: list of task_types that can be processed
tags_to_sandboxes: dictionary mapping sandboxes to a list of tags
symprec: tolerance for SPGLib spacegroup finding
ltol: StructureMatcher tuning parameter for matching tasks to materials
stol: StructureMatcher tuning parameter for matching tasks to materials
Expand All @@ -75,6 +77,7 @@ def __init__(
self.allowed_task_types = {TaskType(t) for t in allowed_task_types} or set(
TaskType
)
self.tags_to_sandoxes = tags_to_sandoxes or SETTINGS.tags_to_sandboxes
self.query = query if query else {}
self.symprec = symprec
self.ltol = ltol
Expand Down Expand Up @@ -170,7 +173,7 @@ def get_items(self) -> Iterator[List[Dict]]:
"output.parameters",
"orig_inputs",
"input.structure",
"sandboxes",
"tags",
]

for formula in to_process_forms:
Expand All @@ -185,6 +188,14 @@ def get_items(self) -> Iterator[List[Dict]]:
else:
t["is_valid"] = True

t["sandboxes"] = [
sandbox
for sandbox in self.tags_to_sandoxes
if any(
tag in t["tags"] for tag in set(self.tags_to_sandoxes[sandbox])
)
]

yield tasks

def process_item(self, tasks: List[Dict]) -> List[Dict]:
Expand Down

0 comments on commit 6f78510

Please sign in to comment.