The server does not support the request made to https://api.materialsproject.org/materials/thermo/?_fields=entries%2Cthermo_type&formula=e_above_hull&_limit=1000
Code snippet
mpr.get_entries({"e_above_hull": {"$lte": 0.001}}, compatible_only=True)
What happened?
I'm porting some old code to the new API, but ended up on an error from within mp_api.
Version
mp-api 0.41.2
Which OS?
- [ ] MacOS
- [ ] Windows
- [X] Linux
Log output
/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py:993: UserWarning: The server does not support the request made to https://api.materialsproject.org/materials/thermo/?_fields=entries%2Cthermo_type&formula=e_above_hull&_limit=1000. This may be due to an outdated mp-api package, or a problem with the query.
warnings.warn(
Traceback (most recent call last):
File "/home/chn/orexplore/git/earthcrust-simulator/presentation.py", line 274, in <module>
entries, orex_explanation = common_prologue()
^^^^^^^^^^^^^^^^^
File "/home/chn/orexplore/git/earthcrust-simulator/presentation.py", line 218, in common_prologue
entries = mpr.get_entries({"e_above_hull": {"$lte": 0.001}}, compatible_only=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/orexplore/git/earthcrust-simulator/mygetter.py", line 20, in wrapper
ret = real_method(*args, **kwords)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/mprester.py", line 738, in get_entries
docs = self.thermo.search(
^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/routes/materials/thermo.py", line 136, in search
return super()._search(
^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 1181, in _search
return self._get_all_documents(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 1254, in _get_all_documents
results = self._query_resource(
^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 565, in _query_resource
data = self._submit_requests(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 712, in _submit_requests
initial_data_tuples = self._multi_thread(
^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 934, in _multi_thread
data, subtotal = future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/chn/env/lib/python3.12/site-packages/mp_api/client/core/client.py", line 1027, in _submit_request_and_process
raise MPRestError(
mp_api.client.core.client.MPRestError: REST query returned with error status code 400 on URL https://api.materialsproject.org/materials/thermo/?_fields=entries%2Cthermo_type&formula=e_above_hull&_limit=1000 with message:
Problem processing one or more provided formulas.
You will have to add a list of chemical systems, formulas, or mpids, and pass the energy above hull query as additional criteria:
data = mpr.get_entries(chemsys_formula_mpids=["Si-O"],
additional_criteria={"energy_above_hull": (None, 0.001)},
compatible_only=True)
Thanks @munrojm, that works! It's only the error message that is misleading then.
What to pass as chemsys_formula_mpids to get all materials on the convext hull? (i.e. a system constisting of all elements)
What to pass as chemsys_formula_mpids to get all materials on the convext hull? (i.e. a system constisting of all elements)
@kalvdans Were you able to find a solution to your last question?
What to pass as chemsys_formula_mpids to get all materials on the convext hull? (i.e. a system constisting of all elements)
@kalvdans Were you able to find a solution to your last question?
Thanks for coming back to me. I was able to simulate the old behaviour by this ugly hack:
mpr.get_entries(["*", "*-*", "*-*-*"], additional_criteria=dict(energy_above_hull=(None, 0.001), thermo_types=["R2SCAN"]), compatible_only=True)
The error message I was complaining on has been improved since:
TypeError: MPRester.get_entries() missing 1 required positional argument: 'chemsys_formula_mpids'
so I'll close the bug! Thanks a lot!