Skip to content

Commit

Permalink
CLI: Allow higher than index 10 for verdi presto
Browse files Browse the repository at this point in the history
When the user is using `verdi presto` to create more than 11 profiles, the command will
fail because `presto-10` already exists. This is due to the fact that the
`get_default_presto_profile_name()` function sorts the existing indices as strings,
which means `10` will precede `9` and hence the "last index" would be `9`, making the
new index `10`, which already exists.

Here we fix this issue by casting the extracted existing indices as integers, so the
sorting works as intended.
  • Loading branch information
mbercx committed Jun 18, 2024
1 parent 202a3ec commit 53e8439
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/aiida/cmdline/commands/cmd_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_default_presto_profile_name():

for profile_name in profile_names:
if match := re.search(r'presto[-]?(\d+)?', profile_name):
indices.append(match.group(1) or '0')
indices.append(int(match.group(1) or '0'))

if not indices:
return DEFAULT_PROFILE_NAME_PREFIX
Expand Down

0 comments on commit 53e8439

Please sign in to comment.