mp-api 0.47.0rc1__tar.gz → 0.47.1__tar.gz

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.
Files changed (128) hide show
  1. {mp_api-0.47.0rc1 → mp_api-0.47.1}/PKG-INFO +5 -5
  2. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/client.py +32 -16
  3. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/client.py +39 -19
  4. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/mprester.py +90 -19
  5. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/thermo.py +48 -0
  6. {mp_api-0.47.0rc1 → mp_api-0.47.1}/pyproject.toml +4 -4
  7. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_delta.py +13 -2
  8. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_thermo.py +34 -0
  9. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/test_entry_progress.py +53 -3
  10. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/test_mprester.py +155 -80
  11. {mp_api-0.47.0rc1 → mp_api-0.47.1}/.gitignore +0 -0
  12. {mp_api-0.47.0rc1 → mp_api-0.47.1}/LICENSE +0 -0
  13. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/__init__.py +0 -0
  14. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/_test_utils.py +0 -0
  15. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/__init__.py +0 -0
  16. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/_server_utils.py +0 -0
  17. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/__init__.py +0 -0
  18. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/_logger.py +0 -0
  19. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/_types.py +0 -0
  20. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/_units.py +0 -0
  21. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/schemas.py +0 -0
  22. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/settings.py +0 -0
  23. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/contribs/utils.py +0 -0
  24. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/__init__.py +0 -0
  25. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/_display.py +0 -0
  26. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/_entries.py +0 -0
  27. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/_external.py +0 -0
  28. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/_oxygen_evolution.py +0 -0
  29. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/delta.py +0 -0
  30. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/exceptions.py +0 -0
  31. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/schemas.py +0 -0
  32. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/settings.py +0 -0
  33. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/core/utils.py +0 -0
  34. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/__init__.py +0 -0
  35. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/_server.py +0 -0
  36. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/__init__.py +0 -0
  37. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/absorption.py +0 -0
  38. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/alloys.py +0 -0
  39. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/bonds.py +0 -0
  40. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/chemenv.py +0 -0
  41. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/dielectric.py +0 -0
  42. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/doi.py +0 -0
  43. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/elasticity.py +0 -0
  44. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/electrodes.py +0 -0
  45. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/electronic_structure.py +0 -0
  46. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/eos.py +0 -0
  47. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/grain_boundaries.py +0 -0
  48. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/magnetism.py +0 -0
  49. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/materials.py +0 -0
  50. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/oxidation_states.py +0 -0
  51. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/phonon.py +0 -0
  52. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/piezo.py +0 -0
  53. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/provenance.py +0 -0
  54. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/robocrys.py +0 -0
  55. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/similarity.py +0 -0
  56. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/substrates.py +0 -0
  57. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/summary.py +0 -0
  58. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/surface_properties.py +0 -0
  59. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/synthesis.py +0 -0
  60. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/tasks.py +0 -0
  61. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/materials/xas.py +0 -0
  62. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/molecules/__init__.py +0 -0
  63. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/molecules/jcesr.py +0 -0
  64. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/molecules/molecules.py +0 -0
  65. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/client/routes/molecules/summary.py +0 -0
  66. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/__init__.py +0 -0
  67. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/_schemas.py +0 -0
  68. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/mp_mcp.py +0 -0
  69. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/server.py +0 -0
  70. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/tools.py +0 -0
  71. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/mcp/utils.py +0 -0
  72. {mp_api-0.47.0rc1 → mp_api-0.47.1}/mp_api/py.typed +0 -0
  73. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/__init__.py +0 -0
  74. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/__init__.py +0 -0
  75. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/conftest.py +0 -0
  76. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/test_client.py +0 -0
  77. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/test_contribs_schemas.py +0 -0
  78. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/test_contribs_utils.py +0 -0
  79. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/test_side_effects.py +0 -0
  80. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/contribs/test_types.py +0 -0
  81. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_client_progress.py +0 -0
  82. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_delta_versions.py +0 -0
  83. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_display.py +0 -0
  84. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_external.py +0 -0
  85. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_ids.py +0 -0
  86. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_oxygen_evolution.py +0 -0
  87. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_quiet.py +0 -0
  88. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_schemas.py +0 -0
  89. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_session_headers.py +0 -0
  90. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/core/test_utils.py +0 -0
  91. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/__init__.py +0 -0
  92. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_absorption.py +0 -0
  93. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_alloys.py +0 -0
  94. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_bonds.py +0 -0
  95. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_chemenv.py +0 -0
  96. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_dielectric.py +0 -0
  97. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_doi.py +0 -0
  98. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_elasticity.py +0 -0
  99. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_electrodes.py +0 -0
  100. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_electronic_structure.py +0 -0
  101. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_eos.py +0 -0
  102. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_grain_boundary.py +0 -0
  103. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_magnetism.py +0 -0
  104. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_materials.py +0 -0
  105. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_oxidation_states.py +0 -0
  106. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_phonon.py +0 -0
  107. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_piezo.py +0 -0
  108. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_provenance.py +0 -0
  109. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_robocrys.py +0 -0
  110. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_similarity.py +0 -0
  111. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_substrates.py +0 -0
  112. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_summary.py +0 -0
  113. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_surface_properties.py +0 -0
  114. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_synthesis.py +0 -0
  115. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_tasks.py +0 -0
  116. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/materials/test_xas.py +0 -0
  117. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/molecules/__init__.py +0 -0
  118. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/molecules/test_jcesr.py +0 -0
  119. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/molecules/test_molecules.py +0 -0
  120. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/molecules/test_summary.py +0 -0
  121. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/test_client.py +0 -0
  122. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/test_core_client.py +0 -0
  123. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/client/test_heartbeat.py +0 -0
  124. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/conftest.py +0 -0
  125. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/mcp/__init__.py +0 -0
  126. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/mcp/test_server.py +0 -0
  127. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/mcp/test_tools.py +0 -0
  128. {mp_api-0.47.0rc1 → mp_api-0.47.1}/tests/mcp/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: mp-api
3
- Version: 0.47.0rc1
3
+ Version: 0.47.1
4
4
  Summary: API Client for the Materials Project
5
5
  Author-email: The Materials Project <feedback@materialsproject.org>
6
6
  License-Expression: BSD-3-Clause-LBNL
@@ -16,18 +16,18 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
17
  Classifier: Topic :: Scientific/Engineering
18
18
  Requires-Python: >=3.12
19
- Requires-Dist: boto3
19
+ Requires-Dist: boto3>=1.34
20
20
  Requires-Dist: deltalake<1.6.0,>=1.4.0
21
- Requires-Dist: emmet-core<0.88.1,>=0.88.0rc3
21
+ Requires-Dist: emmet-core>=0.88.0
22
22
  Requires-Dist: monty>=2024.12.10
23
23
  Requires-Dist: orjson<4,>=3.10
24
24
  Requires-Dist: pyarrow>=20.0.0
25
- Requires-Dist: pymatgen>2024.2.20
25
+ Requires-Dist: pymatgen>=2026.10.24
26
26
  Requires-Dist: requests>=2.23.0
27
27
  Requires-Dist: rich>=13.0
28
28
  Provides-Extra: all
29
29
  Requires-Dist: custodian; extra == 'all'
30
- Requires-Dist: emmet-core[all]<0.88.1,>=0.88.0rc; extra == 'all'
30
+ Requires-Dist: emmet-core[all]>=0.88.0; extra == 'all'
31
31
  Requires-Dist: fastmcp; extra == 'all'
32
32
  Requires-Dist: flask; extra == 'all'
33
33
  Requires-Dist: ipywidgets; extra == 'all'
@@ -994,11 +994,14 @@ class ContribsClient(SwaggerClient):
994
994
  else MPCDict(contrib)
995
995
  )
996
996
 
997
- def get_table(self, tid_or_md5: str) -> Table:
997
+ def get_table(self, tid_or_md5: str, timeout: int = -1) -> Table:
998
998
  """Retrieve full Pandas DataFrame for a table.
999
999
 
1000
+ Data pages beyond the first are fetched concurrently.
1001
+
1000
1002
  Args:
1001
1003
  tid_or_md5 (str): ObjectId or MD5 hash digest for table
1004
+ timeout (int): cancel remaining requests if timeout exceeded (in seconds)
1002
1005
  """
1003
1006
  str_len = len(tid_or_md5)
1004
1007
  if str_len not in {24, 32}:
@@ -1016,23 +1019,36 @@ class ContribsClient(SwaggerClient):
1016
1019
 
1017
1020
  op = self.swagger_spec.resources["tables"].queryTables
1018
1021
  per_page = op.params["data_per_page"].param_spec["maximum"]
1019
- table: dict[str, list[str]] = {"data": []}
1020
- page, pages = 1, None
1021
1022
 
1022
- while pages is None or page <= pages:
1023
- resp = self.tables.getTableById(
1024
- pk=tid, _fields=["_all"], data_page=page, data_per_page=per_page
1025
- ).result()
1026
- table["data"].extend(resp["data"])
1027
- if pages is None:
1028
- pages = resp["total_data_pages"]
1029
- table["index"] = resp["index"]
1030
- table["columns"] = resp["columns"]
1031
- table_attrs: dict[str, str] = (resp.get("attrs") or {}) | {
1032
- field: resp.get(field) for field in {"id", "name", "md5"}
1033
- }
1023
+ # fetch the first page to learn the total number of data pages + metadata
1024
+ resp = self.tables.getTableById(
1025
+ pk=tid, _fields=["_all"], data_page=1, data_per_page=per_page
1026
+ ).result()
1027
+ pages = resp["total_data_pages"]
1028
+ table: dict[str, Any] = {
1029
+ "data": resp["data"],
1030
+ "index": resp["index"],
1031
+ "columns": resp["columns"],
1032
+ }
1033
+ table_attrs: dict[str, str] = (resp.get("attrs") or {}) | {
1034
+ field: resp.get(field) for field in {"id", "name", "md5"}
1035
+ }
1034
1036
 
1035
- page += 1
1037
+ # fetch any remaining pages concurrently, then reassemble in page order
1038
+ if pages > 1:
1039
+ futures = [
1040
+ self._get_future(
1041
+ page,
1042
+ {"_fields": "_all", "data_page": page, "data_per_page": per_page},
1043
+ rel_url=f"tables/{tid}",
1044
+ )
1045
+ for page in range(2, pages + 1)
1046
+ ]
1047
+ responses = _run_futures(
1048
+ futures, timeout=timeout, disable=self.mute_progress_bars
1049
+ )
1050
+ for page in sorted(responses):
1051
+ table["data"].extend(responses[page]["result"]["data"])
1036
1052
 
1037
1053
  return Table.from_dict(table | {"attrs": table_attrs})
1038
1054
 
@@ -486,6 +486,7 @@ class BaseRester(_Rester):
486
486
 
487
487
  self.timeout = timeout
488
488
  self._s3_client = s3_client
489
+ self._gnome_access: bool | None = None
489
490
 
490
491
  @property
491
492
  def s3_client(self):
@@ -896,6 +897,43 @@ class BaseRester(_Rester):
896
897
  "to download that version, then filter it locally."
897
898
  )
898
899
 
900
+ def _has_gnome_access(self, timeout: int | None = None) -> bool:
901
+ """Whether the API key can access the (BY-NC licensed) GNoMe data.
902
+
903
+ Checked with one request, cached once it succeeds. A failed check (e.g. without
904
+ an API key) counts as no access, and is retried on the next call.
905
+
906
+ Args:
907
+ timeout (int or None) : timeout for the check, defaults to `self.timeout`
908
+
909
+ Returns:
910
+ bool
911
+ """
912
+ if self._gnome_access is None:
913
+ try:
914
+ self._gnome_access = bool(
915
+ self._submit_requests(
916
+ url=urljoin(self.base_endpoint, "materials/summary/"),
917
+ criteria={
918
+ "batch_id": "gnome_r2scan_statics",
919
+ "_fields": "material_id",
920
+ },
921
+ use_document_model=False,
922
+ num_chunks=1,
923
+ chunk_size=1,
924
+ timeout=timeout if timeout is not None else self.timeout,
925
+ show_progress=False,
926
+ )
927
+ .get("meta", {})
928
+ .get("total_doc", 0)
929
+ )
930
+ except MPRestError as exc:
931
+ logger.debug(
932
+ f"Could not check access to GNoMe data, assuming none: {exc}"
933
+ )
934
+ return False
935
+ return self._gnome_access
936
+
899
937
  def _query_delta_backed(
900
938
  self,
901
939
  bucket: str,
@@ -995,28 +1033,10 @@ class BaseRester(_Rester):
995
1033
  f"Regenerating {collection}{version_note} at {target_path}..."
996
1034
  )
997
1035
 
998
- # Check if user has access to GNoMe
999
- has_gnome_access = bool(
1000
- self._submit_requests(
1001
- url=urljoin(self.base_endpoint, "materials/summary/"),
1002
- criteria={
1003
- "batch_id": "gnome_r2scan_statics",
1004
- "_fields": "material_id",
1005
- },
1006
- use_document_model=False,
1007
- num_chunks=1,
1008
- chunk_size=1,
1009
- timeout=timeout if timeout is not None else self.timeout,
1010
- show_progress=False,
1011
- )
1012
- .get("meta", {})
1013
- .get("total_doc", 0)
1014
- )
1015
-
1016
1036
  conditions = []
1017
1037
  if versioned:
1018
1038
  conditions.append(f"version = '{version}'")
1019
- filter_access = access_controlled and not has_gnome_access
1039
+ filter_access = access_controlled and not self._has_gnome_access(timeout)
1020
1040
  if filter_access:
1021
1041
  if collection == "tasks":
1022
1042
  controlled_batch_str = ",".join(
@@ -764,8 +764,13 @@ class MPRester(_Rester):
764
764
 
765
765
  This returns a list of ComputedStructureEntry with final structures for all thermo types
766
766
  represented in the database. Each type corresponds to a different mixing scheme
767
- (i.e. GGA/GGA+U, GGA/GGA+U/R2SCAN, R2SCAN). By default the thermo_type of the
768
- entry is also returned.
767
+ (i.e. GGA/GGA+U, GGA/GGA+U/R2SCAN, R2SCAN).
768
+
769
+ Entries from different thermo types can share an ``entry_id`` and differ only
770
+ in their energy adjustments: e.g. the R2SCAN and GGA/GGA+U/R2SCAN entries of a
771
+ material are the same r2SCAN calculation, the latter with the mixing correction
772
+ applied. To get the entries of a single thermo type, pass it in
773
+ ``additional_criteria``, e.g. ``{"thermo_types": ["GGA_GGA+U_R2SCAN"]}``.
769
774
 
770
775
  Args:
771
776
  chemsys_formula_mpids (str | list[str]): A chemical system, list of chemical systems
@@ -1371,8 +1376,19 @@ class MPRester(_Rester):
1371
1376
  str(doc["material_id"]): {p: doc[p] for p in property_data}
1372
1377
  for doc in docs
1373
1378
  }
1379
+ no_doc = dict.fromkeys(property_data)
1380
+ missing = []
1374
1381
  for entry in entries: # served entries carry `material_id`
1375
- entry.data |= props[str(entry.data["material_id"])]
1382
+ material_id = str(entry.data["material_id"])
1383
+ if material_id not in props:
1384
+ missing.append(material_id)
1385
+ entry.data |= props.get(material_id, no_doc)
1386
+ if missing: # e.g. materials removed since an older `db_version`
1387
+ logger.warning(
1388
+ f"No thermo document was found for {', '.join(missing)} in "
1389
+ f"database version {self.current_db_version} (used for REST "
1390
+ "queries), so their `property_data` fields are None."
1391
+ )
1376
1392
 
1377
1393
  if entries is None:
1378
1394
  # MP has no pre-built diagram for this system, so redo the mixing here as MP does when
@@ -1394,7 +1410,8 @@ class MPRester(_Rester):
1394
1410
  )
1395
1411
  n = len(unmixed)
1396
1412
  entries = apply_corrections(
1397
- MaterialsProjectDFTMixingScheme(),
1413
+ # strict structure matching, as for MP's pre-built phase diagrams
1414
+ MaterialsProjectDFTMixingScheme(fuzzy_matching=False),
1398
1415
  unmixed,
1399
1416
  description="Re-mixing GGA(+U)/r2SCAN entries",
1400
1417
  log=f"Re-mixing {n:,} GGA(+U)/r2SCAN entries onto a common energy scale",
@@ -1918,16 +1935,19 @@ class MPRester(_Rester):
1918
1935
  """Get the energy above hull of a list of entries.
1919
1936
 
1920
1937
  Args:
1921
- entries (list of ComputedEntry or ComputedStructureEntry or PDEntry) :
1922
- List of entries with energy and composition information to compute
1923
- hull energies.
1924
- thermo_type (str or ThermoType) : The hull type to use.
1925
- Defaults to ThermoType.GGA_GGA_U_R2SCAN.
1938
+ entries (list of ComputedEntry or ComputedStructureEntry or PDEntry):
1939
+ List of entries with energy and composition information to compute
1940
+ hull energies. Entries the corrections drop (for the GGA(+U)/r2SCAN
1941
+ mixing scheme, those without a structure or `entry_id`, and duplicates
1942
+ of a structure) are only assigned an energy above hull if computed
1943
+ with the functional the hull is anchored on, else None.
1944
+ thermo_type (str or ThermoType) : The hull type to use.
1945
+ Defaults to ThermoType.GGA_GGA_U_R2SCAN.
1926
1946
 
1927
1947
  Returns:
1928
1948
  list of dict:
1929
1949
  {
1930
- "e_above_hull": float, # energy above the hull
1950
+ "e_above_hull": float | None, # energy above the hull, or None
1931
1951
  "composition": dict[str,float], # composition as dict
1932
1952
  "energy": float, # energy with mixing / corrections
1933
1953
  "entry_id": str, # optional identifier
@@ -2006,15 +2026,66 @@ class MPRester(_Rester):
2006
2026
  )
2007
2027
  new_pd = PhaseDiagram(processed) # type: ignore[arg-type]
2008
2028
 
2009
- return [
2010
- {
2011
- "e_above_hull": new_pd.get_e_above_hull(entry), # type: ignore[arg-type]
2012
- "composition": entry.composition.as_dict(),
2013
- "energy": entry.energy,
2014
- "entry_id": getattr(entry, "entry_id", f"user-entry-{idx}"),
2015
- }
2016
- for idx, entry in enumerate(entries)
2017
- ]
2029
+ # The corrector works in place, so the entries it kept are the input objects. The
2030
+ # mixing scheme leaves the energies of the functional the hull is anchored on as
2031
+ # compat_1/compat_2 corrected them, so entries of that functional it dropped (e.g.
2032
+ # duplicates of MP structures) are on the hull's scale once corrected the same way
2033
+ kept = {id(entry) for entry in processed}
2034
+ anchor_run_types: list[str] = []
2035
+ anchor_compat: Compatibility | None = None
2036
+ if isinstance(corrector, mixing_scheme_class()):
2037
+ # it only keeps r2SCAN entries unadjusted if the hull is anchored on r2SCAN
2038
+ r2scan_anchored = any(
2039
+ e.parameters["run_type"] in corrector.valid_rtypes_2
2040
+ and not e.energy_adjustments
2041
+ for e in processed
2042
+ if isinstance(e, ComputedStructureEntry) # all the scheme keeps
2043
+ )
2044
+ anchor_run_types, anchor_compat = (
2045
+ (corrector.valid_rtypes_2, corrector.compat_2)
2046
+ if r2scan_anchored
2047
+ else (corrector.valid_rtypes_1, corrector.compat_1)
2048
+ )
2049
+
2050
+ def placed(entry):
2051
+ """`entry` with its energy on the hull's scale, or None if it isn't."""
2052
+ if id(entry) in kept:
2053
+ return entry
2054
+ if entry.parameters.get("run_type") not in anchor_run_types:
2055
+ return None
2056
+ if anchor_compat is None: # not corrected (r2SCAN's compat_2 here)
2057
+ return entry
2058
+ try: # MP2020's POTCAR check raises for entries without POTCAR info
2059
+ return anchor_compat.process_entry(entry, inplace=False)
2060
+ except (KeyError, ValueError):
2061
+ return None
2062
+
2063
+ results, unplaced = [], []
2064
+ for idx, entry in enumerate(entries):
2065
+ label = getattr(entry, "entry_id", None) or f"user-entry-{idx}"
2066
+ if (placement := placed(entry)) is None:
2067
+ unplaced.append(label)
2068
+ results.append(
2069
+ {
2070
+ "e_above_hull": (
2071
+ None
2072
+ if placement is None
2073
+ # a dropped entry is not on the hull, so can lie below it
2074
+ else new_pd.get_e_above_hull(placement, allow_negative=True)
2075
+ ),
2076
+ "composition": entry.composition.as_dict(),
2077
+ "energy": (entry if placement is None else placement).energy,
2078
+ "entry_id": label,
2079
+ }
2080
+ )
2081
+ if unplaced:
2082
+ mp_warning(
2083
+ f"{type(corrector).__name__} dropped {len(unplaced):,} of your entries, "
2084
+ f"which are off the {thermo_type_valid_str} hull's energy scale, so their "
2085
+ f"`e_above_hull` is None: {', '.join(unplaced)}",
2086
+ stacklevel=2,
2087
+ )
2088
+ return results
2018
2089
 
2019
2090
  def get_oxygen_evolution(
2020
2091
  self,
@@ -10,6 +10,7 @@ from emmet.core.types.pymatgen_types.phase_diagram_adapter import PhaseDiagramTy
10
10
  from pydantic import TypeAdapter
11
11
  from pymatgen.analysis.phase_diagram import PhaseDiagram
12
12
  from pymatgen.core import Element
13
+ from pymatgen.entries.computed_entries import ConstantEnergyAdjustment
13
14
 
14
15
  from mp_api.client.core import BaseRester
15
16
  from mp_api.client.core._display import status
@@ -24,6 +25,45 @@ if TYPE_CHECKING:
24
25
  from enums import Enum
25
26
 
26
27
 
28
+ def _accessible_entries(pd: PhaseDiagram) -> list:
29
+ """The entries of a pre-built GGA(+U)/r2SCAN phase diagram without the access-
30
+ controlled (BY-NC licensed, GNoMe) ones, with energies as if mixed without them.
31
+
32
+ GNoMe entries in the mixed phase diagrams are r2SCAN, so they only affect the mixing
33
+ state or other entries' energies in r2SCAN-anchored systems. If this is the case and
34
+ GNoMe entries are being pruned, we re-reference to the r2SCAN hull without them, as
35
+ a re-mix would give.
36
+ """
37
+ entries = [e for e in pd.all_entries if e.data.get("license") != "BY-NC"]
38
+ shifted = [
39
+ e
40
+ for e in entries
41
+ if any(
42
+ "onto the r2SCAN hull" in (a.description or "")
43
+ for a in e.energy_adjustments
44
+ )
45
+ ]
46
+ if shifted:
47
+ r2scan = [
48
+ e for e in entries if str(e.parameters.get("run_type")).lower() == "r2scan"
49
+ ]
50
+ hull = PhaseDiagram(r2scan, elements=pd.elements)
51
+ shifts = [ # (all before any entry energies change)
52
+ hull.get_hull_energy_per_atom(e.composition)
53
+ - pd.get_hull_energy_per_atom(e.composition)
54
+ for e in shifted
55
+ ]
56
+ for entry, shift in zip(shifted, shifts, strict=True):
57
+ if shift > 1e-10: # beyond float noise
58
+ entry.energy_adjustments.append(
59
+ ConstantEnergyAdjustment(
60
+ shift * entry.composition.num_atoms,
61
+ name="MP GGA(+U)/r2SCAN mixing adjustment, without GNoMe entries",
62
+ )
63
+ )
64
+ return entries
65
+
66
+
27
67
  class ThermoRester(BaseRester):
28
68
  suffix = "materials/thermo"
29
69
  document_model = ThermoDoc # type: ignore
@@ -246,6 +286,14 @@ class ThermoRester(BaseRester):
246
286
  if len(pds := TypeAdapter(list[PhaseDiagramType]).validate_python(as_py)) > 0:
247
287
  pd = pds[0]
248
288
 
289
+ # pre-built phase diagrams include the access-controlled GNoMe entries
290
+ if (
291
+ pd
292
+ and any(e.data.get("license") == "BY-NC" for e in pd.all_entries)
293
+ and not self._has_gnome_access()
294
+ ):
295
+ pd = PhaseDiagram(_accessible_entries(pd), elements=pd.elements)
296
+
249
297
  # Ensure el_ref keys are Element objects for PDPlotter.
250
298
  # Ensure qhull_data is a numpy array
251
299
  # This should be fixed in pymatgen
@@ -40,11 +40,11 @@ classifiers = [
40
40
  ]
41
41
 
42
42
  dependencies = [
43
- "pymatgen>2024.2.20",
43
+ "pymatgen>=2026.10.24",
44
44
  "requests>=2.23.0",
45
45
  "monty>=2024.12.10",
46
- "emmet-core>=0.88.0rc3,<0.88.1",
47
- "boto3",
46
+ "emmet-core>=0.88.0",
47
+ "boto3>=1.34",
48
48
  "orjson >= 3.10,<4",
49
49
  "pyarrow >= 20.0.0",
50
50
  "deltalake>=1.4.0,<1.6.0",
@@ -70,7 +70,7 @@ contribs = [
70
70
  ]
71
71
  all = [
72
72
  "custodian",
73
- "emmet-core[all]>=0.88.0rc,<0.88.1",
73
+ "emmet-core[all]>=0.88.0",
74
74
  "fastmcp",
75
75
  "flask",
76
76
  "ipywidgets",
@@ -6,6 +6,7 @@ these tests need no network access, API key, or files on disk.
6
6
 
7
7
  import logging
8
8
  import threading
9
+ import time
9
10
  import warnings
10
11
 
11
12
  import pyarrow as pa
@@ -18,9 +19,9 @@ from mp_api.client.core.delta import DeltaCatalog, _is_missing_object
18
19
  from mp_api.client.core.exceptions import MPRestError, MPRestWarning
19
20
 
20
21
  REAL_ERROR = (
21
- "Failed to fetch metadata for file Users/tsmathis/mp_datasets/build/collections/"
22
+ "Failed to fetch metadata for file data/mp_datasets/build/collections/"
22
23
  "materials/version=2026-04-13/group-4-part-0.zstd.parquet: Parquet error: External: "
23
- "Object at location /Users/tsmathis/mp_datasets/build/collections/materials/"
24
+ "Object at location /data/mp_datasets/build/collections/materials/"
24
25
  "version=2026-04-13/group-4-part-0.zstd.parquet not found: No such file or "
25
26
  "directory (os error 2)"
26
27
  )
@@ -344,6 +345,13 @@ def _in_thread(fn, *args, **kwargs):
344
345
  return th, result
345
346
 
346
347
 
348
+ def _wait_until(predicate, timeout=5.0):
349
+ deadline = time.monotonic() + timeout
350
+ while not predicate():
351
+ assert time.monotonic() < deadline, "test timed out"
352
+ time.sleep(0.005)
353
+
354
+
347
355
  def test_reload_does_not_block_queries_on_other_tables(catalog, monkeypatch):
348
356
  blocker = BlockingLoads(monkeypatch, "s3a://bucket/a/")
349
357
 
@@ -386,6 +394,9 @@ def test_concurrent_refreshes_of_same_table_reload_once(catalog, monkeypatch):
386
394
  t1, r1 = _in_thread(catalog.execute, "SELECT * FROM a", label="a")
387
395
  assert blocker.started.wait(5)
388
396
  t2, r2 = _in_thread(catalog.execute, "SELECT * FROM a", label="a")
397
+ # t2 must take the second failure before t1's reload finishes; otherwise
398
+ # t1's retry takes it and fails
399
+ _wait_until(lambda: not FakeQueryBuilder.failures)
389
400
 
390
401
  blocker.release.set()
391
402
  t1.join(5)
@@ -69,3 +69,37 @@ def test_get_phase_diagram_from_chemsys():
69
69
  pd,
70
70
  PhaseDiagram,
71
71
  )
72
+
73
+
74
+ def test_get_phase_diagram_from_chemsys_gnome_access(rester):
75
+ """The (access-controlled, BY-NC licensed) GNoMe entries of the pre-built phase
76
+ diagrams are only served to API keys with access to the GNoMe data."""
77
+ rester._gnome_access = True # (the cached access check)
78
+ full = rester.get_phase_diagram_from_chemsys("Cu-Se-Si")
79
+ rester._gnome_access = False
80
+ pd = rester.get_phase_diagram_from_chemsys("Cu-Se-Si")
81
+
82
+ # the GNoMe Cu3SiSe4 is on the r2SCAN-anchored hull (as of v2026.09.28), so the
83
+ # GGA(+U)-only entries placed onto it are re-referenced (up) without it, and the
84
+ # other entries keep their energies:
85
+ gnome = {str(e.entry_id) for e in full.all_entries if e.data["license"] == "BY-NC"}
86
+ full_energies = {str(e.entry_id): e.energy_per_atom for e in full.all_entries}
87
+ energies = {str(e.entry_id): e.energy_per_atom for e in pd.all_entries}
88
+ reref = {
89
+ str(e.entry_id)
90
+ for e in pd.all_entries
91
+ if any("without GNoMe" in adj.name for adj in e.energy_adjustments)
92
+ }
93
+ assert gnome and reref
94
+ assert set(energies) == set(full_energies) - gnome
95
+ for i, energy in energies.items():
96
+ if i in reref:
97
+ assert energy > full_energies[i]
98
+ else:
99
+ assert energy == pytest.approx(full_energies[i])
100
+
101
+
102
+ def test_failed_gnome_access_check_not_cached():
103
+ with ThermoRester(api_key="a" * 32) as rester: # invalid key, so the check fails
104
+ assert not rester._has_gnome_access()
105
+ assert rester._gnome_access is None # so checked again on the next call
@@ -218,9 +218,10 @@ def test_mixing_results_identical_with_progress(term):
218
218
  log="Re-mixing",
219
219
  summary="Re-mixed 8 entries ({kept:,} kept)",
220
220
  )
221
- assert [(e.entry_id, e.energy) for e in processed] == pytest.approx(
222
- [(e.entry_id, e.energy) for e in expected]
223
- )
221
+ for processed_entry, expected_entry in zip(processed, expected):
222
+ assert processed_entry.entry_id == expected_entry.entry_id
223
+ assert processed_entry.energy == pytest.approx(expected_entry.energy)
224
+
224
225
  # the caller's scheme and its parts were never modified
225
226
  for obj in (scheme, scheme.compat_1, scheme.structure_matcher):
226
227
  assert not {"get_adjustments", "group_structures"} & set(vars(obj))
@@ -430,4 +431,53 @@ def test_get_stability_shows_progress(mpr, thermo, monkeypatch, term):
430
431
  mine = [gga[3]]
431
432
  result = mpr.get_stability(mine, thermo_type="GGA_GGA+U")
432
433
  assert result and result[0]["entry_id"] == "GGA-4"
434
+ assert result[0]["e_above_hull"] is not None
433
435
  assert "Corrected 4 entries (4 kept)" in plain(term.getvalue())
436
+
437
+
438
+ @pytest.mark.parametrize(
439
+ "without, e_above_hull",
440
+ [ # MP's Li, O2 and Li2O ground states all have r2SCAN twins, so r2SCAN anchors:
441
+ (None, [None, None, 0.05, None, None, None]),
442
+ # without Li2O's r2SCAN twin, GGA(+U) anchors:
443
+ ("r2SCAN-3", [0.05, 0.05, None, None, -0.05, None]),
444
+ ],
445
+ ids=["r2SCAN", "GGA(+U)"],
446
+ )
447
+ def test_get_stability_dropped_entries(
448
+ mpr, thermo, monkeypatch, pipe, without, e_above_hull
449
+ ):
450
+ """Dropped entries only get an `e_above_hull` if on the hull's energy scale."""
451
+ from pymatgen.analysis.phase_diagram import PhaseDiagram
452
+ from pymatgen.entries.computed_entries import ComputedEntry
453
+ from pymatgen.io.vasp.sets import MPRelaxSet
454
+
455
+ mp = [e for e in li_o_entries() if e.entry_id != without]
456
+ thermo("get_phase_diagram_from_chemsys", lambda self, *a, **k: PhaseDiagram(mp))
457
+ monkeypatch.setattr(type(mpr), "_get_unmixed_entries", lambda self, *a, **k: mp)
458
+ li = (["Li"], [[0, 0, 0]], 3.4) # MP's Li structure
459
+ li2o = (["Li", "Li", "O"], [[0, 0, 0], [0.5, 0.5, 0.5], [0.25, 0.25, 0.25]], 4.6)
460
+ bad_u = _entry("gga-bad-u", "GGA+U", *li2o, -4.75) # MP2020 rejects U on Li
461
+ bad_u.parameters |= {"hubbards": {"Li": 3.0}, "is_hubbard": True}
462
+ mine = [ # twins of MP's materials, 0.05 eV/atom higher in energy:
463
+ _entry("gga", "GGA", *li, -1.85),
464
+ ComputedEntry("Li2O", 3 * -4.75, parameters={"run_type": "GGA"}), # an oxide
465
+ _entry("r2scan", "r2SCAN", *li, -2.85),
466
+ bad_u,
467
+ ComputedEntry(
468
+ "Li", -1.95, parameters={"run_type": "GGA"}, entry_id="gga-below"
469
+ ),
470
+ ]
471
+ # get_stability checks POTCARs; all but the last entry have them
472
+ for entry in [*mp, *mine]:
473
+ entry.parameters["potcar_symbols"] = [
474
+ f"PAW_PBE {MPRelaxSet.CONFIG['POTCAR'][el.symbol]}" for el in entry.elements
475
+ ]
476
+ mine.append(ComputedEntry("Li", -1.85, parameters={"run_type": "GGA"}))
477
+ labels = ["gga", "user-entry-1", "r2scan", "gga-bad-u", "gga-below", "user-entry-5"]
478
+ unplaced = ", ".join(labels[i] for i, e in enumerate(e_above_hull) if e is None)
479
+ with pytest.warns(MPRestWarning, match=f"None: {unplaced}$"):
480
+ result = mpr.get_stability(mine, thermo_type="GGA_GGA+U_R2SCAN")
481
+
482
+ assert [r["entry_id"] for r in result] == labels
483
+ assert [r["e_above_hull"] for r in result] == pytest.approx(e_above_hull)