|
6 | 6 | from typing import TYPE_CHECKING, NamedTuple |
7 | 7 |
|
8 | 8 | from emmet.core.electrode import InsertionElectrodeDoc |
9 | | -from emmet.core.mpid import MPID |
| 9 | +from emmet.core.mpid import MPID, check_ulid |
10 | 10 | from emmet.core.structure_group import StructureGroupDoc |
11 | 11 | from jobflow import Flow, Maker, Response, job |
12 | 12 | from pymatgen.analysis.defects.generators import ChargeInterstitialGenerator |
13 | 13 | from pymatgen.entries.computed_entries import ComputedStructureEntry |
14 | 14 | from ulid import ULID |
15 | 15 |
|
| 16 | +try: |
| 17 | + from emmet.core.mpid import AlphaID |
| 18 | +except ImportError: |
| 19 | + AlphaID = None |
| 20 | + |
16 | 21 | if TYPE_CHECKING: |
17 | 22 | from collections.abc import Callable |
18 | 23 | from pathlib import Path |
@@ -196,7 +201,12 @@ def get_insertion_electrode_doc( |
196 | 201 | ) -> Response: |
197 | 202 | """Return a `InsertionElectrodeDoc`.""" |
198 | 203 | for ient in computed_entries: |
199 | | - ient.data["material_id"] = ient.entry_id |
| 204 | + if AlphaID and check_ulid.fullmatch(ient.entry_id): |
| 205 | + # AlphaID not compatible with ULID, MPID is but ID validation |
| 206 | + # does not permit ULIDs, just their integer values. |
| 207 | + ient.data["material_id"] = AlphaID(int(ULID.from_str(ient.entry_id))) |
| 208 | + else: |
| 209 | + ient.data["material_id"] = ient.entry_id |
200 | 210 | return InsertionElectrodeDoc.from_entries( |
201 | 211 | computed_entries, working_ion_entry, battery_id=None |
202 | 212 | ) |
|
0 commit comments