Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #919

Open
1 of 3 tasks
kalvdans opened this issue Jul 6, 2024 · 2 comments

Comments

@kalvdans
Copy link

kalvdans commented Jul 6, 2024

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
  • 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.
@kalvdans kalvdans added the bug Something isn't working label Jul 6, 2024
@kalvdans kalvdans changed the title [Bug]: 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. [Bug]: 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 Jul 6, 2024
@kalvdans kalvdans changed the title [Bug]: 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 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 Jul 6, 2024
@munrojm
Copy link
Member

munrojm commented Jul 11, 2024

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)

@munrojm munrojm removed the bug Something isn't working label Jul 11, 2024
@kalvdans
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants