@@ -28,7 +28,8 @@ class PropnetBuilder(MapBuilder):
2828 """
2929
3030 def __init__ (self , materials , propstore , materials_symbol_map = None ,
31- criteria = None , source_name = "" , graph_parallel = False ,
31+ criteria = None , source_name = "" , include_deprecated = False ,
32+ graph_parallel = False ,
3233 max_graph_workers = None , graph_timeout = None ,
3334 allow_child_process = False , ** kwargs ):
3435 """
@@ -40,6 +41,11 @@ def __init__(self, materials, propstore, materials_symbol_map=None,
4041 criteria (dict): criteria for Mongodb find() query specifying
4142 criteria for records to process
4243 source_name (str): identifier for record source
44+ include_deprecated (bool): True processes materials marked as
45+ deprecated via the "deprecated" field. False skips those materials.
46+ If an entry does not have the "deprecated" field, it will be processed.
47+ Note that False will create a logical "and" with any criteria specified
48+ in "criteria". Default: False
4349 graph_parallel (bool): True runs the graph algorithm in parallel with
4450 the number of workers specified by max_workers. Default: False (serial)
4551 Note: there will be no substantial speed-up from using a parallel
@@ -64,6 +70,17 @@ def __init__(self, materials, propstore, materials_symbol_map=None,
6470 self .materials = materials
6571 self .propstore = propstore
6672 self .criteria = criteria
73+ self .include_deprecated = include_deprecated
74+ if not include_deprecated :
75+ deprecated_filter = {
76+ "$or" : [{"deprecated" : {"$exists" : False }},
77+ {"deprecated" : False }]
78+ }
79+ if criteria :
80+ self .criteria = {'$and' : [criteria , deprecated_filter ]}
81+ else :
82+ self .criteria = deprecated_filter
83+
6784 self .materials_symbol_map = materials_symbol_map \
6885 or MPRester .mapping
6986 if source_name == "" :
@@ -84,11 +101,12 @@ def __init__(self, materials, propstore, materials_symbol_map=None,
84101 props = list (self .materials_symbol_map .keys ())
85102 props += ["task_id" , "pretty_formula" , "run_type" , "is_hubbard" ,
86103 "pseudo_potential" , "hubbards" , "potcar_symbols" , "oxide_type" ,
87- "final_energy" , "unit_cell_formula" , "created_at" ]
104+ "final_energy" , "unit_cell_formula" , "created_at" , "deprecated" ]
88105 props = list (set (props ))
89106
90107 super (PropnetBuilder , self ).__init__ (source = materials ,
91108 target = propstore ,
109+ query = self .criteria ,
92110 ufn = self .process ,
93111 projection = props ,
94112 ** kwargs )
@@ -180,6 +198,9 @@ def process(self, item):
180198 aggregated_quantities = new_material .get_aggregated_quantities ()
181199
182200 for symbol , quantity in aggregated_quantities .items ():
201+ if symbol .name not in doc :
202+ # No new quantities were derived
203+ continue
183204 # Store mean and std dev for aggregated quantities
184205 sub_doc = {"mean" : unumpy .nominal_values (quantity .value ).tolist (),
185206 "std_dev" : unumpy .std_devs (quantity .value ).tolist (),
@@ -189,7 +210,8 @@ def process(self, item):
189210 doc [symbol .name ].update (sub_doc )
190211
191212 doc .update ({"task_id" : item ["task_id" ],
192- "pretty_formula" : item .get ("pretty_formula" )})
213+ "pretty_formula" : item .get ("pretty_formula" ),
214+ "deprecated" : item .get ("deprecated" , False )})
193215 return jsanitize (doc , strict = True )
194216
195217
0 commit comments