From 9156312e7847359e7be9548e776a04fc6ebcfd4c Mon Sep 17 00:00:00 2001 From: jmmshn Date: Tue, 2 Mar 2021 23:20:09 -0500 Subject: [PATCH] changed electrode back --- .../emmet/builders/materials/electrodes.py | 60 +++++++------------ 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/emmet-builders/emmet/builders/materials/electrodes.py b/emmet-builders/emmet/builders/materials/electrodes.py index 6b9db42d8f..0fe24de01c 100644 --- a/emmet-builders/emmet/builders/materials/electrodes.py +++ b/emmet-builders/emmet/builders/materials/electrodes.py @@ -160,7 +160,7 @@ def get_items(self): ) ] - self.logger.info( + self.logger.debug( f"Performing initial checks on {len(all_chemsys)} chemical systems containing redox elements with or without the Working Ion." ) self.total = len(all_chemsys) @@ -230,15 +230,8 @@ def get_items(self): f"There are {len(mat_ids)} material ids in the source database vs {len(target_mat_ids)} in the target database." ) if mat_ids == target_mat_ids and max_mat_time < min_target_time: - self.logger.info( - f"Skipping all documents in {chemsys}." - ) - all_mats_in_chemsys = [] continue else: - self.logger.debug(f"MPIDS: {mat_ids} -> {max_mat_time}") - self.logger.debug(f"MPIDS: {target_mat_ids} -> {min_target_time}") - self.logger.debug(f"MPIDS: {target_mat_ids}") self.logger.info( f"Nuking all {len(target_mat_ids)} documents in chemsys {chemsys} in the target database." ) @@ -268,11 +261,6 @@ def _entry_from_mat_doc(self, mdoc): return ComputedStructureEntry.from_dict(d_) def process_item(self, item: Any) -> Any: - self.logger.info( - f"Processing {len(item['materials'])} materials entries in {item['chemsys']}." - ) - if len(item["materials"])==0: - return None entries = [*map(self._entry_from_mat_doc, item["materials"])] s_groups = StructureGroupDoc.from_ungrouped_structure_entries( entries=entries, @@ -293,29 +281,28 @@ def _remove_targets(self, rm_ids): class InsertionElectrodeBuilder(MapBuilder): def __init__( self, - sgroup: MongoStore, - material: MongoStore, + grouped_materials: MongoStore, insertion_electrode: MongoStore, - thermo: MongoStore = None, + thermo: MongoStore, + material: MongoStore, query: dict = None, **kwargs, ): - self.sgroup = sgroup + self.grouped_materials = grouped_materials self.insertion_electrode = insertion_electrode self.thermo = thermo self.material = material qq_ = {} if query is None else query qq_.update({"structure_matched": True, "has_distinct_compositions": True}) super().__init__( - source=self.sgroup, + source=self.grouped_materials, target=self.insertion_electrode, query=qq_, **kwargs, ) def get_items(self): - """ - """ + """""" @lru_cache(None) def get_working_ion_entry(working_ion): @@ -330,20 +317,17 @@ def modify_item(item): self.logger.debug( f"Looking for {len(item['grouped_ids'])} material_id in the Thermo DB." ) - thermo_docs = [] - self.logger.debug(self.thermo) - if self.thermo is not None: - with self.thermo as store: - thermo_docs = [ - *store.query( - { - "$and": [ - {"material_id": {"$in": item["grouped_ids"]}}, - ] - }, - properties=["material_id", "_sbxn", "thermo"], - ) - ] + with self.thermo as store: + thermo_docs = [ + *store.query( + { + "$and": [ + {"material_id": {"$in": item["grouped_ids"]}}, + ] + }, + properties=["material_id", "_sbxn", "thermo"], + ) + ] with self.material as store: material_docs = [ @@ -364,17 +348,13 @@ def modify_item(item): "Insertion electrode can only be defined for one working ion species" ) working_ion_doc = get_working_ion_entry(item["ignored_species"][0]) - - res = { + return { "material_id": item["material_id"], "working_ion_doc": working_ion_doc, "working_ion": item["ignored_species"][0], + "thermo_docs": thermo_docs, "material_docs": material_docs, } - if self.thermo: - resp["thermo_docs"] = thermo_docs - - return res yield from map(modify_item, super().get_items())