You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parity with legacy MPRester convenience functions #676
This issue is to discuss what necessary parity should exist between the new and legacy MPRester top level convenience functions (e.g. MPRester.get_entries_in_chemsys).
Below is list of current breaking differences going from legacy to new.
Missing:
submit_vasp_directory
delete_snl
get_all_substrates
get_cohesive_energy
get_data
get_doc
get_download_info
get_exp_entries
get_exp_thermo_data
get_interface_reactions
get_phonon_ddb_by_material_id
get_reaction
get_stability
submit_vasp_directory
submit_snl
query_snl
parse_criteria
Major changes:
query replaced with MPRester.summary.search. No MongoDB-like query language support anymore.
get_gb_data replaced with MPRester.grain_boundary.search
get_substrates replaced with MPRester.substrates.search
get_surface_data replaced with MPRester.surface_properties.search
Based on the above, I think the only ones I think warrant feature parity are get_entries*. I know of course that inc_structure is irrelevant in the new API, but I think you should just leave the arg in, default it to None, and just have a warning message if someone puts in a value to say that this argument is maintained for backwards compatibility and has no effect in the new API. I think compatible_only, additional_criteria and property_data needs to be implemented for sure - those are often used. I am not sure where conventional_structure fits in here, since ComputedStructureEntries are already returned. I personally never used that, but maybe someone else did.
Rather than add deprecated kwargs to the docstring which do nothing, we could just add a catch-all **kwargs and warn if any additional ones are provided?
I think it is better to be explicit. E.g., if someone tries nonsense=True, we want the code to fail with "nonsense is not a supported kwarg" rather than a warning. There is only one arg that is redundant right now - inc_structure. The rest actually does something.
I'm fine with it raising instead of warning, it was more cluttering the docstring that I was asking about. But no strong feelings either way.
if kwargs:
# or even check for the specific list of kwargs here
raise ValueError("{','.join(kwargs.keys()} are not supported keyword arguments. These may only have been supported by the legacy API.")
Yeah, I prefer the documentation to say something about it too, since this is a clear change from previous behavior. Also, it is generally poor practice to allow an arbitrary list of args and then have to check it for validity. In any case, this is not a detail I want to bother debating over. So I will leave you guys to implement whichever way you want. I am more concerned with the broader issues of feature parity for the args that actually does somehting as well as broken documentation/features in the API.
Hi @munrojm, I want to follow up in this issue about the missing "get_cohesive_energy". Is there a way to get the cohesive energy or isolated energy of elements now? Previously, the MPRester could do that with _make_request, while now I'm wondering how to get the isolated elemental energies.
@JiQi535, this is currently being worked on. The isolated atom calculations will be incorporated into the API very soon. After that I can write a method for the client.
@shyuep, the updates to the methods are in the client. The only two arguments that don't have their behavior at parity are additional_criteria and inc_structure. For both of those, the user is warned if either is passed and the docstrings also list them as deprecated. Here is the relevant PR: #691
@shyuep The issue is that the MongoDB-like query syntax you would pass to that argument is not supported anymore. The updated alternative would be to pass a dictionary mapping between the new query arguments of MPRester.thermo.search and their values for additional criteria. This seems strange to me, as it departs significantly from the legacy behavior (requiring users to change their code anyway), and points to just using the MPRester.thermo.search method directly.
Can't we just pass **additional_criteria as kwarg to the query to set the criteria? If this is undoable, at the min allowing such a query, even if the syntax has to change, is preferable to not allowing it at all.
Yes, but will just be like passing **additional_criteria directly to MPRester.thermo.search. If you feel strongly about it and think we should do it, then I will update and patch release.
I think it is non obvious that entries come from Thermo endpoint. Entries have many functions other than thermo. Anyway, since it does not detract from functionality and would help backwards compatibility, we should just add it.
The get_all_substrates in legacy MPRester returns a list of material_ids ("/materials/all_substrate_ids") corresponding to possible substrates. Is such a list of material_ids also used by substrates.search?
For example, I have tried insertion_electrodes.search(fields=['battery_id']) and get all battery ids. However, a similar search on substrates returns error ("Server timed out trying to obtain data. Try again with a smaller request").
The list of substrates is desired when a local film structure without material_id is considered. Thank you.
get_cohesive_energy was implemented in #951 by @esoteric-ephemera today after additional requests through the forum. A release candidate for it will be published soon.
@goodwillingmpr.materials.substrates.search() should not be timing out anymore but will still take a while since there are 10M documents to download. Internally reorganizing the document structure for the substrates collection is on our TODO list.
Activity
munrojm commentedon Sep 22, 2022
@shyuep this is current as of
v0.27.3shyuep commentedon Sep 23, 2022
Based on the above, I think the only ones I think warrant feature parity are
get_entries*. I know of course thatinc_structureis irrelevant in the new API, but I think you should just leave the arg in, default it to None, and just have a warning message if someone puts in a value to say that this argument is maintained for backwards compatibility and has no effect in the new API. I thinkcompatible_only,additional_criteriaandproperty_dataneeds to be implemented for sure - those are often used. I am not sure whereconventional_structurefits in here, since ComputedStructureEntries are already returned. I personally never used that, but maybe someone else did.mkhorton commentedon Oct 3, 2022
Rather than add deprecated kwargs to the docstring which do nothing, we could just add a catch-all
**kwargsand warn if any additional ones are provided?shyuep commentedon Oct 3, 2022
I think it is better to be explicit. E.g., if someone tries nonsense=True, we want the code to fail with "nonsense is not a supported kwarg" rather than a warning. There is only one arg that is redundant right now - inc_structure. The rest actually does something.
mkhorton commentedon Oct 3, 2022
I'm fine with it raising instead of warning, it was more cluttering the docstring that I was asking about. But no strong feelings either way.
shyuep commentedon Oct 3, 2022
Yeah, I prefer the documentation to say something about it too, since this is a clear change from previous behavior. Also, it is generally poor practice to allow an arbitrary list of args and then have to check it for validity. In any case, this is not a detail I want to bother debating over. So I will leave you guys to implement whichever way you want. I am more concerned with the broader issues of feature parity for the args that actually does somehting as well as broken documentation/features in the API.
JiQi535 commentedon Oct 10, 2022
Hi @munrojm, I want to follow up in this issue about the missing "get_cohesive_energy". Is there a way to get the cohesive energy or isolated energy of elements now? Previously, the MPRester could do that with _make_request, while now I'm wondering how to get the isolated elemental energies.
munrojm commentedon Oct 11, 2022
@JiQi535, this is currently being worked on. The isolated atom calculations will be incorporated into the API very soon. After that I can write a method for the client.
munrojm commentedon Oct 11, 2022
@shyuep, the updates to the methods are in the client. The only two arguments that don't have their behavior at parity are
additional_criteriaandinc_structure. For both of those, the user is warned if either is passed and the docstrings also list them as deprecated. Here is the relevant PR: #691shyuep commentedon Oct 11, 2022
Thanks. But
additional_criteriashouldn't be deprecated. It is actually immensely useful.munrojm commentedon Oct 11, 2022
@shyuep The issue is that the MongoDB-like query syntax you would pass to that argument is not supported anymore. The updated alternative would be to pass a dictionary mapping between the new query arguments of
MPRester.thermo.searchand their values for additional criteria. This seems strange to me, as it departs significantly from the legacy behavior (requiring users to change their code anyway), and points to just using theMPRester.thermo.searchmethod directly.shyuep commentedon Oct 11, 2022
Can't we just pass **additional_criteria as kwarg to the query to set the criteria? If this is undoable, at the min allowing such a query, even if the syntax has to change, is preferable to not allowing it at all.
munrojm commentedon Oct 12, 2022
Yes, but will just be like passing
**additional_criteriadirectly toMPRester.thermo.search. If you feel strongly about it and think we should do it, then I will update and patch release.shyuep commentedon Oct 12, 2022
I think it is non obvious that entries come from Thermo endpoint. Entries have many functions other than thermo. Anyway, since it does not detract from functionality and would help backwards compatibility, we should just add it.
munrojm commentedon Oct 13, 2022
Okay, I have updated the client and have done a patch release.
goodwilling commentedon Feb 8, 2023
The get_all_substrates in legacy MPRester returns a list of material_ids ("/materials/all_substrate_ids") corresponding to possible substrates. Is such a list of material_ids also used by substrates.search?
For example, I have tried insertion_electrodes.search(fields=['battery_id']) and get all battery ids. However, a similar search on substrates returns error ("Server timed out trying to obtain data. Try again with a smaller request").
The list of substrates is desired when a local film structure without material_id is considered. Thank you.
munrojm commentedon Feb 9, 2023
@goodwilling which exact query are you trying to make? I can take a look at this.
goodwilling commentedon Feb 9, 2023
Thanks. The query that I made is as follows:
mpr= MPRester(API_key)
docs = mpr.substrates.search(fields=['sub_id'])
tschaume commentedon Dec 14, 2024
get_cohesive_energywas implemented in #951 by @esoteric-ephemera today after additional requests through the forum. A release candidate for it will be published soon.@goodwilling
mpr.materials.substrates.search()should not be timing out anymore but will still take a while since there are 10M documents to download. Internally reorganizing the document structure for the substrates collection is on our TODO list.