Skip to content

Commit

Permalink
Fix pre-chunking for materials and thermo builder (#264)
Browse files Browse the repository at this point in the history
* Ensure mpid can be pulled from static calcs

* Linting

* Fix prechunking on materials and thermo
  • Loading branch information
Jason Munro authored Sep 9, 2021
1 parent 38e8ce2 commit 2b8363b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions emmet-builders/emmet/builders/vasp/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def prechunk(self, number_splits: int) -> Iterable[Dict]:
}

for formula_chunk in grouper(to_process_forms, number_splits):
yield {"formula_pretty": {"$in": list(formula_chunk)}}
yield {"query": {"formula_pretty": {"$in": list(formula_chunk)}}}

def get_items(self) -> Iterator[List[Dict]]:
"""
Expand Down Expand Up @@ -265,8 +265,7 @@ def update_targets(self, items: List[List[Dict]]):
self.logger.info(f"Updating {len(docs)} materials")
self.materials.remove_docs({self.materials.key: {"$in": material_ids}})
self.materials.update(
docs=docs,
key=["material_id"],
docs=docs, key=["material_id"],
)
else:
self.logger.info("No items to update")
Expand Down
6 changes: 2 additions & 4 deletions emmet-builders/emmet/builders/vasp/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def prechunk(self, number_splits: int) -> Iterable[Dict]:
to_process_chemsys |= chemsys_permutations(chemsys)

for chemsys_chunk in grouper(to_process_chemsys, number_splits):
yield {"chemsys": {"$in": list(chemsys_chunk)}}
yield {"query": {"chemsys": {"$in": list(chemsys_chunk)}}}

def get_items(self) -> Iterator[List[Dict]]:
"""
Expand Down Expand Up @@ -264,9 +264,7 @@ def get_entries(self, chemsys: str) -> List[Dict]:

return all_entries

def get_updated_chemsys(
self,
) -> Set:
def get_updated_chemsys(self,) -> Set:
"""Gets updated chemical system as defined by the updating of an existing material"""

updated_mats = self.thermo.newer_in(self.materials, criteria=self.query)
Expand Down

0 comments on commit 2b8363b

Please sign in to comment.