Hello!
I have a program which I have been using for a long time which calls “MPRester.get_phonon_dos_by_material_id”, and yesterday (without any changes to my own environment), I began to receive ‘None’ types for this call (for systems which I know have phonon DOS in MP because I have been pulling and using them all year.) I see all the past posts whose similar issues with get_dos_by_material_id, get_structure_by_material_id, etc. were resolved by updating the mp-api version (so now I’m at v0.45.6) , but when I did this: I got the following:
ImportError: cannot import name 'PhononBS' from 'emmet.core.phonon' (C:\Users\xxxxxx\miniforge3\envs\ElasticMod\Lib\site-packages\emmet\core\phonon.py). Did you mean: 'Phonon'?
Following my nose through the proceeding cascade of dependency errors, I tried upgrading Pymatgen (now v2025.5.28), emmet-core (now v0.84.7), pydantic (now v2.11.6), and pydantic-core (v2.33.2) until I reached the following error:
PDOS = mpr.get_phonon_dos_by_material_id(mpid)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\mprester.py", line 1251, in get_phonon_dos_by_material_id
doc = self.materials.phonon.search(material_ids=material_id, fields=["ph_dos"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\routes\materials\phonon.py", line 60, in search
return super()._search(
^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\core\client.py", line 1191, in _search
return self._get_all_documents(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\core\client.py", line 1264, in _get_all_documents
results = self._query_resource(
^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\core\client.py", line 464, in _query_resource
raise MPRestError(
mp_api.client.core.client.MPRestError: invalid fields requested: ['ph_dos']. Available fields: ['builder_meta', 'nsites', 'elements', 'nelements', 'composition', 'composition_reduced', 'formula_pretty', 'formula_anonymous', 'chemsys', 'volume', 'density', 'density_atomic', 'symmetry', 'identifier', 'phonon_method', 'phonon_bandstructure', 'phonon_dos', 'epsilon_static', 'epsilon_electronic', 'born', 'force_constants', 'last_updated', 'sum_rules_breaking', 'structure', 'total_dft_energy', 'volume_per_formula_unit', 'formula_units', 'supercell_matrix', 'primitive_matrix', 'code', 'post_process_settings', 'thermal_displacement_data', 'calc_meta', 'material_id', 'task_ids']
Naturally, seeing there was a clear keyword mistake, I went into mp_api/client/MPRester.py and changed the keyword from “ph_dos” to “phonon_dos” to see if this would fix the issue, but instead I was met with:
make_tensor_heat_map(trueTensor, VASPTensor.voigt, mpid=mpid, vasp=True, nionic_steps=nsteps, showDebye=True)
File "c:\[...]\elastic_tensor_from_bulk_relax.py", line 1317, in make_tensor_heat_map
PDOS = mpr.get_phonon_dos_by_material_id(mpid)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\mprester.py", line 1251, in get_phonon_dos_by_material_id
doc = self.materials.phonon.search(material_ids=material_id, fields=["phonon_dos"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\routes\materials\phonon.py", line 60, in search
return super()._search(
^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 1191, in _search
return self._get_all_documents(
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 1264, in _get_all_documents
results = self._query_resource(
^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 570, in _query_resource
data = self._submit_requests(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 717, in _submit_requests
initial_data_tuples = self._multi_thread(
^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 939, in _multi_thread
data, subtotal = future.result()
^^^^^^^^^^^^^^^
File "C:\[...]\Lib\concurrent\futures\_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\[...]\Lib\concurrent\futures\thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\site-packages\mp_api\client\core\client.py", line 1017, in _submit_request_and_process
data["data"] = self._convert_to_model(data["data"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\mp_api\client\core\client.py", line 1059, in _convert_to_model
data_model(
File "C:\[...]\Lib\site-packages\pydantic\main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\[...]\Lib\site-packages\pydantic\_internal\_mock_val_ser.py", line 100, in __getattr__
raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `MPDataDoc` is not fully defined; you should define `PhononComputationalSettings`, then call `MPDataDoc.model_rebuild()`.
For further information visit https://errors.pydantic.dev/2.11/u/class-not-fully-defined
Now, having already updated pydantic and pydantic-core, I have officially hit a wall. Can someone please help me understand what’s going on and address this dependency issue with mp-api?