Fix potential inefficiency in aiida.tools.data.cif
converters
#3098
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3097
Recently, the
BackendNode
interface and implementation was changedsignificantly with respect to attributes and extras. As a result, the
values on unstored nodes are not cleaned until the node is stored.
That means that unstored nodes can contain attributes and extras with
uncleaned values. For example an unstored
Dict
node can containedstored
Float
nodes. This change becomes problematic in theimplementation of
_get_aiida_structure_pymatgen_inline
and_get_aiida_structure_ase_inline
ofaiida.tools.data.cif
. Theparameters
keyword argument can be an unstoredDict
node, if thefunctions are run with
store_provenance=False
. Since it is unstored,it can contain stored nodes for the values within them. For example,
the
site_tolerance
can be a storedFloat
. Since they are overloadednative float objects, they can be passed to pymatgens
CifParser
without it complaining. However, now whenever that class references the
value, since it is a stored node, the
ModelWrapper
will cause themodel instance to be refreshed from the database, which becomes
prohibitively expensive. Simply calling
clean_value
on theparameters
beforehand, will cause these nodes to be dereferenced intotheir base values, which solves the issue.