emmet-builders 0.84.7rc4__py3-none-any.whl → 0.84.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of emmet-builders might be problematic. Click here for more details.

Files changed (41) hide show
  1. emmet/builders/abinit/phonon.py +15 -11
  2. emmet/builders/abinit/sound_velocity.py +14 -10
  3. emmet/builders/feff/xas.py +1 -2
  4. emmet/builders/materials/absorption_spectrum.py +9 -4
  5. emmet/builders/materials/alloys.py +2 -3
  6. emmet/builders/materials/chemenv.py +2 -3
  7. emmet/builders/materials/corrected_entries.py +14 -8
  8. emmet/builders/materials/dielectric.py +9 -4
  9. emmet/builders/materials/elasticity.py +32 -25
  10. emmet/builders/materials/electrodes.py +23 -18
  11. emmet/builders/materials/electronic_structure.py +16 -16
  12. emmet/builders/materials/magnetism.py +9 -3
  13. emmet/builders/materials/ml.py +9 -11
  14. emmet/builders/materials/optimade.py +7 -3
  15. emmet/builders/materials/piezoelectric.py +1 -2
  16. emmet/builders/materials/provenance.py +11 -7
  17. emmet/builders/materials/robocrys.py +2 -3
  18. emmet/builders/materials/substrates.py +8 -7
  19. emmet/builders/materials/thermo.py +17 -11
  20. emmet/builders/matscholar/missing_compositions.py +12 -8
  21. emmet/builders/mobility/migration_graph.py +5 -5
  22. emmet/builders/molecules/atomic.py +27 -22
  23. emmet/builders/molecules/bonds.py +17 -12
  24. emmet/builders/molecules/electric.py +16 -11
  25. emmet/builders/molecules/metal_binding.py +19 -16
  26. emmet/builders/molecules/orbitals.py +15 -11
  27. emmet/builders/molecules/redox.py +27 -21
  28. emmet/builders/molecules/summary.py +21 -13
  29. emmet/builders/molecules/thermo.py +20 -15
  30. emmet/builders/molecules/trajectory.py +23 -18
  31. emmet/builders/molecules/vibration.py +15 -11
  32. emmet/builders/qchem/molecules.py +37 -32
  33. emmet/builders/settings.py +7 -8
  34. emmet/builders/utils.py +11 -7
  35. emmet/builders/vasp/materials.py +17 -11
  36. emmet/builders/vasp/task_validator.py +3 -5
  37. {emmet_builders-0.84.7rc4.dist-info → emmet_builders-0.84.9.dist-info}/METADATA +1 -1
  38. emmet_builders-0.84.9.dist-info/RECORD +54 -0
  39. emmet_builders-0.84.7rc4.dist-info/RECORD +0 -54
  40. {emmet_builders-0.84.7rc4.dist-info → emmet_builders-0.84.9.dist-info}/WHEEL +0 -0
  41. {emmet_builders-0.84.7rc4.dist-info → emmet_builders-0.84.9.dist-info}/top_level.txt +0 -0
@@ -1,24 +1,29 @@
1
+ from __future__ import annotations
2
+
1
3
  from collections import defaultdict
2
4
  from datetime import datetime
3
5
  from itertools import chain
4
6
  from math import ceil
5
- from typing import Optional, Iterable, Iterator, List, Dict
6
7
 
7
8
  from maggma.builders import Builder
8
9
  from maggma.core import Store
9
10
  from maggma.utils import grouper
10
11
 
11
- from emmet.core.qchem.task import TaskDocument
12
- from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
12
+ from emmet.builders.settings import EmmetBuildSettings
13
13
  from emmet.core.molecules.atomic import (
14
- PartialChargesDoc,
15
- PartialSpinsDoc,
16
14
  CHARGES_METHODS,
17
15
  SPINS_METHODS,
16
+ PartialChargesDoc,
17
+ PartialSpinsDoc,
18
18
  )
19
+ from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
20
+ from emmet.core.qchem.task import TaskDocument
19
21
  from emmet.core.utils import jsanitize
20
- from emmet.builders.settings import EmmetBuildSettings
21
22
 
23
+ from typing import TYPE_CHECKING
24
+
25
+ if TYPE_CHECKING:
26
+ from collections.abc import Iterable, Iterator
22
27
 
23
28
  __author__ = "Evan Spotte-Smith"
24
29
 
@@ -55,9 +60,9 @@ class PartialChargesBuilder(Builder):
55
60
  tasks: Store,
56
61
  molecules: Store,
57
62
  charges: Store,
58
- query: Optional[Dict] = None,
59
- methods: Optional[List] = None,
60
- settings: Optional[EmmetBuildSettings] = None,
63
+ query: dict | None = None,
64
+ methods: list | None = None,
65
+ settings: EmmetBuildSettings | None = None,
61
66
  **kwargs,
62
67
  ):
63
68
  self.tasks = tasks
@@ -105,7 +110,7 @@ class PartialChargesBuilder(Builder):
105
110
  self.charges.ensure_index("last_updated")
106
111
  self.charges.ensure_index("formula_alphabetical")
107
112
 
108
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
113
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
109
114
  """Prechunk the builder for distributed computation"""
110
115
 
111
116
  temp_query = dict(self.query)
@@ -131,7 +136,7 @@ class PartialChargesBuilder(Builder):
131
136
  query["species_hash"] = {"$in": list(hash_chunk)}
132
137
  yield {"query": query}
133
138
 
134
- def get_items(self) -> Iterator[List[Dict]]:
139
+ def get_items(self) -> Iterator[list[dict]]:
135
140
  """
136
141
  Gets all items to process into partial charges documents.
137
142
  This does no datetime checking; relying on on whether
@@ -178,12 +183,12 @@ class PartialChargesBuilder(Builder):
178
183
 
179
184
  yield molecules
180
185
 
181
- def process_item(self, items: List[Dict]) -> List[Dict]:
186
+ def process_item(self, items: list[dict]) -> list[dict]:
182
187
  """
183
188
  Process the tasks into PartialChargesDocs
184
189
 
185
190
  Args:
186
- tasks List[Dict] : a list of MoleculeDocs in dict form
191
+ tasks list[dict] : a list of MoleculeDocs in dict form
187
192
 
188
193
  Returns:
189
194
  [dict] : a list of new partial charges docs
@@ -275,7 +280,7 @@ class PartialChargesBuilder(Builder):
275
280
 
276
281
  return jsanitize([doc.model_dump() for doc in charges_docs], allow_bson=True)
277
282
 
278
- def update_targets(self, items: List[List[Dict]]):
283
+ def update_targets(self, items: list[list[dict]]):
279
284
  """
280
285
  Inserts the new documents into the charges collection
281
286
 
@@ -334,9 +339,9 @@ class PartialSpinsBuilder(Builder):
334
339
  tasks: Store,
335
340
  molecules: Store,
336
341
  spins: Store,
337
- query: Optional[Dict] = None,
338
- methods: Optional[List] = None,
339
- settings: Optional[EmmetBuildSettings] = None,
342
+ query: dict | None = None,
343
+ methods: list | None = None,
344
+ settings: EmmetBuildSettings | None = None,
340
345
  **kwargs,
341
346
  ):
342
347
  self.tasks = tasks
@@ -384,7 +389,7 @@ class PartialSpinsBuilder(Builder):
384
389
  self.spins.ensure_index("last_updated")
385
390
  self.spins.ensure_index("formula_alphabetical")
386
391
 
387
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
392
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
388
393
  """Prechunk the builder for distributed computation"""
389
394
 
390
395
  temp_query = dict(self.query)
@@ -410,7 +415,7 @@ class PartialSpinsBuilder(Builder):
410
415
  query["species_hash"] = {"$in": list(hash_chunk)}
411
416
  yield {"query": query}
412
417
 
413
- def get_items(self) -> Iterator[List[Dict]]:
418
+ def get_items(self) -> Iterator[list[dict]]:
414
419
  """
415
420
  Gets all items to process into partial spins documents.
416
421
  This does no datetime checking; relying on on whether
@@ -457,12 +462,12 @@ class PartialSpinsBuilder(Builder):
457
462
 
458
463
  yield molecules
459
464
 
460
- def process_item(self, items: List[Dict]) -> List[Dict]:
465
+ def process_item(self, items: list[dict]) -> list[dict]:
461
466
  """
462
467
  Process the tasks into PartialSpinsDocs
463
468
 
464
469
  Args:
465
- tasks List[Dict] : a list of MoleculeDocs in dict form
470
+ tasks list[dict] : a list of MoleculeDocs in dict form
466
471
 
467
472
  Returns:
468
473
  [dict] : a list of new partial spins docs
@@ -555,7 +560,7 @@ class PartialSpinsBuilder(Builder):
555
560
 
556
561
  return jsanitize([doc.model_dump() for doc in spins_docs], allow_bson=True)
557
562
 
558
- def update_targets(self, items: List[List[Dict]]):
563
+ def update_targets(self, items: list[list[dict]]):
559
564
  """
560
565
  Inserts the new documents into the spins collection
561
566
 
@@ -1,19 +1,24 @@
1
+ from __future__ import annotations
2
+
1
3
  from collections import defaultdict
2
4
  from datetime import datetime
3
5
  from itertools import chain
4
6
  from math import ceil
5
- from typing import Optional, Iterable, Iterator, List, Dict
6
7
 
7
8
  from maggma.builders import Builder
8
9
  from maggma.core import Store
9
10
  from maggma.utils import grouper
10
11
 
11
- from emmet.core.qchem.task import TaskDocument
12
+ from emmet.builders.settings import EmmetBuildSettings
13
+ from emmet.core.molecules.bonds import BOND_METHODS, MoleculeBondingDoc
12
14
  from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
13
- from emmet.core.molecules.bonds import MoleculeBondingDoc, BOND_METHODS
15
+ from emmet.core.qchem.task import TaskDocument
14
16
  from emmet.core.utils import jsanitize
15
- from emmet.builders.settings import EmmetBuildSettings
16
17
 
18
+ from typing import TYPE_CHECKING
19
+
20
+ if TYPE_CHECKING:
21
+ from collections.abc import Iterable, Iterator
17
22
 
18
23
  __author__ = "Evan Spotte-Smith"
19
24
 
@@ -54,9 +59,9 @@ class BondingBuilder(Builder):
54
59
  tasks: Store,
55
60
  molecules: Store,
56
61
  bonds: Store,
57
- query: Optional[Dict] = None,
58
- methods: Optional[List] = None,
59
- settings: Optional[EmmetBuildSettings] = None,
62
+ query: dict | None = None,
63
+ methods: list | None = None,
64
+ settings: EmmetBuildSettings | None = None,
60
65
  **kwargs,
61
66
  ):
62
67
  self.tasks = tasks
@@ -104,7 +109,7 @@ class BondingBuilder(Builder):
104
109
  self.bonds.ensure_index("last_updated")
105
110
  self.bonds.ensure_index("formula_alphabetical")
106
111
 
107
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
112
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
108
113
  """Prechunk the builder for distributed computation"""
109
114
 
110
115
  temp_query = dict(self.query)
@@ -130,7 +135,7 @@ class BondingBuilder(Builder):
130
135
  query["species_hash"] = {"$in": list(hash_chunk)}
131
136
  yield {"query": query}
132
137
 
133
- def get_items(self) -> Iterator[List[Dict]]:
138
+ def get_items(self) -> Iterator[list[dict]]:
134
139
  """
135
140
  Gets all items to process into bonding documents.
136
141
  This does no datetime checking; relying on on whether
@@ -177,12 +182,12 @@ class BondingBuilder(Builder):
177
182
 
178
183
  yield molecules
179
184
 
180
- def process_item(self, items: List[Dict]) -> List[Dict]:
185
+ def process_item(self, items: list[dict]) -> list[dict]:
181
186
  """
182
187
  Process the tasks into MoleculeBondingDocs
183
188
 
184
189
  Args:
185
- tasks List[Dict] : a list of MoleculeDocs in dict form
190
+ tasks list[dict] : a list of MoleculeDocs in dict form
186
191
 
187
192
  Returns:
188
193
  [dict] : a list of new bonding docs
@@ -292,7 +297,7 @@ class BondingBuilder(Builder):
292
297
 
293
298
  return jsanitize([doc.model_dump() for doc in bonding_docs], allow_bson=True)
294
299
 
295
- def update_targets(self, items: List[List[Dict]]):
300
+ def update_targets(self, items: list[list[dict]]):
296
301
  """
297
302
  Inserts the new documents into the bonds collection
298
303
 
@@ -1,19 +1,24 @@
1
+ from __future__ import annotations
2
+
1
3
  from collections import defaultdict
2
4
  from datetime import datetime
3
5
  from itertools import chain
4
6
  from math import ceil
5
- from typing import Optional, Iterable, Iterator, List, Dict
6
7
 
7
8
  from maggma.builders import Builder
8
9
  from maggma.core import Store
9
10
  from maggma.utils import grouper
10
11
 
11
- from emmet.core.qchem.task import TaskDocument
12
- from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
12
+ from emmet.builders.settings import EmmetBuildSettings
13
13
  from emmet.core.molecules.electric import ElectricMultipoleDoc
14
+ from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
15
+ from emmet.core.qchem.task import TaskDocument
14
16
  from emmet.core.utils import jsanitize
15
- from emmet.builders.settings import EmmetBuildSettings
16
17
 
18
+ from typing import TYPE_CHECKING
19
+
20
+ if TYPE_CHECKING:
21
+ from collections.abc import Iterable, Iterator
17
22
 
18
23
  __author__ = "Evan Spotte-Smith"
19
24
 
@@ -41,8 +46,8 @@ class ElectricMultipoleBuilder(Builder):
41
46
  tasks: Store,
42
47
  molecules: Store,
43
48
  multipoles: Store,
44
- query: Optional[Dict] = None,
45
- settings: Optional[EmmetBuildSettings] = None,
49
+ query: dict | None = None,
50
+ settings: EmmetBuildSettings | None = None,
46
51
  **kwargs,
47
52
  ):
48
53
  self.tasks = tasks
@@ -89,7 +94,7 @@ class ElectricMultipoleBuilder(Builder):
89
94
  self.multipoles.ensure_index("last_updated")
90
95
  self.multipoles.ensure_index("formula_alphabetical")
91
96
 
92
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
97
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
93
98
  """Prechunk the builder for distributed computation"""
94
99
 
95
100
  temp_query = dict(self.query)
@@ -115,7 +120,7 @@ class ElectricMultipoleBuilder(Builder):
115
120
  query["species_hash"] = {"$in": list(hash_chunk)}
116
121
  yield {"query": query}
117
122
 
118
- def get_items(self) -> Iterator[List[Dict]]:
123
+ def get_items(self) -> Iterator[list[dict]]:
119
124
  """
120
125
  Gets all items to process into multipole documents.
121
126
  This does no datetime checking; relying on on whether
@@ -162,12 +167,12 @@ class ElectricMultipoleBuilder(Builder):
162
167
 
163
168
  yield molecules
164
169
 
165
- def process_item(self, items: List[Dict]) -> List[Dict]:
170
+ def process_item(self, items: list[dict]) -> list[dict]:
166
171
  """
167
172
  Process the tasks into ElectricMultipoleDocs
168
173
 
169
174
  Args:
170
- tasks List[Dict] : a list of MoleculeDocs in dict form
175
+ tasks list[dict] : a list of MoleculeDocs in dict form
171
176
 
172
177
  Returns:
173
178
  [dict] : a list of new electric multipole docs
@@ -250,7 +255,7 @@ class ElectricMultipoleBuilder(Builder):
250
255
 
251
256
  return jsanitize([doc.model_dump() for doc in multipole_docs], allow_bson=True)
252
257
 
253
- def update_targets(self, items: List[List[Dict]]):
258
+ def update_targets(self, items: list[list[dict]]):
254
259
  """
255
260
  Inserts the new documents into the multipoles collection
256
261
 
@@ -1,24 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ import copy
1
4
  from datetime import datetime
2
5
  from itertools import chain
3
6
  from math import ceil
4
- from typing import Optional, Iterable, Iterator, List, Dict
5
- import copy
6
-
7
- from pymatgen.core.structure import Molecule
8
- from pymatgen.util.graph_hashing import weisfeiler_lehman_graph_hash
7
+ from typing import TYPE_CHECKING
9
8
 
10
9
  from maggma.builders import Builder
11
10
  from maggma.core import Store
12
11
  from maggma.utils import grouper
12
+ from pymatgen.core.structure import Molecule
13
+ from pymatgen.util.graph_hashing import weisfeiler_lehman_graph_hash
13
14
 
14
- from emmet.core.qchem.molecule import MoleculeDoc
15
+ from emmet.builders.settings import EmmetBuildSettings
15
16
  from emmet.core.molecules.atomic import PartialChargesDoc, PartialSpinsDoc
16
17
  from emmet.core.molecules.bonds import MoleculeBondingDoc, metals
18
+ from emmet.core.molecules.metal_binding import METAL_BINDING_METHODS, MetalBindingDoc
17
19
  from emmet.core.molecules.thermo import MoleculeThermoDoc
18
- from emmet.core.molecules.metal_binding import MetalBindingDoc, METAL_BINDING_METHODS
20
+ from emmet.core.qchem.molecule import MoleculeDoc
19
21
  from emmet.core.utils import jsanitize
20
- from emmet.builders.settings import EmmetBuildSettings
21
22
 
23
+ if TYPE_CHECKING:
24
+ from collections.abc import Iterable, Iterator
22
25
 
23
26
  __author__ = "Evan Spotte-Smith"
24
27
 
@@ -73,9 +76,9 @@ class MetalBindingBuilder(Builder):
73
76
  bonds: Store,
74
77
  thermo: Store,
75
78
  metal_binding: Store,
76
- query: Optional[Dict] = None,
77
- methods: Optional[List] = None,
78
- settings: Optional[EmmetBuildSettings] = None,
79
+ query: dict | None = None,
80
+ methods: list | None = None,
81
+ settings: EmmetBuildSettings | None = None,
79
82
  **kwargs,
80
83
  ):
81
84
  self.molecules = molecules
@@ -161,7 +164,7 @@ class MetalBindingBuilder(Builder):
161
164
  self.metal_binding.ensure_index("formula_alphabetical")
162
165
  self.metal_binding.ensure_index("method")
163
166
 
164
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
167
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
165
168
  """Prechunk the builder for distributed computation"""
166
169
 
167
170
  temp_query = dict(self.query)
@@ -187,7 +190,7 @@ class MetalBindingBuilder(Builder):
187
190
  query["species_hash"] = {"$in": list(hash_chunk)}
188
191
  yield {"query": query}
189
192
 
190
- def get_items(self) -> Iterator[List[Dict]]:
193
+ def get_items(self) -> Iterator[list[dict]]:
191
194
  """
192
195
  Gets all items to process into metal_binding documents.
193
196
 
@@ -232,12 +235,12 @@ class MetalBindingBuilder(Builder):
232
235
 
233
236
  yield molecules
234
237
 
235
- def process_item(self, items: List[Dict]) -> List[Dict]:
238
+ def process_item(self, items: list[dict]) -> list[dict]:
236
239
  """
237
240
  Process molecule, bonding, partial charges, partial spins, and thermo documents into MetalBindingDocs
238
241
 
239
242
  Args:
240
- tasks List[Dict] : a list of MoleculeDocs in dict form
243
+ tasks list[dict] : a list of MoleculeDocs in dict form
241
244
 
242
245
  Returns:
243
246
  [dict] : a list of new metal binding docs
@@ -491,7 +494,7 @@ class MetalBindingBuilder(Builder):
491
494
 
492
495
  return jsanitize([doc.model_dump() for doc in binding_docs], allow_bson=True)
493
496
 
494
- def update_targets(self, items: List[List[Dict]]):
497
+ def update_targets(self, items: list[list[dict]]):
495
498
  """
496
499
  Inserts the new documents into the metal_binding collection
497
500
 
@@ -1,19 +1,23 @@
1
+ from __future__ import annotations
2
+
1
3
  from collections import defaultdict
2
4
  from datetime import datetime
3
5
  from itertools import chain
4
6
  from math import ceil
5
- from typing import Optional, Iterable, Iterator, List, Dict
7
+ from typing import TYPE_CHECKING
6
8
 
7
9
  from maggma.builders import Builder
8
10
  from maggma.core import Store
9
11
  from maggma.utils import grouper
10
12
 
11
- from emmet.core.qchem.task import TaskDocument
12
- from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
13
+ from emmet.builders.settings import EmmetBuildSettings
13
14
  from emmet.core.molecules.orbitals import OrbitalDoc
15
+ from emmet.core.qchem.molecule import MoleculeDoc, evaluate_lot
16
+ from emmet.core.qchem.task import TaskDocument
14
17
  from emmet.core.utils import jsanitize
15
- from emmet.builders.settings import EmmetBuildSettings
16
18
 
19
+ if TYPE_CHECKING:
20
+ from collections.abc import Iterable, Iterator
17
21
 
18
22
  __author__ = "Evan Spotte-Smith"
19
23
 
@@ -40,8 +44,8 @@ class OrbitalBuilder(Builder):
40
44
  tasks: Store,
41
45
  molecules: Store,
42
46
  orbitals: Store,
43
- query: Optional[Dict] = None,
44
- settings: Optional[EmmetBuildSettings] = None,
47
+ query: dict | None = None,
48
+ settings: EmmetBuildSettings | None = None,
45
49
  **kwargs,
46
50
  ):
47
51
  self.tasks = tasks
@@ -87,7 +91,7 @@ class OrbitalBuilder(Builder):
87
91
  self.orbitals.ensure_index("last_updated")
88
92
  self.orbitals.ensure_index("formula_alphabetical")
89
93
 
90
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
94
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
91
95
  """Prechunk the builder for distributed computation"""
92
96
 
93
97
  temp_query = dict(self.query)
@@ -113,7 +117,7 @@ class OrbitalBuilder(Builder):
113
117
  query["species_hash"] = {"$in": list(hash_chunk)}
114
118
  yield {"query": query}
115
119
 
116
- def get_items(self) -> Iterator[List[Dict]]:
120
+ def get_items(self) -> Iterator[list[dict]]:
117
121
  """
118
122
  Gets all items to process into orbital documents.
119
123
  This does no datetime checking; relying on on whether
@@ -160,12 +164,12 @@ class OrbitalBuilder(Builder):
160
164
 
161
165
  yield molecules
162
166
 
163
- def process_item(self, items: List[Dict]) -> List[Dict]:
167
+ def process_item(self, items: list[dict]) -> list[dict]:
164
168
  """
165
169
  Process the tasks into a OrbitalDocs
166
170
 
167
171
  Args:
168
- tasks List[Dict] : a list of MoleculeDocs in dict form
172
+ tasks list[dict] : a list of MoleculeDocs in dict form
169
173
 
170
174
  Returns:
171
175
  [dict] : a list of new orbital docs
@@ -257,7 +261,7 @@ class OrbitalBuilder(Builder):
257
261
 
258
262
  return jsanitize([doc.model_dump() for doc in orbital_docs], allow_bson=True)
259
263
 
260
- def update_targets(self, items: List[List[Dict]]):
264
+ def update_targets(self, items: list[list[dict]]):
261
265
  """
262
266
  Inserts the new documents into the orbitals collection
263
267
 
@@ -1,22 +1,28 @@
1
- from collections import defaultdict
1
+ from __future__ import annotations
2
+
2
3
  import copy
4
+ from collections import defaultdict
3
5
  from datetime import datetime
4
6
  from itertools import chain, groupby
5
7
  from math import ceil
6
- from typing import Any, Dict, Iterable, Iterator, List, Optional, Union
7
8
 
8
9
  from maggma.builders import Builder
9
10
  from maggma.core import Store
10
11
  from maggma.utils import grouper
11
12
 
12
- from emmet.core.qchem.task import TaskDocument
13
- from emmet.core.qchem.molecule import MoleculeDoc
13
+ from emmet.builders.settings import EmmetBuildSettings
14
14
  from emmet.core.molecules.bonds import metals
15
- from emmet.core.molecules.thermo import MoleculeThermoDoc
16
15
  from emmet.core.molecules.redox import RedoxDoc
16
+ from emmet.core.molecules.thermo import MoleculeThermoDoc
17
+ from emmet.core.qchem.molecule import MoleculeDoc
18
+ from emmet.core.qchem.task import TaskDocument
17
19
  from emmet.core.utils import confirm_molecule, get_graph_hash, jsanitize
18
- from emmet.builders.settings import EmmetBuildSettings
19
20
 
21
+ from typing import TYPE_CHECKING
22
+
23
+ if TYPE_CHECKING:
24
+ from collections.abc import Iterable, Iterator
25
+ from typing import Any
20
26
 
21
27
  __author__ = "Evan Spotte-Smith"
22
28
 
@@ -51,8 +57,8 @@ class RedoxBuilder(Builder):
51
57
  molecules: Store,
52
58
  thermo: Store,
53
59
  redox: Store,
54
- query: Optional[Dict] = None,
55
- settings: Optional[EmmetBuildSettings] = None,
60
+ query: dict | None = None,
61
+ settings: EmmetBuildSettings | None = None,
56
62
  **kwargs,
57
63
  ):
58
64
  self.tasks = tasks
@@ -107,7 +113,7 @@ class RedoxBuilder(Builder):
107
113
  self.redox.ensure_index("last_updated")
108
114
  self.redox.ensure_index("formula_alphabetical")
109
115
 
110
- def prechunk(self, number_splits: int) -> Iterable[Dict]: # pragma: no cover
116
+ def prechunk(self, number_splits: int) -> Iterable[dict]: # pragma: no cover
111
117
  """Prechunk the builder for distributed computation"""
112
118
 
113
119
  temp_query = dict(self.query)
@@ -133,7 +139,7 @@ class RedoxBuilder(Builder):
133
139
  query["species_hash"] = {"$in": list(hash_chunk)}
134
140
  yield {"query": query}
135
141
 
136
- def get_items(self) -> Iterator[List[Dict]]:
142
+ def get_items(self) -> Iterator[list[dict]]:
137
143
  """
138
144
  Gets all items to process into redox documents.
139
145
  This does no datetime checking; relying on on whether
@@ -180,12 +186,12 @@ class RedoxBuilder(Builder):
180
186
 
181
187
  yield molecules
182
188
 
183
- def process_item(self, items: List[Dict]) -> List[Dict]:
189
+ def process_item(self, items: list[dict]) -> list[dict]:
184
190
  """
185
191
  Process the tasks into a RedoxDoc
186
192
 
187
193
  Args:
188
- tasks List[Dict] : a list of MoleculeDocs in dict form
194
+ tasks list[dict] : a list of MoleculeDocs in dict form
189
195
 
190
196
  Returns:
191
197
  [dict] : a list of new redox docs
@@ -203,7 +209,7 @@ class RedoxBuilder(Builder):
203
209
 
204
210
  for graph_group in group_by_graph.values():
205
211
  # Molecule docs will be grouped by charge
206
- charges: Dict[int, Any] = dict()
212
+ charges: dict[int, Any] = dict()
207
213
 
208
214
  for gg in graph_group:
209
215
  # First, grab relevant MoleculeThermoDocs and identify possible IE/EA single-points
@@ -360,7 +366,7 @@ class RedoxBuilder(Builder):
360
366
  [doc.model_dump() for doc in redox_docs if doc is not None], allow_bson=True
361
367
  )
362
368
 
363
- def update_targets(self, items: List[List[Dict]]):
369
+ def update_targets(self, items: list[list[dict]]):
364
370
  """
365
371
  Inserts the new documents into the orbitals collection
366
372
 
@@ -391,7 +397,7 @@ class RedoxBuilder(Builder):
391
397
  self.logger.info("No items to update")
392
398
 
393
399
  @staticmethod
394
- def _group_by_graph(mol_docs: List[MoleculeDoc]) -> Dict[int, List[MoleculeDoc]]:
400
+ def _group_by_graph(mol_docs: list[MoleculeDoc]) -> dict[int, list[MoleculeDoc]]:
395
401
  """
396
402
  Group molecule docs by molecular graph connectivity
397
403
 
@@ -399,7 +405,7 @@ class RedoxBuilder(Builder):
399
405
  :return: Grouped molecule entries
400
406
  """
401
407
 
402
- graph_hashes_nometal: List[str] = list()
408
+ graph_hashes_nometal: list[str] = list()
403
409
  results = defaultdict(list)
404
410
 
405
411
  # Within each group, group by the covalent molecular graph
@@ -430,10 +436,10 @@ class RedoxBuilder(Builder):
430
436
 
431
437
  @staticmethod
432
438
  def _collect_by_lot_solvent(
433
- thermo_docs: List[MoleculeThermoDoc],
434
- ie_docs: List[TaskDocument],
435
- ea_docs: List[TaskDocument],
436
- ) -> Dict[str, Any]:
439
+ thermo_docs: list[MoleculeThermoDoc],
440
+ ie_docs: list[TaskDocument],
441
+ ea_docs: list[TaskDocument],
442
+ ) -> dict[str, Any]:
437
443
  """
438
444
  For a given MoleculeDoc, group potential MoleculeThermoDocs and TaskDocs for
439
445
  IE/EA calculations based on level of theory and solvent.
@@ -452,7 +458,7 @@ class RedoxBuilder(Builder):
452
458
  }
453
459
  """
454
460
 
455
- def _lot_solv(doc: Union[MoleculeThermoDoc, TaskDocument]):
461
+ def _lot_solv(doc: MoleculeThermoDoc | TaskDocument):
456
462
  if isinstance(doc, MoleculeThermoDoc):
457
463
  if doc.correction:
458
464
  return doc.correction_lot_solvent