aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
414 stars 185 forks source link

Caching: Rename `get_hash` to `compute_hash` #6347

Closed sphuber closed 2 months ago

sphuber commented 2 months ago

The get_hash method was actually recomputing the hash and not just returning the hash stored in the extras that was computed when the node got stored. The get_hash and _get_hash methods are renamed to compute_hash and _compute_hash, respectively. This allows get_hash to be reimplemented to simply return the hash stored in the extras.

Although technically speaking this is changing the implementation of public facing API, if users even use get_hash() it will have been to retrieve the hash for an already stored node, which is therefore equal to just returning the pre-computed hash stored in the extras. So effectively this should not be a breaking change.

sphuber commented 2 months ago

LGTM. I am wondering, how does this interact with nodes that are stored but not sealed? (such as running Calcjob)

Attributes that can be changed after a node is stored have to be part of _updatable_attributes in order to not incur the ModificationNotAllowed exception and these are automatically excluded from the hash calculation. So these should have no impact whatsoever.