forked from aiidateam/aiida-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
verdi code setup
: validate the uniqueness of the full label (aiidat…
…eam#5205) The full label of a `Code` instance is defined as `label@computer.label`. Recently, the uniqueness of the full label was not even checked and it was possible to create codes with duplicate full labels. Since this was fixed though, `verdi code setup` would only fail when all parameters are parsed and it would try to store the code. In interactive mode, this is pretty annoying as the command will not fail until all parameters have been specified. Here, a validator is added to the `--label` option to check the uniqueness of the full label. In order to check this, it needs the selected computer. To ensure the computer is parsed before the label, the option is defined before the label when the command is defined. At least for the interactive mode, this guarantees that the computer is prompted for before the label, so the callback of the label can check for uniqueness. If it fails, the user is shown the reason why and prompted again. Note that the parsing order of parameters in the non-interactive mode is not guaranteed by the definition order but by the order in which they are passed by the caller. Therefore, the callback of the label cannot be relied upon, because if the label is specified first, the callback won't know the computer and will have to exit. Therefore, the callback has to be called manually once again in the body of the command when it is guaranteed that both the label and computer will have been defined. There is a slight overhead in the sense that the callback is called twice, but the first call will exit almost instantly and so the overhead will be minimal.
- Loading branch information
Showing
3 changed files
with
88 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters