Issue with search MP API with has_props()

The MP API documentation details how to use the has_props parameter, namely by providing a list of strings:

via:

with MPRester("your_api_key_here") as mpr:
    docs = mpr.materials.summary.search(
        has_props=["dielectric", "dos"], fields=["material_id"]
    )

However, it looks as if this code throws an error and I need to use the actual Enum object which is much less convenient:

from emmet.core.summary import HasProps
docs = mpr.materials.summary.search(has_props=[HasProps.dielectric, HasProps.dos], fields=["material_id"])

Can you confirm this behavior?

Thanks @Anubhav_Jain for reporting this! I can confirm that it throws the following error. I’m looking into it and will update this thread when a new release of mp-api is out.

File ~/miniconda3/envs/mp-api/lib/python3.10/site-packages/mp_api/client/routes/materials/summary.py:256, in <listcomp>(.0)
    253     query_params.update({"has_reconstructed": has_reconstructed})
    255 if has_props:
--> 256     query_params.update({"has_props": ",".join([i.value for i in has_props])})
    258 if theoretical is not None:
    259     query_params.update({"theoretical": theoretical})

AttributeError: 'str' object has no attribute 'value'

@Anubhav_Jain I just released mp-api==0.42.0 which should fix the issue.