-
Notifications
You must be signed in to change notification settings - Fork 192
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
CifData constructor parses cif file, and then throws parsed object away #1186
Comments
This indeed seems to be a bug. Looking back to the introduction of For the solution here I support the lazy spirit. Attributes A quick fix would be just to move initialization of |
Thanks, I'm working on a solution now, pull request comes soon
Thanks for the notice, I'll have a look. |
I think this is the best way to do. |
In the following piece of code
the constructor of CifData seems to first parse the CIF file, and then throw the information away again.
Below is the code for the constructor:
https://github.com/aiidateam/aiida_core/blob/62a5258f09d92dd36cd75f5f462196c24037b078/aiida/orm/data/cif.py#L513-L519
After line 517,
self._values
actually holds the parsed CIF object [1]. Then it is set toNone
.This raises a few questions
_values
to be set (which I would prefer) or by hiding the_values
from this logic. Which of the two routes should be followed?CifData
in the end one wants at least two options for the constructor: a direct one, where the constructor parses the contents of the cif file and stores them, and a lazy one, where the constructor just stores the file name and the Cif file is parsed on demand.Perhaps even a third one, which is the current model of storing only formula & spacegroup and throwing away the python object so that it does not bloat the DB.
Which of these options should be the default?
Mentioning @merkys who seems to have written these lines...
Also mentioning @giovannipizzi @nmounet
[1] This goes via a rather complicated route. The
super
callsaiida/orm/implementation/sqlalchemy/node.py
_init__
=> aiida/orm/implementation/general/node.py
_set_with_defaults
=> aiida/orm/implementation/general/node.py
_set_internal
=> (somehow) aiida/orm/data/cif.py
set_file
=> aiida/orm/data/cif.py
_set_attr('formulae', self.get_formulae())
which causes the CIF file to be read
Edit: Regarding 2., on reflection it is not that strange anymore, if one has learned that in the 'AiiDA way' calling the constructor with
file=<filename>
calls theset_file
functionhttps://github.com/aiidateam/aiida_core/blob/62a5258f09d92dd36cd75f5f462196c24037b078/aiida/orm/data/cif.py#L528-L543
where
get_formula
then inevitably forces the parsing of the cif file.The text was updated successfully, but these errors were encountered: