def add_mp_icsd(self, table: str, mp_data: Optional[List[Dict[str, Union[pymatgen.core.Structure, str]]]] = None, mp_api_key: Optional[str] = None) -> int: """Add a table populated with Materials Project-hosted ICSD structures. Note: This is very computationally expensive for large datasets and will not likely run on a laptop. If possible, download a pre-constructed database. Args: table (str): The name of the table to add. mp_data: The Materials Project data to parse. If this is None, data will be downloaded. Downloading data needs `mp_api_key` to be set. mp_api_key (str): A Materials Project API key. Only needed if `mp_data` is None. Returns: The number of structs added. """ if mp_data is None: #pragma: no cover with MPRester(mp_api_key) as m: data = m.query( criteria={'icsd_ids.0': { '$exists': True }}, properties=['structure', 'material_id'], ) else: data = mp_data self.add_table(table) if pathos_available: pool = ParallelPool() parse_iter = pool.uimap(parse_mprest, data) else: #pragma: no cover parse_iter = map(parse_mprest, data) return self.add_structs(parse_iter, table, commit_after_each=True)