Skip to content

Commit

Permalink
Fix thermo doc updating (#635)
Browse files Browse the repository at this point in the history
* Fix custom query propogation in corrected entries

* Fix thermo data updating

* Linting
  • Loading branch information
munrojm authored Jan 31, 2023
1 parent 9737617 commit 871e02b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion emmet-builders/emmet/builders/materials/corrected_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def _get_chemsys_to_process(self):
# Use last-updated to find new chemsys
materials_chemsys_dates = {}
for d in self.materials.query(
{"deprecated": False}, properties=[self.corrected_entries.key, self.materials.last_updated_field]
{"deprecated": False, **self.query},
properties=[self.corrected_entries.key, self.materials.last_updated_field]
):

entry = materials_chemsys_dates.get(d[self.corrected_entries.key], None)
Expand Down
14 changes: 8 additions & 6 deletions emmet-builders/emmet/builders/materials/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def process_item(self, item):
if not item:
return None

pd_thermo_doc_pair_list = []

for thermo_type, entry_list in item["entries"].items():

entries = [ComputedStructureEntry.from_dict(entry) for entry in entry_list]
Expand All @@ -145,9 +147,9 @@ def process_item(self, item):
warnings.simplefilter("ignore")
with HiddenPrints():

pd_thermo_doc_pair = self._produce_pair(entries, thermo_type, elements)
pd_thermo_doc_pair_list.append(self._produce_pair(entries, thermo_type, elements))

return pd_thermo_doc_pair
return pd_thermo_doc_pair_list

def _produce_pair(self, pd_entries, thermo_type, elements):
# Produce thermo and phase diagram pair
Expand Down Expand Up @@ -192,11 +194,11 @@ def update_targets(self, items):
"""
Inserts the thermo and phase diagram docs into the thermo collection
Args:
items ([tuple(List[dict],List[dict])]): a list of thermo dictionaries to update
items ([[tuple(List[dict],List[dict])]]): a list of a list of thermo and phase diagram dict pairs to update
"""

thermo_docs = [pair[0] for pair in items]
phase_diagram_docs = [pair[1] for pair in items]
thermo_docs = [pair[0] for pair_list in items for pair in pair_list]
phase_diagram_docs = [pair[1] for pair_list in items for pair in pair_list]

# flatten out lists
thermo_docs = list(filter(None, chain.from_iterable(thermo_docs)))
Expand Down Expand Up @@ -225,7 +227,7 @@ def _get_chemsys_to_process(self):
corrected_entries_chemsys_dates = {
d[self.corrected_entries.key]: d[self.corrected_entries.last_updated_field]
for d in self.corrected_entries.query(
{}, properties=[self.corrected_entries.key, self.corrected_entries.last_updated_field]
self.query, properties=[self.corrected_entries.key, self.corrected_entries.last_updated_field]
)
}

Expand Down

0 comments on commit 871e02b

Please sign in to comment.