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

Improve code setup #724

Open
danielhollas opened this issue May 9, 2024 · 1 comment
Open

Improve code setup #724

danielhollas opened this issue May 9, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@danielhollas
Copy link
Contributor

We're now having discussions about this in three different places, so creating issue just for this.

I think this comment from Seb and subsequent discussion is critical:

@sphuber would you mind taking a look if the changes here make sense? I am not super familiar in how aiida-core handles User instances.

I had a look but I don't understand what the changes to fetching the default user should do. First of, User.objects is deprecated, and User.collection should be used instead. So the PR changes to use the deprecated version. The current use is correct. To get the default user, User.collection.get_default() is correct. The only tricky part here is that this default is cached on the StorageBackend. So if the default user is changed, this needs to be reset through StorageBackend.reset_default_user. This is done automatically through Manager.set_default_user_email but not if you go directly through Profile.set_default_user_email.

If you want to manually query for a user given an email, I would recommend User.collection.get(email='email'). It is concise and closest in syntax to User.colelction.get_default()

Is seems to me that using StorageBackend.reset_default_user could be used to get rid of the cached User instance, before setting up the codes.

@danielhollas danielhollas added the enhancement New feature or request label May 9, 2024
@danielhollas
Copy link
Contributor Author

cc @unkcpz @superstar54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant