You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, short of resetting the manager, there currently doesn't seem to be a way to reset this cache, as one might want to do, for example, after setting a new default user programmatically, deleting the default user, etc.
Resetting this cache could be done at two levels:
A specific command for the User.objects collection that resets its _default_user property
A generic reset() method for objects - objects are loaded lazily and so you can add a generic method
The second solution you proposed, as implemented, will not only reset the collection of that particular entity and backend, but of all collections that have been instantiated. This is not what we want. I would for now go for a specific reset on the default user on the User collection. Anyway, that is the only collection with real state I think.
The second solution you proposed, as implemented, will not only reset the collection of that particular entity and backend, but of all collections that have been instantiated.
Oops - you're right ;-)
Instead of hacking a specific solution for the User, one could probably still do something like this (seems to work)?
defreset(self):
""" Remove lazily constructed collection instance. Removes lazily constructed collection instance from LazyStore (constructed again upon next request). Useful to clear any internal caches of the collection. """self._COLLECTIONS.pop((self.entity_type, self.backend))
Since the default user of an AiiDA profile is requested a lot, we've introduced a cache for this property:
aiida-core/aiida/orm/users.py
Lines 51 to 70 in cc94a1e
However, short of resetting the manager, there currently doesn't seem to be a way to reset this cache, as one might want to do, for example, after setting a new default user programmatically, deleting the default user, etc.
Resetting this cache could be done at two levels:
User.objects
collection that resets its_default_user
propertyreset()
method forobjects
-objects
are loaded lazily and so you can add a generic methodaiida.orm.entities.Collection
This would allow to do
User.objects.reset()
(same forXXX.objects.reset()
).I'm leaning towards the second option - what do you guys think?
@sphuber
@giovannipizzi
The text was updated successfully, but these errors were encountered: