-
Notifications
You must be signed in to change notification settings - Fork 214
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
👌 IMPROVE: Move default user caching to StorageBackend
#5460
Conversation
Same as for #5461 if you add a quick test, we should merge this for the release since it is a known bug of the new profile switching |
Currently it is cached on the `UserCollection`, but this means that, on profile switching, it would return a user associated with the wrong backend instance.
f2cc261
to
d0b5e06
Compare
@sphuber this is good to go |
aiida/orm/groups.py
Outdated
@@ -155,7 +155,7 @@ def __init__( | |||
raise ValueError('Group label must be provided') | |||
|
|||
backend = backend or get_manager().get_profile_storage() | |||
user = user or users.User.collection(backend).get_default() | |||
user = user if user else backend.default_user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the change from user or
to user if user else
necessary? Does that change anything? I think the or
notation is clearer and is also used in the line before.
results = query.all(flat=True) | ||
if results: | ||
self._default_user = results[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was line 178 being tested? Shouldn't all(flat=True)
just return the User
or None
? So line 178 indexing [0]
would except no? Anyway, I think we should just use first
here.
results = query.all(flat=True) | |
if results: | |
self._default_user = results[0] | |
self._default_user = query.first(flat=True) |
@@ -31,7 +31,6 @@ def _entity_base_cls() -> Type['User']: | |||
|
|||
def __init__(self, entity_class: Type['User'], backend: Optional['StorageBackend'] = None) -> None: | |||
super().__init__(entity_class=entity_class, backend=backend) | |||
self._default_user: Optional[User] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overridden constructor is now pointless, might as well get rid of it entirely
Currently it is cached on the
UserCollection
,but this means that, on profile switching,
it would return a user associated with the wrong backend instance.