Skip to content
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

Caching: node class is not taken into account making subclasses potentially indistinguishable #6320

Closed
sphuber opened this issue Mar 17, 2024 · 1 comment · Fixed by #6321

Comments

@sphuber
Copy link
Contributor

sphuber commented Mar 17, 2024

As reported here aiidateam/aiida-quantumespresso#1015
Two data nodes of different classes, but where one is a subclass of the other, will have an identical hash as long as the attributes are the same. This is because Node._get_objects_to_hash does not include the class itself, which it arguably should.

@sphuber
Copy link
Contributor Author

sphuber commented Mar 17, 2024

Example:

In [1]: from aiida.orm import Data, Int

In [2]: i = Int(5).store()

In [3]: d = Data()

In [4]: d.base.attributes.set('value', 5)

In [5]: d.store()
Out[5]: <Data: uuid: 8644cb29-497a-42d8-b723-e895cf30ea56 (pk: 157610)>

In [6]: i.base.caching.get_hash() == d.base.caching.get_hash()
Out[6]: True

This is true because Int is a subclass of Data, but arguably the hashes should be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant