materialsproject / api

New API client for the Materials Project
https://materialsproject.github.io/api/
Other
104 stars 38 forks source link

MPRest Error for material project #820

Closed nmehjabin closed 1 year ago

janosh commented 1 year ago

Please post the code you're running.

janosh commented 1 year ago

Could you make it a minimal repro (the smallest piece of code that reproduces your error)?

QuantumChemist commented 1 year ago

Hi @janosh , it might be related to my issue https://github.com/materialsproject/api/issues/814#event-9583619067

janosh commented 1 year ago

@munrojm Does this look like a dupe of #814? If so, @nmehjabin is the error still happening reliably?

munrojm commented 1 year ago

Yes, this could be related to the server issues we have been dealing with. We are getting out a new deployment ASAP which will hopefully help with this.

nmehjabin commented 1 year ago

Yes, this could be related to the server issues we have been dealing with. We are getting out a new deployment ASAP which will hopefully help with this.

I have went through the material project documentation and they have New API and Legacy API. I am trying to use New API on my projects and I have noticed that they have also changed their query style of writing. The recent bug that I am getting is that my API key works when I test it in https://api.materialsproject.org/docs#/Materials%20Summary/search_materials_summary_stats__get So it looks like my API key is working. However, when I try to run a snippet of code that has query with my API it gives an error.

Code

from mp_api.client import MPRester with MPRester("A3gokBALO3E6mu2jZMDCcpB3MTGExf0v") as mpr: docs = mpr.materials.search(material_ids=["mp-149", "mp-13", "mp-22526"])

Error

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/materials/?material_ids=mp-149&material_ids=mp-13&material_ids=mp-22526&all_fields=True&limit=1000 with message: Not Found

nmehjabin commented 1 year ago

@munrojm Does this look like a dupe of #814? If so, @nmehjabin is the error still happening reliably?

Yes.

nmehjabin commented 1 year ago

Yes, this could be related to the server issues we have been dealing with. We are getting out a new deployment ASAP which will hopefully help with this.

Are you saying that it's something I should wait to fix the problem?

munrojm commented 1 year ago

The 404 error can be resolved by updating your mp-api package. Other timeout issues may be resolved in a day or two on our end.

nmehjabin commented 1 year ago

I did pip install mp-api and used "from mp_api.client import MPRester" and I still get the same issues. Does it have to be with the query? Because previously when it was running, I used query() but now I saw in the documentation there were examples with "summary.search()" and "materials.search()". Thanks for the prompt response.

munrojm commented 1 year ago

Shouldn't be the query. I can tell by the endpoint it is trying to ping in the error message that your client is out of date. What is the exact version of both python and mp-api that you are using? Have you tried running pip install mp-api --upgrade?

nmehjabin commented 1 year ago

Hi. I have updated my python version to 10 and I did pip install -U mp-api and the version shows mp-api==0.33.3. However, I am trying to run a piece of code to see if my API key works and grab the information from the database.

Code

from mp_api.client import MPRester with MPRester(“MY_API_KEY”) as mpr: docs = mpr.materials.search(material_ids=[“mp-149”, “mp-13”, “mp-22526”])

Error

MPRestError: REST query returned with error status code 404 on URL https://api.materialsproject.org/materials/?material_ids=mp-149&material_ids=mp-13&material_ids=mp-22526&all_fields=True&limit=1000 with message: Not Found

munrojm commented 1 year ago

That version is correct, but the endpoint it is spitting out in the error still tells me it isn't updated in whatever environment you are running the code in. If it was running with the newest client, it would be trying to hit https://api.materialsproject.org/materials/core/... and not https://api.materialsproject.org/materials/.... Are you running this in a jupyter notebook?

nmehjabin commented 1 year ago

Yes this is being run in a Jupyter notebook

munrojm commented 1 year ago

Have you made sure the notebook kernel is refreshed and correctly pulling from the updated installation of python and mp-api?

nmehjabin commented 1 year ago

I fixed the issue. Thanks for all the help. I really appreciate.

munrojm commented 1 year ago

No worries!