Skip to content

Commit 9181df7

Browse files
committed
move thermo type defaults to settings -> make get_phase_diagram_from_chemsys thermo_type arg consistent with other defaults
1 parent 796eee4 commit 9181df7

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

mp_api/client/core/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
from pathlib import Path
33

44
from emmet.core.settings import EmmetSettings
5+
from emmet.core.types.enums import ThermoType
56
from pydantic import Field, field_validator
67
from pydantic_settings import BaseSettings, SettingsConfigDict
78
from pymatgen.core import _load_pmg_settings
89

910
from mp_api.client import __file__ as root_dir
1011

12+
DEFAULT_THERMOTYPE = ThermoType("GGA_GGA+U_R2SCAN")
13+
DEFAULT_THERMOTYPE_CRITERIA = {"thermo_types": [DEFAULT_THERMOTYPE.value]}
14+
1115
PMG_SETTINGS = _load_pmg_settings()
1216
_NUM_PARALLEL_REQUESTS = min(PMG_SETTINGS.get("MPRESTER_NUM_PARALLEL_REQUESTS", 4), 4)
1317
_MAX_RETRIES = min(PMG_SETTINGS.get("MPRESTER_MAX_RETRIES", 3), 3)

mp_api/client/mprester.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
MPRestWarning,
3333
_emit_status_warning,
3434
)
35-
from mp_api.client.core.settings import MAPI_CLIENT_SETTINGS
35+
from mp_api.client.core.settings import (
36+
DEFAULT_THERMOTYPE,
37+
DEFAULT_THERMOTYPE_CRITERIA,
38+
MAPI_CLIENT_SETTINGS,
39+
)
3640
from mp_api.client.core.utils import LazyImport, load_json, validate_ids
3741
from mp_api.client.routes import GENERIC_RESTERS
3842
from mp_api.client.routes.materials import MATERIALS_RESTERS
@@ -58,8 +62,6 @@
5862
from mp_api.client.core.client import QueryBuilderWithCache
5963
from mp_api.client.core.schemas import _DictLikeAccess
6064

61-
DEFAULT_THERMOTYPE = ThermoType("GGA_GGA+U_R2SCAN")
62-
DEFAULT_THERMOTYPE_CRITERIA = {"thermo_types": [DEFAULT_THERMOTYPE.value]}
6365

6466
RESTER_LAYOUT = {
6567
"molecules/core": LazyImport(

mp_api/client/routes/materials/thermo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from mp_api.client.core import BaseRester
1515
from mp_api.client.core.exceptions import MPRestError
16+
from mp_api.client.core.settings import DEFAULT_THERMOTYPE
1617
from mp_api.client.core.utils import validate_ids
1718

1819
if TYPE_CHECKING:
@@ -185,13 +186,14 @@ def search(
185186
)
186187

187188
def get_phase_diagram_from_chemsys(
188-
self, chemsys: str, thermo_type: ThermoType | str
189+
self, chemsys: str, thermo_type: ThermoType | str = DEFAULT_THERMOTYPE
189190
) -> PhaseDiagram:
190191
"""Get a pre-computed phase diagram for a given chemsys.
191192
192193
Arguments:
193194
chemsys (str): A chemical system (e.g. Li-Fe-O)
194195
thermo_type (ThermoType): The thermo type for the phase diagram.
196+
Defaults to ThermoType.GGA_GGA_U_R2SCAN.
195197
196198
Returns:
197199
(PhaseDiagram): Pymatgen phase diagram object.

0 commit comments

Comments
 (0)