materialsproject / api

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

[Bug or New restriction]: exclude_elements - String should have at most 15 characters #879

Open JiaoyueYuan opened 6 months ago

JiaoyueYuan commented 6 months ago

I have a list of ~20 elements that need to be excluded in MP query. The code worked fine on Dec 1st, but failed with this error on Dec 11th:

mp_api.client.core.client.MPRestError: REST query returned with error status code 422 on URL ... with message:
exclude_elements - String should have at most 15 characters

Any query with exclude_elements length > 15 characters (including comma) would result in the same error. eg,.

from mp_api.client import MPRester
from emmet.core.summary import HasProps

with MPRester("your_api_key") as mpr:
    exclude_eles = ["H", "Rb", "Cs", "Be", 
                    "Mn", "Tc", "Re", "Fe", 
                    "Ru", "Os", "Co", "Rh",
                    "Ir", "Ni", "Pd", "Pt",
                    "Ag", "Au", "Cd", "Hg"]

    docs = mpr.summary.search(num_elements=3, 
                              is_gap_direct=True,
                              exclude_elements=exclude_eles,
                              has_props=[HasProps.bandstructure],
                              fields=["material_id"])

I am wondering if this is a new restriction or a bug.

munrojm commented 6 months ago

This is a new restriction for the time being while we address some performance issues with our infrastructure.

Shibu778 commented 4 months ago

I am encountering the same error. Can you please tell when are you going to remove this restriction?