but this returns âNoneâ for k_voight and g_voight.
An additional question: I see query time can be reduced by using has_props=[âk_voightâ], for example, but when I add this to search() is gives the following error:
For using HasProps I could use a little more guidance though. This is what Iâm trying now
from mp_api.client import MPRester
from emmet.core.summary import HasProps
with MPRester("uJpFxJJGKCSp9s1shwg9HmDuNjCDfWbM") as mpr:
docs = mpr.materials.summary.search(HasProps(elasticity), is_metal=True, fields=["material_id", "is_metal", "k_voigt"])
but it says âelasticityâ is not defined, even though that is one of the enum values?
I have a similar problem. I tried to used the provided code on Materials Project webpage:
from mp_api.client import MPRester
with MPRester(api_key="<enter your api key>") as mpr:
elasticity_doc = mpr.elasticity.search(material_ids=["mp-1265"])
but got the following error:
TypeError: search() got an unexpected keyword argument 'material_ids'
(I did change âenter your api keyâ to my own api key. Just donât want to show my key here.)
@Carla_Becker, we have just changed how some of the data is built but have not updated the docs yet. Sorry for the confusion. You can instead ask for bulk_modulus or bulk_modulus.voigt to get what you need in fields.
@jessechen the latest API client has support for querying elasticity data using a list of MPIDs. If you update to v0.38.0 it should work now.
I think the issue I have may be related to this. If not, my apologies. I am unable to query surface data information. I ran this exact code Friday and it worked. Is there a simple syntactical fix here as well?
with MPRester() as mpr:
surface_properties_doc = mpr.surface_properties.get_data_by_id("mp-30")
>>>---------------------------------------------------------------------------
MPRestError Traceback (most recent call last)
Input In [12], in <cell line: 1>()
1 with MPRester(api_key="") as mpr:
----> 2 surface_properties_doc = mpr.surface_properties.get_data_by_id("mp-30")
File /opt/conda/lib/python3.9/site-packages/mp_api/client/core/client.py:917, in BaseRester.get_data_by_id(self, document_id, fields)
912 results = self._query_resource_data(
913 criteria=criteria, fields=fields, suburl=document_id # type: ignore
914 )
916 if not results:
--> 917 raise MPRestError(f"No result for record {document_id}.")
918 elif len(results) > 1: # pragma: no cover
919 raise ValueError(
920 f"Multiple records for {document_id}, this shouldn't happen. Please report as a bug."
921 )
MPRestError: No result for record mp-30.
Just chiming in to say that both of the code snippets are working for me (except the doc.bulk_modulus.voigt part, since bulk_modulus attribute is a dictionary). In the recent past, I remember reading about people having issues with the API with an outdated mp-api package, even with a package a few minor versions or patches behind. Iâm guessing either this may be the issue or there was an outage with the API at the time these errors happened.
@Carla_Becker and @bwander make sure you have the most up to date emmet-core and mp-api. I believe that should fix the issues as @firaty has also suggested.
Same problem there. After querying materials with m.summary.search(âŚ, fields=[âk_voigtâ, âk_reussâ, âk_vrhâ, âg_voigtâ, âg_reussâ, âg_vrhâ]),
this list of fields is included in entries SummaryDoc âfields_not_requestedâ, with no elasticity data obtained.
It definitely was not like this in database version 2022.10.28, when all those fields were retrieved without problems!