materialsproject / api

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

Elasticity document `search` method keyword argument error #811

Open thomasgho opened 1 year ago

thomasgho commented 1 year ago

Hello, I'm trying to retrieve elasticity documents, but failing to do so when searching via material ids.

Version Info

python == 3.11.3 mp-api == 0.33.3 emmet-core == 0.55.2

Reproduction

From the direction of the website under Elastic Constant -> API for a material, I tried:

from mp_api.client import MPRester

with MPRester(api_key="<api key>") as mpr:
    elasticity_doc = mpr.elasticity.search(material_ids=["mp-27971"])

This raises:

TypeError: ElasticityRester.search() got an unexpected keyword argument 'material_ids'

Expected Behavior

The elasticity document to be returned for given material ids.

munrojm commented 1 year ago

Hi @thomasgho, unfortunately the elasticity endpoint does not support searching with lists of MPIDs. This endpoint is going to be updated soon alongside a big data release, where that will be added in. For now, I would recommend passing nothing to the endpoint to just pull every document and filter locally (it isn't very large), or just use MPRester.elasticity.get_data_by_id.