-
Notifications
You must be signed in to change notification settings - Fork 198
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
Manager.load_profile
: do not load default profile if other already loaded
#5383
Manager.load_profile
: do not load default profile if other already loaded
#5383
Conversation
Since this is really a problem of |
@@ -105,15 +105,14 @@ def load_profile(self, profile: Union[None, str, 'Profile'] = None, allow_switch | |||
from aiida.common.log import configure_logging | |||
from aiida.manage.configuration.profile import Profile | |||
|
|||
if profile is None and self._profile: |
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.
if profile is None and self._profile: | |
# If a profile is already loaded and no explicit profile is specified, we do nothing | |
if profile is None and self._profile: |
aiida/manage/manager.py
Outdated
# If a profile is loaded and the specified profile name is that of the currently loaded, do nothing | ||
if self._profile and (self._profile.name == profile.name): | ||
return self._profile | ||
|
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.
I don't think this needs to be removed: it handles for example:
load_profile('x')
load_profile('x') # no-op
I think its ok not to |
…loaded The `Manager.load_profile` method was loading the default profile if no explicit profile name was specified, even if another profile was already loaded. This is violating the note in the docstring that if a profile is already loaded, not specifying an explicit profile to be loaded should be a no-op. This bug was manifesting itself in `verdi` where the `--profile` option was effectively ignored if a profile other than the default was specified for a command that uses the `load_dbenv` decorator. This is because the `ProfileParamType` would correctly load the profile specified by the option, but then the `load_dbenv` decorator would call `aiida.cmdline.utils.decorators.load_backend_if_not_loaded` which would call `Manager.load_profile` without specifying a profile, and so the default profile would be loaded.
18311c4
to
7b50516
Compare
Perhaps we need to increase the allowed verdi load time from 0.4 to 0.41. For python 3.8, it often can be about this. |
Yeah, it is indeed a bit annoying, but it would be better still to see if we can get the load time to decrease. I personally at least find it very annoying to have lag in the tab-completion. |
Fixes #5381
The
Manager.load_profile
method was loading the default profile if noexplicit profile name was specified, even if another profile was already
loaded. This is violating the note in the docstring that if a profile is
already loaded, not specifying an explicit profile to be loaded should
be a no-op.
This bug was manifesting itself in
verdi
where the--profile
optionwas effectively ignored if a profile other than the default was
specified for a command that uses the
load_dbenv
decorator. This isbecause the
ProfileParamType
would correctly load the profilespecified by the option, but then the
load_dbenv
decorator would callaiida.cmdline.utils.decorators.load_backend_if_not_loaded
which wouldcall
Manager.load_profile
without specifying a profile, and so thedefault profile would be loaded.