-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Pourbaix client #428
Add Pourbaix client #428
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be down with merging this as-is and improving with a future PR, concur? This is great otherwise, thank you(!)
|
||
return pbx_entries | ||
|
||
# TODO - @lru_cache causes this method to fail when chemsys is given as a list, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use Union[str, Tuple]
instead, which is hashable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep the call signature consistent with get_pourbaix_entries
and other methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep it consistent with the legacy method? It has to be tuple/hashable if you want to use @lru_cache, it cannot be list. Change is worth it imo to make the function cachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to keep consistent with get_entries
or get_entries_in_chemsys
. Users expect to be able to specify a chemsys as either a string Li-Fe-O
or a list ['Li','Fe','O']
, right? I don't recall seeing anywhere where we specify the chemsys as a tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but we can change that. Or you can make this a private method that accepts a tuple and the public method accepts a list and converts it. Either way. But I think it's an important method to cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no argument at all with that approach; I just want to keep the user-facing arguments consistent
# capitalize and sort the elements | ||
chemsys = sorted(e.capitalize() for e in chemsys) | ||
|
||
# TODO - see if there is a way to avoid querying the entire collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. You can query for a formula containing a substring with formula__contains
or any of the data fields, see https://contribs-api.materialsproject.org/#/contributions/get_entries for syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. What we would really need here is the equivalent of mongo $in
, i.e. {'MajElements`: {"$in": chemsys}}. As best I can tell that isn't possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refer that to @tschaume :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to use data__MajElements__in
, e.g. https://contribs-api.materialsproject.org/contributions/?project=ion_ref_data&data__MajElements__in=Li,B&_fields=identifier,data.MajElements
Thanks @mkhorton! I'm good with this as is now. Please check the test failures though; there seems to be something wrong with the api key setting in the test environment but I don't think it's related to anything in this PR. Not 100% sure though. There are a ton of these errors:
|
The tests should pass once merged. Can you confirm they are all passing locally @rkingsbury ? |
Locally, I have one failure in
|
Ok, I'll go ahead and merge and we can fix up in an additional PR. Thanks again! |
@rkingsbury The |
that would be great @tschaume , thanks. I might actually make use of that soon as part of the SCAN work. |
get_pourbaix_entries
to MPRester with an equivalent call signature to the legacy pymatgen methodGibbsComputedStructureEntry
get_ion_reference_data
andget_ion_entries
methods to make it a little easier and more transparent for users to customize Pourbaix diagramsContributor Checklist
TODO
get_pourbaix_entries
more thorough