Skip to content

Commit

Permalink
CLI: Fix bug verdi presto when tab-completing without config (#6535)
Browse files Browse the repository at this point in the history
For a clean environment where the config directory had not yet been
created, tab-completing `verdi presto` would result in an exception
being thrown because the callable for the default of the
`--profile-name` option would try to access the configuration.

The exception is now caught and the callable simply returns the default
profile name `presto` which should be correct since no profiles should
exist if there is not even a configuration directory.
  • Loading branch information
sphuber authored Jul 17, 2024
1 parent de83e2c commit a2063f8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/aiida/cmdline/commands/cmd_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@


def get_default_presto_profile_name():
from aiida.common.exceptions import ConfigurationError
from aiida.manage import get_config

profile_names = get_config().profile_names
try:
profile_names = get_config().profile_names
except ConfigurationError:
# This can happen when tab-completing in an environment that did not create the configuration folder yet.
# It would have been possible to just call ``get_config(create=True)`` to create the config directory, but this
# should not be done during tab-completion just to generate a default value.
return DEFAULT_PROFILE_NAME_PREFIX

indices = []

for profile_name in profile_names:
Expand Down

0 comments on commit a2063f8

Please sign in to comment.