-
Notifications
You must be signed in to change notification settings - Fork 189
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
upf to json converter #3308
upf to json converter #3308
Conversation
Thanks @simonpintarelli for the PR. @giovannipizzi, @sphuber this export functionality is needed to enable SIRIUS support within the aiida-cp2k plugin. I think the same could be used to support SIRIUS under QE. |
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.
Thanks, @simonpintarelli ,
Before I start the review please add a couple of tests (upf1->json, upf2->json) and fix the problems raised by the pre-commit run. Just run pre-commit run --all-files
to see all of them
As soon as it is done, I think there shouldn't be a problem to merge it.
38f584b
to
44f7bd3
Compare
Hi @simonpintarelli, I am unsure how familiar you are with pre-commit, so just to be more explicit (and if you already know it, then hopefully no harm done 😄 ):
when in the folder of the git cloned 'aiida-core' folder, or
if installing from PyPI and using AiiDA v0.12 (should not be the case here). After this, still being in the git cloned 'aiida-core' folder, you can run
and then, finally
as @yakutovicha writes 😃 |
34fd304
to
5163179
Compare
@CasperWA, I did |
bbf31cf
to
b34ae22
Compare
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.
For now we could include this into AiiDA core, even if eventually we want to move materials-science related classes in a different repository/plugin.
One question: do you have in mind of preparing a minimal library to manage UPF and then you could keep the code there and just depend on it, or this is the whole code for UPF that you have so it's easier to add it to aiida_core verbatim, as you are doing in this PR?
json_string, _ = self.pseudo_oxygen_upf1._prepare_json() | ||
filepath_base = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, os.pardir, 'fixtures', 'pseudos')) | ||
reference_json = json.dumps(json.load(open(os.path.join(filepath_base, 'O_raw.json'), 'r'))) | ||
self.assertEqual(json_string, reference_json.encode('utf-8')) |
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.
Could you compare the dictionaries rather than the strings?
@@ -0,0 +1,3 @@ | |||
""" UPF converter """ | |||
|
|||
from .upf_to_json import upf_to_json |
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.
The right place for these tools (we're slowly moving also other things there) is not in aiida/orm/data
but in aiida/tools/data/upf/...
. Could you move the logic there?
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.
@giovannipizzi Yes, this is the entire code we have for UPF to json conversion. Although moving it to a separate dependency might be a good idea.
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.
Moving the files to aiida/tools/data/upf seems to trigger a circular import if I then import the function in orm/nodes/data/upf.py
.
81fbc7a
to
6be3a57
Compare
I've moved the code to It passes through prospector on my computer and and export upf to json via verdi works as desired. For some reason now travis keeps failing on both python3 & 2:
|
78d6cfe
to
ac923d1
Compare
I have the feeling this might be a cyclic import error... can you investigate if you understand if this is the case, having this hint? |
5d67b4a
to
bc12816
Compare
@giovannipizzi There was a circular dependency, I've moved the json converter now to a separate package. There is one failure remaining. Where do I have to add a generator of a dummy instance?
|
You need to add a clause to |
@sphuber Thanks! I've rebased my PR to the latest develop branch, before there was no |
bc12816
to
5dedb5f
Compare
Travis is failing the last test, because conda cannot find Is it enough to publish the package on conda-forge? |
Yes, as long as it is on conda-forge, it should work. Note that even after pushing it to conda-forge it may take some time for it to become discoverable. But usually one hour after uploading should be sufficient. |
5dedb5f
to
1ea1ca0
Compare
@sphuber, thank you. PR is pending on conda-forge: conda-forge/staged-recipes#9862 |
767c84b
to
2ffba11
Compare
2ffba11
to
3127495
Compare
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.
@simonpintarelli thanks a lot, this is looking great now. Except for a minor typo, this is looking good to merge. Could you please address the final change and rebase?
@export_options | ||
@decorators.with_dbenv() | ||
def upf_export(**kwargs): | ||
"""Export StructureData object to file.""" |
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.
"""Export StructureData object to file.""" | |
"""Export `UpfData` object to file.""" |
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.
Thanks. I've fixed it.
UPF format 1 and 2 are supported. SIRIUS requires pseudopotentials in json format.
Export a upf to json using: verdi data export upf
3127495
to
5d325d3
Compare
Thanks a lot for the contribution @simonpintarelli |
_prepare_json
to upf classverdi data upf export PK
to cli interface