88
99from emmet .core .electronic_structure import BSPathType
1010from emmet .core .mpid import MPID , AlphaID
11- from emmet .core .settings import EmmetSettings
1211from emmet .core .tasks import TaskDoc
1312from emmet .core .types .enums import ThermoType
1413from emmet .core .vasp .calc_types import CalcType
4241 from pymatgen .analysis .phase_diagram import PDEntry
4342 from pymatgen .entries .computed_entries import ComputedEntry
4443
45- _EMMET_SETTINGS = EmmetSettings ()
4644DEFAULT_THERMOTYPE_CRITERIA = {"thermo_types" : ["GGA_GGA+U" ]}
4745
4846RESTER_LAYOUT = {
@@ -119,9 +117,7 @@ def __init__(
119117 """
120118 self .api_key = validate_api_key (api_key )
121119
122- self .endpoint = validate_endpoint (endpoint ) or MAPI_CLIENT_SETTINGS .ENDPOINT
123- if not self .endpoint .endswith ("/" ):
124- self .endpoint += "/"
120+ self .endpoint = validate_endpoint (endpoint )
125121
126122 self .headers = headers or {}
127123 self .session = session or BaseRester ._create_session (
@@ -464,9 +460,9 @@ def get_structures(
464460 def find_structure (
465461 self ,
466462 filename_or_structure : str | Structure ,
467- ltol : float = _EMMET_SETTINGS .LTOL ,
468- stol : float = _EMMET_SETTINGS .STOL ,
469- angle_tol : float = _EMMET_SETTINGS .ANGLE_TOL ,
463+ ltol : float = MAPI_CLIENT_SETTINGS .LTOL ,
464+ stol : float = MAPI_CLIENT_SETTINGS .STOL ,
465+ angle_tol : float = MAPI_CLIENT_SETTINGS .ANGLE_TOL ,
470466 allow_multiple_results : bool = False ,
471467 ) -> list [str ] | str :
472468 """Finds matching structures from the Materials Project database.
@@ -501,13 +497,14 @@ def get_entries(
501497 self ,
502498 chemsys_formula_mpids : str | list [str ],
503499 compatible_only : bool = True ,
504- inc_structure : bool | None = None ,
505500 property_data : list [str ] | None = None ,
506501 conventional_unit_cell : bool = False ,
507502 additional_criteria : dict | None = None ,
503+ ** kwargs ,
508504 ) -> list [ComputedStructureEntry ]:
509- """Get a list of ComputedEntries or ComputedStructureEntries corresponding
510- to a chemical system or formula. This returns entries for all thermo types
505+ """Get a list of ComputedStructureEntry from a chemical system, or formula, or MPID.
506+
507+ This returns ComputedStructureEntries with final structures for all thermo types
511508 represented in the database. Each type corresponds to a different mixing scheme
512509 (i.e. GGA/GGA+U, GGA/GGA+U/R2SCAN, R2SCAN). By default the thermo_type of the
513510 entry is also returned.
@@ -523,12 +520,6 @@ def get_entries(
523520 which performs adjustments to allow mixing of GGA and GGA+U
524521 calculations for more accurate phase diagrams and reaction
525522 energies. This data is obtained from the core "thermo" API endpoint.
526- inc_structure (str): *This is a deprecated argument*. Previously, if None, entries
527- returned were ComputedEntries. If inc_structure="initial",
528- ComputedStructureEntries with initial structures were returned.
529- Otherwise, ComputedStructureEntries with final structures
530- were returned. This is no longer needed as all entries will contain the
531- final structure data by default.
532523 property_data (list): Specify additional properties to include in
533524 entry.data. If None, only default data is included. Should be a subset of
534525 input parameters in the 'MPRester.thermo.available_fields' list.
@@ -538,14 +529,15 @@ def get_entries(
538529 correspond to proper function inputs to `MPRester.thermo.search`. For instance,
539530 if you are only interested in entries on the convex hull, you could pass
540531 {"energy_above_hull": (0.0, 0.0)} or {"is_stable": True}.
532+ kwargs: Used here only to gracefully handle deprecated arguments. All kwargs are ignored.
541533
542534 Returns:
543535 List ComputedStructureEntry objects.
544536 """
545- if inc_structure is not None :
537+ if kwargs . pop ( " inc_structure" , None ) is not None :
546538 warnings .warn (
547- "The ' inc_structure' argument is deprecated as structure "
548- "data is now always included in all returned entry objects."
539+ "The ` inc_structure` argument is deprecated as final structures "
540+ "are always included in all returned ComputedStructureEntry objects."
549541 )
550542
551543 if isinstance (chemsys_formula_mpids , str ):
@@ -935,9 +927,9 @@ def get_entry_by_material_id(
935927 self ,
936928 material_id : str ,
937929 compatible_only : bool = True ,
938- inc_structure : bool | None = None ,
939930 property_data : list [str ] | None = None ,
940931 conventional_unit_cell : bool = False ,
932+ ** kwargs ,
941933 ):
942934 """Get all ComputedEntry objects corresponding to a material_id.
943935
@@ -950,37 +942,32 @@ def get_entry_by_material_id(
950942 which performs adjustments to allow mixing of GGA and GGA+U
951943 calculations for more accurate phase diagrams and reaction
952944 energies. This data is obtained from the core "thermo" API endpoint.
953- inc_structure (str): *This is a deprecated argument*. Previously, if None, entries
954- returned were ComputedEntries. If inc_structure="initial",
955- ComputedStructureEntries with initial structures were returned.
956- Otherwise, ComputedStructureEntries with final structures
957- were returned. This is no longer needed as all entries will contain
958- structure data by default.
959945 property_data (list): Specify additional properties to include in
960946 entry.data. If None, only default data is included. Should be a subset of
961947 input parameters in the 'MPRester.thermo.available_fields' list.
962948 conventional_unit_cell (bool): Whether to get the standard
963949 conventional unit cell
950+ kwargs : Other kwargs to pass to `get_entries`
964951 Returns:
965952 List of ComputedEntry or ComputedStructureEntry object.
966953 """
967954 return self .get_entries (
968955 material_id ,
969956 compatible_only = compatible_only ,
970- inc_structure = inc_structure ,
971957 property_data = property_data ,
972958 conventional_unit_cell = conventional_unit_cell ,
959+ ** kwargs ,
973960 )
974961
975962 def get_entries_in_chemsys (
976963 self ,
977964 elements : str | list [str ],
978965 use_gibbs : int | None = None ,
979966 compatible_only : bool = True ,
980- inc_structure : bool | None = None ,
981967 property_data : list [str ] | None = None ,
982968 conventional_unit_cell : bool = False ,
983969 additional_criteria : dict = DEFAULT_THERMOTYPE_CRITERIA ,
970+ ** kwargs ,
984971 ):
985972 """Helper method to get a list of ComputedEntries in a chemical system.
986973 For example, elements = ["Li", "Fe", "O"] will return a list of all
@@ -1006,12 +993,6 @@ def get_entries_in_chemsys(
1006993 which performs adjustments to allow mixing of GGA and GGA+U
1007994 calculations for more accurate phase diagrams and reaction
1008995 energies. This data is obtained from the core "thermo" API endpoint.
1009- inc_structure (str): *This is a deprecated argument*. Previously, if None, entries
1010- returned were ComputedEntries. If inc_structure="initial",
1011- ComputedStructureEntries with initial structures were returned.
1012- Otherwise, ComputedStructureEntries with final structures
1013- were returned. This is no longer needed as all entries will contain
1014- structure data by default.
1015996 property_data (list): Specify additional properties to include in
1016997 entry.data. If None, only default data is included. Should be a subset of
1017998 input parameters in the 'MPRester.thermo.available_fields' list.
@@ -1022,6 +1003,7 @@ def get_entries_in_chemsys(
10221003 if you are only interested in entries on the convex hull, you could pass
10231004 {"energy_above_hull": (0.0, 0.0)} or {"is_stable": True}, or if you are only interested
10241005 in entry data
1006+ kwargs : Other kwargs to pass to `get_entries`
10251007 Returns:
10261008 List of ComputedStructureEntries.
10271009 """
@@ -1042,10 +1024,10 @@ def get_entries_in_chemsys(
10421024 self .get_entries (
10431025 all_chemsyses ,
10441026 compatible_only = compatible_only ,
1045- inc_structure = inc_structure ,
10461027 property_data = property_data ,
10471028 conventional_unit_cell = conventional_unit_cell ,
10481029 additional_criteria = additional_criteria or DEFAULT_THERMOTYPE_CRITERIA ,
1030+ ** kwargs ,
10491031 )
10501032 )
10511033
@@ -1167,11 +1149,7 @@ def get_charge_density_from_task_id(
11671149 key = f"chgcars/{ validate_ids ([task_id ])[0 ]} .json.gz" ,
11681150 decoder = lambda x : load_json (x , deser = True ),
11691151 )
1170- chgcar = self .materials .tasks ._query_open_data (** kwargs )[0 ]
1171- if not chgcar :
1172- raise MPRestError (f"No charge density fetched for task_id { task_id } ." )
1173-
1174- chgcar = chgcar [0 ]["data" ] # type: ignore
1152+ chgcar = self .materials .tasks ._query_open_data (** kwargs )[0 ][0 ]["data" ]
11751153
11761154 if inc_task_doc :
11771155 task_doc = self .materials .tasks .search (task_ids = task_id )[0 ]
@@ -1341,7 +1319,6 @@ def get_cohesive_energy(
13411319 entries = self .get_entries (
13421320 material_ids ,
13431321 compatible_only = False ,
1344- inc_structure = True ,
13451322 property_data = None ,
13461323 conventional_unit_cell = False ,
13471324 )
@@ -1481,7 +1458,7 @@ def get_stability(
14811458 pd = self .materials .thermo .get_phase_diagram_from_chemsys (
14821459 chemsys_str , thermo_type = thermo_type
14831460 )
1484- except OSError :
1461+ except MPRestError :
14851462 pd = None
14861463
14871464 if not pd :
0 commit comments